Library.Campdoc (Portico/Z v0.1.0)

Context for accessing Campdoc API functions.

See also Z.MIS for context/userland functions + more discussion of usage.

See https://github.com/docnetwork/api/blob/master/v2 for more information about the Campdoc API.

Setup

Requires config.exs to have a setup incantation like so:

config :library, 
  Library.Campdoc: [
    client_id: "yer token",
    client_secret: "yer secret"
  ]

Usage Notes

Because CampDoc API calls all require an OAUTH token that's periodically refreshed in the runtime system, this library assumes that you have that token when making calls. Accordingly, all public API calls take an opts list that includes a required :token parameter (being the current valid OAUTH call token), and will raise an error if none is passed.

Link to this section Summary

Functions

Create a CampDoc profile.

Create a CampDoc group registration.

Create a CampDoc user, associated with a given Profile (by CampDoc profile ID).

Get Campdoc access token.

Get Campdoc group, by Campdoc group ID.

Get Campdoc profile, by identifier (Portico contact ID) or Campdoc profile ID.

Get registrations for a CampDoc profile by Campdoc profile ID.

Get reviews for a CampDoc profile by Campdoc profile ID.

Test an identifier to determine whether it's a Portico ID or a CampDoc ID.

List all CampDoc Groups

List all CampDoc Profiles

Returns the campdoc OAuth redirect URL.

Refresh the CampDoc access token, using a refresh token obtained with get_access_token/1.

Generate a Single Sign-On (SSO) URL for a CampDoc user

Update a CampDoc profile.

Link to this section Functions

Link to this function

create_profile(params, opts \\ [])

Specs

create_profile(map(), Keyword.t()) :: String.t() | map()

Create a CampDoc profile.

Assumes string keys in the params.

See https://github.com/docnetwork/api/blob/master/v2/chapters/profiles.md#create-a-profile for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

create_registration(profile_id, params, opts \\ [])

Specs

create_registration(integer(), map(), Keyword.t()) :: String.t() | map()

Create a CampDoc group registration.

Assumes string keys in the params.

See https://github.com/docnetwork/api/blob/master/v2/chapters/registrations.md#register-a-profile-to-a-group for more information about request format.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

create_user(profile_id, params, opts \\ [])

Specs

create_user(integer(), map(), Keyword.t()) :: String.t() | map()

Create a CampDoc user, associated with a given Profile (by CampDoc profile ID).

If the user already exists (matching by email), it'll be updated with a link to the given profile.

See https://github.com/docnetwork/api/blob/master/v2/chapters/users.md#create-a-user for more information.

Parameters

A User object in CampDoc has the following shape:

  • email [REQUIRED] The user's email address
  • givenName [REQUIRED] The user's given name
  • familyName [REQUIRED] The user's family name

This function also accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

deactivate_registration(profile_id, registration_id, opts \\ [])

Specs

deactivate_registration(integer(), integer(), Keyword.t()) :: String.t() | map()

Deactivates a CampDoc registration

See https://github.com/docnetwork/api/blob/master/v2/chapters/registrations.md#deactivate-a-registration for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

get_access_token(oauth_code, redirect_uri)

Specs

get_access_token(String.t(), String.t()) :: map()

Get Campdoc access token.

See https://github.com/docnetwork/api/blob/master/v2/chapters/oauth.md for more information.

Link to this function

get_group(group_id, opts)

Specs

get_group(integer(), Keyword.t()) :: String.t() | map()

Get Campdoc group, by Campdoc group ID.

See https://github.com/docnetwork/api/blob/master/v2/chapters/groups.md#-retrieve-a-group for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

get_profile(identifier, opts \\ [])

Specs

get_profile(String.t(), Keyword.t()) :: String.t() | map()

Get Campdoc profile, by identifier (Portico contact ID) or Campdoc profile ID.

Because identifiers come in many formats (string and integer versions of CampDoc IDs as well as string versions of Portico IDs), we attempt to be quite clever about determining which identifier we're using. See https://github.com/docnetwork/api/blob/master/v2/chapters/profiles.md#retrieve-a-profile for more information about identifiers and data shape.

Examples

%{"profile" => %{"id" => 2644094}} = Library.Campdoc.get_profile(2644094, token: "yertoken")
%{"profile" => %{"id" => 2644094}} = Library.Campdoc.get_profile("2644094", token: "yertoken")
%{"profile" => %{"id" => 2644094}} = Library.Campdoc.get_profile("8E7AECA3-4EAF-B74A-B847-CD5B8DFCD3B9", token: "yertoken")

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

get_profile_registrations(profile_id, opts)

Specs

get_profile_registrations(integer(), Keyword.t()) :: String.t() | map()

Get registrations for a CampDoc profile by Campdoc profile ID.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

get_profile_reviews(profile_id, opts)

Specs

get_profile_reviews(integer(), Keyword.t()) :: String.t() | map()

Get reviews for a CampDoc profile by Campdoc profile ID.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

identifier_is_portico_id(identifier)

Test an identifier to determine whether it's a Portico ID or a CampDoc ID.

Examples

iex> true = Library.Campdoc.identifier_is_portico_id("8E7AECA3-4EAF-B74A-B847-CD5B8DFCD3B9")
iex> false = Library.Campdoc.identifier_is_portico_id("2644094")
iex> false = Library.Campdoc.identifier_is_portico_id(2644094)
Link to this function

list_groups(opts)

Specs

list_groups(Keyword.t()) :: String.t() | map()

List all CampDoc Groups

See https://github.com/docnetwork/api/blob/master/v2/chapters/groups.md#retrieve-all-groups-in-an-organization for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

list_profiles(opts)

Specs

list_profiles(Keyword.t()) :: String.t() | map()

List all CampDoc Profiles

See https://github.com/docnetwork/api/blob/master/v2/chapters/profiles.md#retrieve-all-profiles-in-an-organization for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

oauth_url(extra_params \\ %{})

Specs

oauth_url(map()) :: String.t()

Returns the campdoc OAuth redirect URL.

You can pass extra_params (a map) to be forwarded to the CampDoc Authorization Request API. See https://github.com/docnetwork/api/blob/master/v2/chapters/oauth.md for more information.

Link to this function

refresh_access_token(refresh_token, redirect_uri)

Specs

refresh_access_token(String.t(), String.t()) :: map()

Refresh the CampDoc access token, using a refresh token obtained with get_access_token/1.

See https://github.com/docnetwork/api/blob/master/v2/chapters/oauth.md for more information.

Link to this function

sso(email, opts \\ [])

Generate a Single Sign-On (SSO) URL for a CampDoc user

See https://github.com/docnetwork/api/blob/master/v2/chapters/users.md#generate-sign-on-link-sso for API details.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token
Link to this function

update_profile(profile_id, params, opts)

Specs

update_profile(integer(), map(), Keyword.t()) :: String.t() | map()

Update a CampDoc profile.

Assumes string keys in the params.

See https://github.com/docnetwork/api/blob/master/v2/chapters/profiles.md#create-a-profile for more information.

Parameters

Accepts the following opts:

  • token (required) a valid CampDoc bearer token