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).
Deactivates a CampDoc registration
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
create_profile(params, opts \\ [])
Specs
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
create_registration(profile_id, params, opts \\ [])
Specs
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
create_user(profile_id, params, opts \\ [])
Specs
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
deactivate_registration(profile_id, registration_id, opts \\ [])
Specs
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
get_access_token(oauth_code, redirect_uri)
Specs
Get Campdoc access token.
See https://github.com/docnetwork/api/blob/master/v2/chapters/oauth.md for more information.
get_group(group_id, opts)
Specs
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
get_profile(identifier, opts \\ [])
Specs
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
get_profile_registrations(profile_id, opts)
Specs
Get registrations for a CampDoc profile by Campdoc profile ID.
Parameters
Accepts the following opts
:
token
(required) a valid CampDoc bearer token
get_profile_reviews(profile_id, opts)
Specs
Get reviews for a CampDoc profile by Campdoc profile ID.
Parameters
Accepts the following opts
:
token
(required) a valid CampDoc bearer token
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)
list_groups(opts)
Specs
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
list_profiles(opts)
Specs
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
oauth_url(extra_params \\ %{})
Specs
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.
refresh_access_token(refresh_token, redirect_uri)
Specs
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.
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
update_profile(profile_id, params, opts)
Specs
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