Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.
/ weebpotion Public archive

Incomplete Elixir Wrapper for the toph Image API portion of weeb.sh

License

Notifications You must be signed in to change notification settings

luaugg/weebpotion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weebpotion

An Elixir wrapper for the toph portion of weeb.sh. Toph refers to the standard image features like fetching crying images. weebpotion will eventually support the rest of the weeb.sh API, but for now only toph is supported.

Adding weebpotion

weebpotion is available in Hex so you can add it as you would any other dependency:

def deps do
  [
    {:weebpotion, "~> 0.2.1"}
  ]
end

Documentation can be found here.

Basic Usage

All functionality in weebpotion is located in the WeebPotion.Api module, and all of it depends on a WeebPotion.Struct.Client which you can obtain with the following code:

WeebPotion.Struct.Client.start [] # Mandatory -- use this to start the HTTPoison Requester.
client = WeebPotion.Struct.Client.new(token: "your weeb.sh token", application_name: "test", version: "1.0.0")
# Check out the documentation to see all the options accepted by the `new/1` function.

Then you can do things such as fetching images with the code:

WeebPotion.Api.random_image!(client, type: "cry").url
|> IO.inspect

# image URL
# again, check out the documentation to see all the accepted options.

Note: In accordance with Erlang tradition, "banged" method alternatives (ones whose names end with exclamation marks) exist which fail fast instead of returning :ok and :error tuples.

Maps vs Structs

Due to my own inexperience/lack of knowledge using Poison in a complicated manner and also the fact that I want to save performance, WeebPotion.Struct.Image structs are only returned if the response itself is an image object.

If it needs to be converted or modified in any way, weebpotion will just return the raw map instead of a converted image struct.

About

Incomplete Elixir Wrapper for the toph Image API portion of weeb.sh

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages