Godaddy v0.4.0 Godaddy.Api View Source

Make generic HTTP calls a web service. Please update (or remove) the tests to a sample service in the examples below.

Link to this section Summary

Functions

Retrieve data from the API using either :get or :post

Encode the provided hash map for the URL

Build the headers for your API

Make an API call using GET. Optionally provide any required headers

Make an API call using PATCH. Optionally provide any required data and headers

Make an API call using POST. Optionally provide any required data and headers

Link to this section Functions

Retrieve data from the API using either :get or :post

Encode the provided hash map for the URL.

Examples

iex> Godaddy.Api.encode_body(%{a: "one", b: "two"})
"{\"b\":\"two\",\"a\":\"one\"}"

iex> Godaddy.Api.encode_body(%{a: "o ne"})
"{\"a\":\"o ne\"}"

iex> Godaddy.Api.encode_body(nil, %{a: "o ne"})
"{\"a\":\"o ne\"}"

iex> Godaddy.Api.encode_body("application/x-www-form-urlencoded", %{a: "o ne"})
"a=o+ne"

iex> Godaddy.Api.encode_body("application/json", %{a: "b"})
"{\"a\":\"b\"}"

Build the headers for your API

Examples

iex> Godaddy.Api.encode_headers(%{content_type: "application/json", ssokey: {"pqr123", "mno456"}})
[{"Content-Type", "application/json"}, {"Authorization", "sso-key pqr123:mno456"}]

iex> Godaddy.Api.encode_headers(%{ssokey: {"pqr123", "mno456"}})
[{"Content-Type", "application/json"}, {"Authorization", "sso-key pqr123:mno456"}]

iex> Godaddy.Api.encode_headers(%{})
[{"Content-Type", "application/json"}, {"Authorization", "sso-key abc123:def456"}]

iex> Godaddy.Api.encode_headers()
[{"Content-Type", "application/json"}, {"Authorization", "sso-key abc123:def456"}]

iex> Godaddy.Api.encode_headers(nil)
[{"Content-Type", "application/json"}, {"Authorization", "sso-key abc123:def456"}]

Make an API call using GET. Optionally provide any required headers

Make an API call using PATCH. Optionally provide any required data and headers

Link to this function patch(source, body, headers) View Source

Make an API call using POST. Optionally provide any required data and headers

Link to this function post(source, body, headers) View Source