TaxJar.Requests.HTTPAdapters.ReqAdapter (tax_jar v0.3.0)
An HTTP adapter using the Req
library. See the Hex docs
for more information on it's features.
Summary
Functions
Perform a POST request to the API using the Req library.
Functions
Link to this function
post(path, body, opts \\ [])
Perform a POST request to the API using the Req library.
Options
The given options are passed to Req.post/2
. See the Req docs
for all of the available options and what they do.
The following default options are provided (but can be overriden):
auth
: The configured:api_key
is used.base_url
: The configured:api_url
is used.headers
: The default headers contain the configured:api_version
.json
: The givenbody
is encoded as JSON.
Errors
When a request is not successful a TaxJar.Requests.Error
is returned.
When the API returns an error
The error fields will be as follows:
:details
: TheReq.Response
struct received as the response.:message
: The error message as defined in the API. Default is"Request failed"
.:reason
: An atom representing the status code. SeeTaxJar.Requests.Error.statuses_lookup
.Default is `:api_error` if the status is outside what the API supports.
JSON Decoding Errors
When the response can't be decoded then the error struct is provided as the :details
attribute
and the reason will be :json_decode_error
.