StripePost v0.4.1 StripePost.Api View Source
Link to this section Summary
Functions
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
Retrieve data from the API using either :get or :post
Post a message to the Stripe API by providing all the necessary information. The answer will be
The Stripe API URL
Link to this section Functions
Encode the provided hash map for the URL.
Examples
iex> StripePost.Api.encode_body(%{a: "one", b: "two"})
"a=one&b=two"
iex> StripePost.Api.encode_body(%{a: "o ne"})
"a=o+ne"
iex> StripePost.Api.encode_body(nil, %{a: "o ne"})
"a=o+ne"
iex> StripePost.Api.encode_body("application/x-www-form-urlencoded", %{a: "o ne"})
"a=o+ne"
iex> StripePost.Api.encode_body("application/json", %{a: "b"})
"{\"a\":\"b\"}"
Build the headers for your API
Examples
iex> StripePost.Api.encode_headers(%{content_type: "application/json", secret_key: "abc123"})
[{"Authorization", "Bearer abc123"}, {"Content-Type", "application/json"}]
iex> StripePost.Api.encode_headers(%{secret_key: "abc123"})
[{"Authorization", "Bearer abc123"}, {"Content-Type", "application/x-www-form-urlencoded"}]
iex> StripePost.Api.encode_headers(%{})
[{"Authorization", "Bearer sk_test_abc123"}, {"Content-Type", "application/x-www-form-urlencoded"}]
iex> StripePost.Api.encode_headers()
[{"Authorization", "Bearer sk_test_abc123"}, {"Content-Type", "application/x-www-form-urlencoded"}]
Make an API call using GET. Optionally provide any required headers
Retrieve data from the API using either :get or :post
Post a message to the Stripe API by providing all the necessary information. The answer will be
If the call succeeds, the response will look like
{status_code, body}
Where the status_code is the response code from the API, e.g. 200
If there is an error, we will return something like
{:error, "some reason"}