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 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
@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
@spec execute(execute_options(), Craftgate.Config.t()) :: success_result() | error_result()
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 tonil
: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 toHTTPoison
. Will default to the empty list[]
. Refer toHTTPoison.options/3
for more details.
@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
@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
@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
@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
@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