Epik.Client (Epik v0.2.4) View Source
API client for the Epik.com v2 API.
Interact with the API directly. It's usually better to use the Epik module
if such a function exists. Otherwise, this module can do everything else.
The
pathparameter in each function is appended to the endpoint set in your config. It should always begin with a forward slash, for example:/v2/domains/checkThe
signatureincluded in your config is used automatically to authenticate requests.
It uses HTTPoison to make requests and parses the response with Jason.
The API is slightly different than HTTPoison to make it more ergonomic
for use with Epik, but it does return HTTPoison.Response structs.
Link to this section Summary
Functions
Send a GET request.
Send a POST request.
General request function. If there's something the other functions in this module can't do, you can use this instead.
Link to this section Functions
Specs
get(path :: String.t(), params :: map()) :: {:ok, HTTPoison.Response.t()} | {:error, any()}
Send a GET request.
iex(1)> Epik.Client.get("/v2/domains/check", %{"DOMAINS" => "tribes.host,fediverse.gold"})
{:ok,
%HTTPoison.Response{
status_code: 200,
body: %{
"code" => 1000,
"data" => %{
"FEDIVERSE.GOLD" => %{
"available" => 1,
"domain" => "FEDIVERSE.GOLD",
"premium" => 0,
"price" => 5.49,
"supported" => 1
},
"TRIBES.HOST" => %{
"available" => 0,
"available_reason" => "in use",
"domain" => "TRIBES.HOST",
"premium" => 0,
"supported" => 1
}
},
"message" => "Command completed successfully."
}
}}
Specs
post(path :: String.t(), body :: any()) :: {:ok, HTTPoison.Response.t()} | {:error, any()}
Send a POST request.
iex(1)> Epik.Client.post("/v2/domains/fedigold.xyz/create", %{"PERIOD" => 1})
{:ok,
%HTTPoison.Response{
status_code: 200,
body: %{
"code" => 1000,
"data" => %{
"FEDIGOLD.XYZ" => %{
"error" => 0,
"message" => "Successfully created",
"payment" => %{
"error" => 0,
"paymentStatus" => true,
"paymentValue" => 0.99,
"period" => "1",
"pricePerPeriod" => 0.99
},
"paymentStatus" => true,
"paymentValue" => 0.99,
"period" => "1",
"pricePerPeriod" => 0.99
}
},
"message" => "Command completed successfully.",
"period" => "1",
"total" => %{
"amount" => 0.99,
"message" => "Withdraw money successfully",
"method" => "Balance",
"success" => true
}
}
}}
request(method, path, params \\ %{}, body \\ "", headers \\ [], options \\ [])
View SourceSpecs
request( method :: HTTPoison.Base.method(), path :: String.t(), params :: map(), body :: any(), headers :: HTTPoison.Base.headers(), options :: Keyword.t() ) :: {:ok, HTTPoison.Response.t()} | {:error, any()}
General request function. If there's something the other functions in this module can't do, you can use this instead.
iex(1)> Epik.Client.request(:get, "/v2/domains/check", %{"DOMAINS" => "tribes.host,fediverse.gold"}, "", [{"user-agent", "Epik Elixir API Client <https://hex.pm/packages/epik>; Bot"}])
{:ok,
%HTTPoison.Response{
status_code: 200,
body: %{
"code" => 1000,
"data" => %{
"FEDIVERSE.GOLD" => %{
"available" => 1,
"domain" => "FEDIVERSE.GOLD",
"premium" => 0,
"price" => 5.49,
"supported" => 1
},
"TRIBES.HOST" => %{
"available" => 0,
"available_reason" => "in use",
"domain" => "TRIBES.HOST",
"premium" => 0,
"supported" => 1
}
},
"message" => "Command completed successfully."
}
}}