wpcom.ex v0.3.0 Wpcom View Source

wpcom.ex is the official Elixir library for the WordPress.com REST API

Link to this section Summary

Functions

Builds api base URL.

Builds a full API url using the supplied path and optional api version.

Fetches api version config value if it exists and valid; default if not.

Generate a WP.com OAuth authorize URL with the given arguments

Switches wpcom.ex to the supplied api version.

Link to this section Types

Link to this type

blog_id()

View Source
blog_id() :: pos_integer() | nil
Link to this type

grant_type()

View Source
grant_type() ::
  :authorization_code | :client_credentials | :password | :wpcom_exchange_token
Link to this type

scope()

View Source
scope() :: :auth | :global

Link to this section Functions

Link to this function

api_base(version)

View Source
api_base(:restV1 | :restV11 | :wpV2 | :wpcomV2) :: String.t()

Builds api base URL.

Link to this function

api_url(endpoint, api_version \\ nil)

View Source
api_url(String.t(), :restV1 | :restV11 | :wpV2 | :wpcomV2 | nil) :: String.t()

Builds a full API url using the supplied path and optional api version.

Link to this function

get_api_version()

View Source
get_api_version() :: :restV1 | :restV11 | :wpV2 | :wpcomV2

Fetches api version config value if it exists and valid; default if not.

Link to this function

oauth_authorize_url(client_id, redirect_uri, scope \\ :auth, blog \\ nil)

View Source
oauth_authorize_url(pos_integer(), String.t(), scope(), blog_id()) :: String.t()

Generate a WP.com OAuth authorize URL with the given arguments

Response type is forced to "code" as implicit OAuth is bad practice, particularly serverside like this library.

Link to this function

retrieve_oauth_token(client_id, client_secret, oauth_code, redirect_uri, grant_type \\ :authorization_code)

View Source
retrieve_oauth_token(
  pos_integer(),
  String.t(),
  String.t(),
  String.t(),
  grant_type()
) :: Wpcom.Req.http_response()

Retrieve an WP.com OAuth token

Requires a previously returned auth code.

Link to this function

switch_api_version(new_version)

View Source
switch_api_version(:restV1 | :restV11 | :wpV2 | :wpcomV2) :: :ok

Switches wpcom.ex to the supplied api version.