class OwO::WhatsThis
- OwO::WhatsThis
- Reference
- Object
Overview
WhatsThis refers to the actual client which is to be used with the wrapper.
It is the entrypoint for any application wishing to use it, and is the only part of this meant to be used.
Defined in:
Constructors
-
.new(token : String, user_agent : String = USER_AGENT, api_uri : String = API_URI)
Initializes a new client instance with the following data:
Instance Method Summary
-
#data_base : String?
The base URI for all normal data uploaded.
-
#data_base=(data_base : String?)
The base URI for all normal data uploaded.
-
#shorten(uri : String | URI)
#shortenshortens theStringURI or theURIinstance as input. -
#shorten_base : String?
The base URI for all shortenings.
-
#shorten_base=(shorten_base : String?)
The base URI for all shortenings.
-
#upload(first : UploadData, second : UploadData?, third : UploadData? = nil)
#uploaduploads the data fromOwO::UploadDataobjects. -
#upload(data : UploadData)
#uploaduploads data given byOwO::UploadDataby passing it to the overloaded#uploadmethod which takes three of them and spits out a tuple of three nullableOwO::UploadedFile.
Constructor Detail
Initializes a new client instance with the following data:
- token being the OwO token.
The token may not have the dashes stripped and must not include any form for whitespace.
If the token is empty, it will raise an
Exceptions::InvalidTokenexception. - user_agent being the User-Agent field.
The User-Agent to be used. This is not recommended to change, as your application may be denied access to the API.
It is defaulted to
OwO::USER_AGENT. - api_uri being the API URI endpoint.
The API endpoint URI to connect to and use while using the client.
Its default value is
OwO::API_URI.
It in turn initializes a new Cossack::Client which follows redirections and has the following headers:
User-Agent=> user_agentAuthorization=> token
Instance Method Detail
The base URI for all normal data uploaded.
This gets prepended to every url field in the OwO::UploadedFileData objects.
NOTE This only applies to #upload_data and #upload_file.
The base URI for all normal data uploaded.
This gets prepended to every url field in the OwO::UploadedFileData objects.
NOTE This only applies to #upload_data and #upload_file.
#shorten shortens the String URI or the URI instance as input.
The single parameter uri specifies the String or URI to shorten and must be a standard UTF-8 URI.
Under the following circumstances are exceptions raised:
Exceptions::Unauthorizedis raised if the@tokenvalue is deactivated.Exceptions::OwOInternalErroris raised if OwO has an internal error at their API.
A 404 error is not handled by this library and may result in a panic.
It returns a String which is the endpoint key for the CDN.
In order to access it, you'll need to prefix it with a valid CDN URI, found on the OwO FAQ.
The base URI for all shortenings. This gets prepended to the shortened URI return.
NOTE This only applies to #shorten.
The base URI for all shortenings. This gets prepended to the shortened URI return.
NOTE This only applies to #shorten.
#upload uploads the data from OwO::UploadData objects.
You can pass up to three, as that's what OwO limits it at, but if it were higher, there would be more support.
Under the following circumstances are exceptions raised:
Exceptions::Unauthorizedis raised if the@tokenvalue is deactivated.Exceptions::TooLargePayloadis raised if OwO changes the payload max size before this library updates.Exceptions::TooLargeis raised if you upload data over the size of 100MiB.Exceptions::OwOInternalErroris raised if OwO has an internal error at their API.
A 404 error is not handled by this library and may result in a panic.
It does not return OwO::UploadedFile as it did in v0.1.0, however it returns OwO::UploadedFileData.
In this case it however returns it as Tuple(UploadedFileData?, UploadedFileData?, UploadedFileData?).
#upload uploads data given by OwO::UploadData by passing it to the overloaded #upload
method which takes three of them and spits out a tuple of three nullable OwO::UploadedFile.
All this does is call #upload with two nil arguments and get the first tuple member.
Under the following circumstances are exceptions raised:
Exceptions::Unauthorizedis raised if the@tokenvalue is deactivated.Exceptions::TooLargePayloadis raised if OwO changes the payload max size before this library updates.Exceptions::TooLargeis raised if you upload data over the size of 100MiB.Exceptions::OwOInternalErroris raised if OwO has an internal error at their API.
A 404 error is not handled by this library and may result in a panic.
NOTE The return is nullable and there is no guarantee this conforms to your needs.