EliVndb v0.2.2 EliVndb.Client

VNDB API Client Module.

VNDB API Refernce

EliVndb.Client types

Global

In order to start global client use EliVndb.Client.start_link/1 or EliVndb.Client.start_link/3 without options or with :global set to true.

Since the client registered globally, once client is started, all other API functions will become available.

As VNDB allows login only once, you need to re-create it anew in order to re-login. You can use method EliVndb.Client.stop/0 to terminate currently running global client.

Local

In order to start local client use EliVndb.Client.start_link/1 or EliVndb.Client.start_link/3 with :global set to false.

To use local client, you’ll need to provide its pid in all API calls.

NOTE: VNDB allows only up to 10 clients from the same API. Global client is preferable way to work with VNDB API.

Available commands

dbstats

Just retrieves statistics from VNDB.

get

Each get command requires to specify flags & filters.

Following default values are used by EliVndb:

  • flags = ["basic"]
  • filters = (id >= 1)

On success it returns {:results, %{...}}

set

Each set command requires you to provide ID of modified object.

On success it returns {:ok, %{...}}

NOTE: For set commands successful response contains empty payload as of now. You might as well to ignore it.

Result

Each function that returns map with keys as strings.

Summary

Types

Get command options

Set command options

Client initialization options

Functions

Retrieves VNDB stats using particular client

Performs GET command with character type

Performs GET command with producer type

Performs GET command with release type

Performs GET command with staff type

Performs GET command with user type

Performs GET command with vn type

Performs GET command with vnlist type

Performs GET command with votelist

Performs GET command with wishlist type

Returns name of global client

Performs SET command with votelist type

Performs SET command with votelist type

Performs SET command with votelist type

Starts VNDB API Client without authorization

Starts VNDB API Client with provided credentials

Stops global client

Stops particular client

Types

get_options()
get_options() :: [type: iodata, flags: [iodata], filters: iodata, options: Map.t]

Get command options

set_options()
set_options() :: [type: iodata, id: integer, fields: Map.t]

Set command options

start_options()
start_options() :: [{:global, boolean}]

Client initialization options

Functions

dbstats(pid \\ EliVndb.Client)
dbstats(GenServer.server) :: term

Retrieves VNDB stats using particular client.

Arguments:

  • pid - Client identifier. Global is used as default.

Reference

On success returns: {:dbstats, map()}

get(options, pid \\ EliVndb.Client)

Performs GET command.

Reference

Arguments:

  • options - Keyword list of command options. See below.
  • pid - Client identifier. Global is used as default.

Options:

  • :type - Command type. See VNDB API for possible values.
  • :flags - Command flags as array of strings. Possible values depends on :type.
  • :filters - Command filters as string. Possible values depends on :type.
  • :options - Command options as map. VNDB API allows following keys: page: integer, results: integer, sort: string, reverse: boolean

Following default values are used by EliVndb:

  • flags = ["basic"]
  • filters = id >= 1

On success returns: {:results, map()}

get_character(options, pid \\ EliVndb.Client)
get_character(get_options, GenServer.server) :: term

Performs GET command with character type.

The same as EliVndb.Client.get/2

get_producer(options, pid \\ EliVndb.Client)
get_producer(get_options, GenServer.server) :: term

Performs GET command with producer type.

The same as EliVndb.Client.get/2

get_release(options, pid \\ EliVndb.Client)
get_release(get_options, GenServer.server) :: term

Performs GET command with release type.

The same as EliVndb.Client.get/2

get_staff(options, pid \\ EliVndb.Client)
get_staff(get_options, GenServer.server) :: term

Performs GET command with staff type.

The same as EliVndb.Client.get/2

get_user(options, pid \\ EliVndb.Client)
get_user(get_options, GenServer.server) :: term

Performs GET command with user type.

The same as EliVndb.Client.get/2

get_vn(options, pid \\ EliVndb.Client)
get_vn(get_options, GenServer.server) :: term

Performs GET command with vn type.

The same as EliVndb.Client.get/2

get_vnlist(options, pid \\ EliVndb.Client)
get_vnlist(get_options, GenServer.server) :: term

Performs GET command with vnlist type.

The same as EliVndb.Client.get/2

get_votelist(options, pid \\ EliVndb.Client)
get_votelist(get_options, GenServer.server) :: term

Performs GET command with votelist.

The same as EliVndb.Client.get/2

get_wishlist(options, pid \\ EliVndb.Client)
get_wishlist(get_options, GenServer.server) :: term

Performs GET command with wishlist type.

The same as EliVndb.Client.get/2

global_name()

Returns name of global client.

set(options, pid \\ EliVndb.Client)

Performs SET command.

Reference

Arguments:

  • options - Keyword list of command options. See below.
  • pid - Client identifier. Global is used as default.

Options:

  • :type - Command type. See VNDB API for possible values.
  • :id - Identifier of object on which to perform SET.
  • :fields - Map of object’s field to its new value.
set_vnlist(options, pid \\ EliVndb.Client)
set_vnlist(set_options, GenServer.server) :: term

Performs SET command with votelist type.

The same as EliVndb.Client.set/2

set_votelist(options, pid \\ EliVndb.Client)
set_votelist(set_options, GenServer.server) :: term

Performs SET command with votelist type.

The same as EliVndb.Client.set/2

set_wishlist(options, pid \\ EliVndb.Client)
set_wishlist(set_options, GenServer.server) :: term

Performs SET command with votelist type.

The same as EliVndb.Client.set/2

start_link(opts \\ [])

Starts VNDB API Client without authorization.

Note that some VNDB APIs may require you to provide login/password.

Options:

  • :global - whether to register client globally.
start_link(user, password, opts \\ [])
start_link(binary | nil, binary | nil, start_options) :: GenServer.on_start

Starts VNDB API Client with provided credentials.

Parameters:

  • user - Username to use for login. To omit provide nil
  • password - Password to use for login. To omit provide nil

Options:

  • :global - whether to register client globally.
stop()
stop() :: :ok

Stops global client.

Does nothing if client hasn’t been started.

stop(pid)
stop(GenServer.server) :: :ok

Stops particular client