class OwO::WhatsThis

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

Instance Method Summary

Constructor Detail

def self.new(token : String, user_agent : String = USER_AGENT, api_uri : String = API_URI) #

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::InvalidToken exception.
  • 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_agent
  • Authorization => token

Instance Method Detail

def data_base : String? #

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.


def data_base=(data_base : String?) #

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.


def shorten(uri : String | URI) #

#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:

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.


def shorten_base : String? #

The base URI for all shortenings. This gets prepended to the shortened URI return.

NOTE This only applies to #shorten.


def shorten_base=(shorten_base : String?) #

The base URI for all shortenings. This gets prepended to the shortened URI return.

NOTE This only applies to #shorten.


def upload(first : UploadData, second : UploadData?, third : UploadData? = nil) #

#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:

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?).


def upload(data : UploadData) #

#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:

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.