Handkit.Profile (Handkit v0.2.0) View Source
Module for interfacing with the Handcash Connect profile
API endpoint.
The profile endpoint provides default access to the user's public profile. The user's private profile can also be accessed, given that those permissions are granted.
The profile endpoint can also be used to access the users encryption keys and to sign data, dependent on those permissions being granted to the connected app.
Link to this section Summary
Functions
Returns the full profile of the currently authenticated user.
Returns the encryption keypair for the currently authenticated user.
Return a list of friends, each including their own public profile.
Returns a list of permissions for the currently authenticated user.
Looks up and returns a list of public profiles from the given list of Handcash handles.
Signs the given data value with the currently authenticated user's identity key.
Link to this section Functions
Specs
get_current_profile(Handkit.Connect.t()) :: {:ok, map()} | {:error, any()}
Returns the full profile of the currently authenticated user.
Example
iex> Handkit.Profile.get_current_profile(client)
{:ok, %{
"private_profile" => %{
"email" => "StevenUrban1234@gmail.com",
"phone_number" => "+11234567891"
},
"public_profile" => %{
"avatar_url" => "https://handcash.io/avatar/7d399a0c-22cf-40cf-b162-f5511a4645db",
"bitcoin_unit" => "DUR",
"display_name" => "Steven Urban K.",
"handle" => "stuk_91",
"id" => "5f15c31c3c177d003028eb97",
"local_currency_code" => "USD",
"paymail" => "BrandonC@handcash.io"
}
}}
Specs
get_encryption_keypair(Handkit.Connect.t()) :: {:ok, map()} | {:error, any()}
Returns the encryption keypair for the currently authenticated user.
Examples
iex> Handkit.Profile.get_encryption_keypair(client)
{:ok, %{
"private_key" => "KwEdGZs5R6WNtNGknuG9DYd7NNdPw3CPNV9DZhjxNydYmLdA3hAs",
"public_key" => "0370794c83b3228f808fe589a4f9e5286254e245d59fe2d5b6edd9e4fc128c2b5f"
}}
Specs
get_friends(Handkit.Connect.t()) :: {:ok, [map()]} | {:error, any()}
Return a list of friends, each including their own public profile.
Example
iex> Handkit.Profile.get_friends(client)
{:ok, [
%{
"avatar_url" => "https://res.cloudinary.com/hk7jbd3jh/image/upload/v1584356800/hprcfwdasenpnrqei3uz.jpg",
"bitcoin_unit" => "DUR",
"display_name" => "Rafa JS",
"handle" => "rjseibane",
"id" => "5f64dfbd7549610022d2861b",
"local_currency_code" => "USD",
"paymail" => "rjseibane@internal.handcash.io"
}
]}
Specs
get_permissions(Handkit.Connect.t()) :: {:ok, [String.t()]} | {:error, any()}
Returns a list of permissions for the currently authenticated user.
Example
iex> Handkit.Profile.get_permissions(client)
{:ok, [
"USER_PUBLIC_PROFILE",
"USER_PRIVATE_PROFILE",
"DECRYPT",
"FRIENDS",
"PAY",
"SIGN_DATA"
]}
Specs
get_public_profiles_by_handle(Handkit.Connect.t(), [String.t()]) :: {:ok, [map()]} | {:error, any()}
Looks up and returns a list of public profiles from the given list of Handcash handles.
Examples
iex> Handkit.Profile.get_permissions(client, ["cryptokang", "eyeone"])
{:ok, [
%{
"avatar_url" => "https://handcash.io/avatar/7d399a0c-22cf-40cf-b162-f5511a4645db",
"bitcoin_unit" => "DUR",
"display_name" => "Brandon",
"handle" => "cryptokang",
"id" => "5f15c31c3c177d003028eb97",
"local_currency_code" => "USD",
"paymail" => "cryptokang@handcash.io"
},
%{
"avatar_url" => "https://handcash.io/avatar/7d399a0c-22cf-40cf-b162-f5511a4645db",
"bitcoin_unit" => "DUR",
"display_name" => "Ivan",
"handle" => "eyeone",
"id" => "5f14c41c3c188d003027eb77",
"local_currency_code" => "EUR",
"paymail" => "eyeone@handcash.io"
}
]}
Specs
sign_data(Handkit.Connect.t(), binary(), keyword()) :: {:ok, map()} | {:error, any()}
Signs the given data value with the currently authenticated user's identity key.
Options
format
- The data value format, must be one of"base64"
,"hex"
or"utf-8"
(default).
Example
iex> Handkit.Profile.sign_data(client, "Handkit")
{:ok, %{
"public_key" => "02f29085c38697e1014283cc80ee22fec356be2c7803bbad8c46f8d62000cb374e",
"signature" => "Hyy5LdDZxRy8M2Kfzz0/l9g9eywoO/Eo+B3epfP6V+12Fum+l4J5tPofq0Uo0j3B4it8nxGqYYAQBo/bvgGA5qk="
}}
iex> Handkit.Profile.sign_data(client, "SGFuZGtpdA==", format: "base64")
{:ok, %{
"public_key" => "02f29085c38697e1014283cc80ee22fec356be2c7803bbad8c46f8d62000cb374e",
"signature" => "Hyy5LdDZxRy8M2Kfzz0/l9g9eywoO/Eo+B3epfP6V+12Fum+l4J5tPofq0Uo0j3B4it8nxGqYYAQBo/bvgGA5qk="
}}