Library.Google (Portico/Z v0.1.0)
Google API context.
If you need to modify auth scopes for Google, update apps/z/lib/z/application.ex
in Z, and also go here to update the scopes for the Google service client.
Link to this section Summary
Functions
Google Geocode API - address lookup.
Show group membership for a particular email/account ID
List groups in Google Directory
List all users in Google Directory
Google directory service user lookup
Link to this section Functions
geocode_lookup(address)
Google Geocode API - address lookup.
Creates a structured address (a Library.Google.Geocode
) from a single
address string.
Examples
iex> [%Library.Google.Geocode{} = address] = Library.Google.geocode_lookup("932 Washington St., Norwood MA 02062")
iex> address.formatted_address
"932 Washington St, Norwood, MA 02062, USA"
group_membership(email)
Show group membership for a particular email/account ID
list_groups(query \\ %{})
List groups in Google Directory
Returns a list of Library.Google.Group
structs.
Some helpful query
options you can pass:
query: "memberKey: email@explo.org"
search for groups in which a particular staff/account is enrolled
See https://developers.google.com/admin-sdk/directory/v1/guides/search-groups for details.
list_users(query \\ %{})
List all users in Google Directory
Returns a list of Library.Google.User
structs.
user_lookup(email)
Specs
user_lookup(String.t()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
Google directory service user lookup
The email
can actually be primary email, alias email, or even Google ID if you know it. See the Google API guide for more details there.
Returns {:ok, Library.Google.User}
on success, and {:error, %Ecto.Changeset{}}
on failure.
Examples
iex> {:ok, %{name: %{"fullName" => "Pat Training"}}} = Library.Google.user_lookup("ptraining@explo.org")