pay_pal v0.0.5 PayPal.API

Documentation for PayPal.API. This module is about the base HTTP functionality

Link to this section Summary

Functions

Make a HTTP GET request to the correct API depending on environment, adding needed auth header

Requests an OAuth token from PayPal, returns a tuple containing the token and seconds till expiry

Make a HTTP PATCH request to the correct API depending on environment, adding needed auth header

Make a HTTP POST request to the correct API depending on environment, adding needed auth header

Link to this section Functions

Link to this function get(url)
get(String.t()) :: {atom(), any()}

Make a HTTP GET request to the correct API depending on environment, adding needed auth header.

Note: If your name is not Zen and you’re reading this, unless you’re sending me a PR (thanks!), you probably don’t need this.

Possible returns:

  • {:ok, data}
  • {:ok, :not_found}
  • {:ok, :no_content}
  • {:error, :bad_network}
  • {:error, reason}

Examples

iex> PayPal.API.get(url) {:ok, {“XXXXXXXXXXXXXX”, 32000}}

Link to this function get_oauth_token()
get_oauth_token() :: {atom(), any()}

Requests an OAuth token from PayPal, returns a tuple containing the token and seconds till expiry.

Note: If your name is not Zen and you’re reading this, unless you’re sending me a PR (thanks!), you probably don’t need this.

Possible returns:

  • {:ok, {“XXXXXXXXXXXXXX”, 32000}}
  • {:error, :unauthorised}
  • {:error, :bad_network}

Examples

iex> PayPal.API.get_oauth_token {:ok, {“XXXXXXXXXXXXXX”, 32000}}

Link to this function patch(url, data)
patch(String.t(), map()) :: {atom(), any()}

Make a HTTP PATCH request to the correct API depending on environment, adding needed auth header.

Note: If your name is not Zen and you’re reading this, unless you’re sending me a PR (thanks!), you probably don’t need this.

Possible returns:

  • {:ok, data}
  • {:ok, :not_found}
  • {:ok, :no_content}
  • {:error, :bad_network}
  • {:error, reason}

Examples

iex> PayPal.API.patch(url, data) {:ok, {“XXXXXXXXXXXXXX”, 32000}}

Link to this function post(url, data)
post(String.t(), map()) :: {atom(), any()}

Make a HTTP POST request to the correct API depending on environment, adding needed auth header.

Note: If your name is not Zen and you’re reading this, unless you’re sending me a PR (thanks!), you probably don’t need this.

Possible returns:

  • {:ok, data}
  • {:ok, :not_found}
  • {:ok, :no_content}
  • {:error, :bad_network}
  • {:error, reason}

Examples

iex> PayPal.API.post(url, data) {:ok, {“XXXXXXXXXXXXXX”, 32000}}