plotka v0.1.0 Plotka

Elixir wrapper for GwentAPI. Developed using Tesla HTTP Client.

Płotka (English: Roach) is the name that Geralt of Rivia, the witcher, gives to all of his horses. His preference is for mares. © http://witcher.wikia.com/wiki/Roach

Summary

Functions

Perform a GET request. See request/1 or request/2 for options definition

Perform a GET request. See request/1 or request/2 for options definition

Perform a GET request. See request/1 or request/2 for options definition

Perform a request. See request/2 for available options

Perform a request using client function

Retrieve avaiable resources list

Types

option()
option ::
  {:method, Tesla.Env.method} |
  {:url, Tesla.Env.url} |
  {:query, Tesla.Env.query} |
  {:headers, Tesla.Env.headers} |
  {:body, Tesla.Env.body} |
  {:opts, Tesla.Env.opts}

Functions

get(url)

Perform a GET request. See request/1 or request/2 for options definition.

Example

iex> ExampleApi.get("/users")

Perform a GET request. See request/1 or request/2 for options definition.

Example

iex> myclient |> ExampleApi.get("/users")
iex> ExampleApi.get("/users", query: [page: 1])
get(client, url, options)

Perform a GET request. See request/1 or request/2 for options definition.

Example

iex> myclient |> ExampleApi.get("/users", query: [page: 1])
request(options)
request([option]) :: Tesla.Env.t

Perform a request. See request/2 for available options.

request(client, options)

Perform a request using client function

Options:

  • :method - the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]
  • :url - either full url e.g. “http://example.com/some/path” or just “/some/path” if using Tesla.Middleware.BaseUrl
  • :query - a keyword list of query params, e.g. [page: 1, per_page: 100]
  • :headers - a keyworld list of headers, e.g. [{"content-type", "text/plain"}]
  • :body - depends on used middleware:

    • by default it can be a binary
    • if using e.g. JSON encoding middleware it can be a nested map
    • if adapter supports it it can be a Stream with any of the above
  • :opts - custom, per-request middleware or adapter options

Examples:

iex> ExampleApi.request(method: :get, url: "/users/path")

You can also use shortcut methods like:

iex> ExampleApi.get("/users/1")

or

iex> myclient |> ExampleApi.post("/users", %{name: "Jon"})
resources()

Retrieve avaiable resources list.

Example:

iex> Plotka.resources

%{"cards" => "https://api.gwentapi.com/v0/cards/",
  "factions" => "https://api.gwentapi.com/v0/factions/",
  "glyphs" => "https://api.gwentapi.com/v0/glyphs/",
  "patches" => "https://api.gwentapi.com/v0/patches/",
  "rarities" => "https://api.gwentapi.com/v0/rarities/",
  "types" => "https://api.gwentapi.com/v0/types/"}