View Source Craftgate.HttpClient (Craftgate v1.0.42)

The module responsible for sending requests to Craftgate API

Uses HTTPoison in the background to execute requests and the Craftgate.Serializable module to encode/decode requests and responses

Link to this section Summary

Functions

Convenience method to get the current Craftgate configuration and execute a DELETE request

Executes a request against Craftgate API with the given properties

Convenience method to get the current Craftgate configuration and execute a GET request

Convenience method to get the current Craftgate configuration and execute a HEAD request

Convenience method to get the current Craftgate configuration and execute a PATCH request

Convenience method to get the current Craftgate configuration and execute a POST request

Convenience method to get the current Craftgate configuration and execute a PUT request

Link to this section Types

@type body() :: term()
@type error_result() :: {:error, any()}
@type execute_options() :: [
  method: method(),
  url: url(),
  lang: binary() | nil,
  body: body() | nil,
  params: params() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
]
@type headers() :: keyword()
@type method() :: :get | :post | :put | :patch | :delete | :options | :head
@type params() :: keyword()
@type request_options() :: HTTPoison.options()
@type success_result() ::
  {:ok,
   HTTPoison.Response.t()
   | HTTPoison.AsyncResponse.t()
   | HTTPoison.MaybeRedirect.t()}
@type url() :: URI.t()

Link to this section Functions

Link to this function

delete!(url, params \\ [], additional_options \\ [])

View Source
@spec delete!(url(), params(),
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a DELETE request

Link to this function

execute(options, config)

View Source

Executes a request against Craftgate API with the given properties

The list of options that can be passed in the options keyword list are as follows:

  • :method - (Required) The HTTP method to send with the request
  • :url - (Required) The path or the relative URL to send the request to
  • :params - (Optional) The keyword list of query parameters to append to the URL. Will default to the empty list []
  • :body - (Optional) The body to send the request with. Will default to nil
  • :lang - (Optional) The language to send the request with. Whe default language from the configuration will be used
  • :headers - (Optional) The list of additional headers to send the request with. Will default to the empty list []. Built-in headers (x-api-key, x-auth-version, x-signature, lang, etc.) will be overridden with the calculated values
  • :request_options - (Optional) The keyword list of request options to specify to HTTPoison. Will default to the empty list []. Refer to HTTPoison.options/3 for more details.
Link to this function

get!(url, params \\ [], additional_options \\ [])

View Source
@spec get!(url(), params(),
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a GET request

Link to this function

head!(url, params \\ [], additional_options \\ [])

View Source
@spec head!(url(), params(),
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a HEAD request

Link to this function

patch!(url, body \\ nil, additional_options \\ [])

View Source
@spec patch!(url(), body() | nil,
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a PATCH request

Link to this function

post!(url, body \\ nil, additional_options \\ [])

View Source
@spec post!(url(), body() | nil,
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a POST request

Link to this function

put!(url, body \\ nil, additional_options \\ [])

View Source
@spec put!(url(), body() | nil,
  lang: binary() | nil,
  headers: headers() | nil,
  request_options: request_options() | nil
) :: success_result() | no_return()

Convenience method to get the current Craftgate configuration and execute a PUT request