weebpotion v0.2.1 WeebPotion.Api View Source
Contains all the functionality of WeebPotion, such as requesting random images (via random_image!/2
and random_image/2
) etc.
All function names ending with an exclamation mark indicate functions that fail-fast, as is Erlang tradition.
Link to this section Summary
Functions
Requests an image object associated with a specific ID and fails-fast unlike the “non-banged” image_info/2
variant
Requests an image object associated with a specific ID but doesn’t fail fast unlike the “banged” image_info!/2
variant
Requests a list of image tags. Fails fast unlike the “non-banged” image_tags/2
variant
Requests a list of image tags. Doesn’t fail fast unlike the “banged” image_tags!/2
variant
Requests a list of image types which change depending on the options passed. Fails fast unlike the “non-banged” image_types/2
variant
Requests a list of image types which change depending on the options passed. Doesn’t fail fast unlike the “banged” image_types!/2
variant
Requests a random image with a given type from weeb.sh, but fails fast unlike the “non-banged” random_image/2
variant
Requests a random image with a given type from weeb.sh, but doesn’t fail fast unlike the “banged” random_image!/2
variant
Link to this section Functions
image_info!(WeebPotion.Struct.Client.t(), String.t()) :: WeebPotion.Struct.Image.t()
Requests an image object associated with a specific ID and fails-fast unlike the “non-banged” image_info/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate the request.image_id
: The ID of the image you want information on.
Examples
iex>WeebPotion.Api.image_info!(client, "r1WMmLQvW")
%WeebPotion.Struct.Image{
account: "HyxjFGfPb",
baseType: "cry",
fileType: "gif",
hidden: false,
id: "r1WMmLQvW",
mimeType: "image/gif",
nsfw: false,
source: nil,
tags: [],
type: "cry",
url: "https://cdn.weeb.sh/images/r1WMmLQvW.gif"
}
image_info(WeebPotion.Struct.Client.t(), String.t()) :: {:ok, WeebPotion.Struct.Image.t()} | {:error, any()}
Requests an image object associated with a specific ID but doesn’t fail fast unlike the “banged” image_info!/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate the request.image_id
: The ID of the image you want information on.
Examples
iex>WeebPotion.Api.image_info(client, "r1WMmLQvW")
{:ok, %WeebPotion.Struct.Image{
account: "HyxjFGfPb",
baseType: "cry",
fileType: "gif",
hidden: false,
id: "r1WMmLQvW",
mimeType: "image/gif",
nsfw: false,
source: nil,
tags: [],
type: "cry",
url: "https://cdn.weeb.sh/images/r1WMmLQvW.gif"
}}
image_tags!(WeebPotion.Struct.Client.t(), list()) :: list()
Requests a list of image tags. Fails fast unlike the “non-banged” image_tags/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate requests.opts
: A key-word list of options that modify the response received.
Examples
iex>WeebPotion.Api.image_tags(client)
["nuzzle", "cuddle", "momiji inubashiri", "wan", "astolfo", "facedesk",
"everyone", "b1nzy", "trap_normal", "trap_memes", "meta-pixiv-8189060"]
Supported Options
:hidden
- Whether or not to show hidden image tags you uploaded. Defaults tofalse
.:nsfw
- Whether or not to show NSFW image tags. Defaults tofalse
.
image_tags(WeebPotion.Struct.Client.t(), list()) :: {:ok, list()} | {:error, any()}
Requests a list of image tags. Doesn’t fail fast unlike the “banged” image_tags!/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate requests.opts
: A key-word list of options that modify the response received.
Examples
iex>WeebPotion.Api.image_tags(client)
{:ok, ["nuzzle", "cuddle", "momiji inubashiri", "wan", "astolfo", "facedesk",
"everyone", "b1nzy", "trap_normal", "trap_memes", "meta-pixiv-8189060"]}
Supported Options
:hidden
- Whether or not to show hidden image tags you uploaded. Defaults tofalse
.:nsfw
- Whether or not to show NSFW image tags. Defaults tofalse
.
image_types!(WeebPotion.Struct.Client.t(), list()) :: list() | [{String.t(), map()}]
Requests a list of image types which change depending on the options passed. Fails fast unlike the “non-banged” image_types/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate the request.opts
: A key-word list of options that modify the response received.
Examples
iex>WeebPotion.Api.image_types(client, preview: true)
[{"awoo", %{
"baseType" => "awoo",
"fileType" => "gif",
"id" => "BJZfMrXwb",
"type" => "awoo",
"url" => "https://cdn.weeb.sh/images/BJZfMrXwb.gif"
}}, ...]
iex>WeebPotion.Api.image_types(client)
["awoo", "bang", "blush", ...]
Supported Options
:nsfw
: Whether or not NSFW image types should be returned. Defaults tofalse
.:hidden
: Whether or not hidden images you uploaded should be returned. Defaults tofalse
.:preview
: Whether or not preview images should be returned along with their associated types. Defaults tofalse
.
Requests a list of image types which change depending on the options passed. Doesn’t fail fast unlike the “banged” image_types!/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance, used to authenticate the request.opts
: A key-word list of options that modify the response received.
Examples
iex>WeebPotion.Api.image_types(client, preview: true)
{:ok, [{"awoo", %{
"baseType" => "awoo",
"fileType" => "gif",
"id" => "BJZfMrXwb",
"type" => "awoo",
"url" => "https://cdn.weeb.sh/images/BJZfMrXwb.gif"
}}, ...]}
iex>WeebPotion.Api.image_types(client)
{:ok, ["awoo", "bang", "blush", ...]}
Supported Options
:nsfw
: Whether or not NSFW image types should be returned. Defaults tofalse
.:hidden
: Whether or not hidden images you uploaded should be returned. Defaults tofalse
.:preview
: Whether or not preview images should be returned along with their associated types. Defaults tofalse
.
random_image!(WeebPotion.Struct.Client.t(), list()) :: WeebPotion.Struct.Image.t()
Requests a random image with a given type from weeb.sh, but fails fast unlike the “non-banged” random_image/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance.opts
: A key-word list of arguments which can be passed to return different results.
Examples
iex>WeebPotion.Api.random_image(client, type: "cry")
%WeebPotion.Struct.Image{
account: "HyxjFGfPb",
baseType: "cry",
fileType: "gif",
hidden: false,
id: "r1WMmLQvW",
mimeType: "image/gif",
nsfw: false,
source: nil,
tags: [],
type: "cry",
url: "https://cdn.weeb.sh/images/r1WMmLQvW.gif"
}
Supported Options
type
: A mandatory option which tells weeb.sh what type of image to send.nsfw
: If NSFW images should be sent. Can be equal totrue
,false
or:only
. Defaults tofalse
.hidden
: If hidden images you uploaded should be sent. Can be equal totrue
orfalse
. Defaults tofalse
.filetype
: What filetype images should be. Can be equal to:gif
,:jpg
,:jpeg
,:png
or:both
. Defaults to:both
.
random_image(WeebPotion.Struct.Client.t(), list()) :: {:ok, WeebPotion.Struct.Image.t()} | {:error, any()}
Requests a random image with a given type from weeb.sh, but doesn’t fail fast unlike the “banged” random_image!/2
variant.
Parameters
client
: AWeebPotion.Struct.Client
instance.opts
: A key-word list of arguments which can be passed to return different results.
Examples
iex>WeebPotion.Api.random_image(client, type: "cry")
{:ok, %WeebPotion.Struct.Image{
account: "HyxjFGfPb",
baseType: "cry",
fileType: "gif",
hidden: false,
id: "r1WMmLQvW",
mimeType: "image/gif",
nsfw: false,
source: nil,
tags: [],
type: "cry",
url: "https://cdn.weeb.sh/images/r1WMmLQvW.gif"
}}
Supported Options
type
: A mandatory option which tells weeb.sh what type of image to send.nsfw
: If NSFW images should be sent. Can be equal totrue
,false
or:only
. Defaults tofalse
.hidden
: If hidden images you uploaded should be sent. Can be equal totrue
orfalse
. Defaults tofalse
.filetype
: What filetype images should be. Can be equal to:gif
,:jpg
,:jpeg
,:png
or:both
. Defaults to:both
.