Actions Status MetaCPAN Release

NAME

UID2::Client - Unified ID 2.0 Perl Client

SYNOPSIS

use UID2::Client;

my $client = UID2::Client->new({
    endpoint => 'https://prod.uidapi.com',
    auth_key => 'your_auth_key',
    secret_key => 'your_secret_key',
});
my $result = $client->refresh;
die $result->{reason} unless $result->{is_success};
my $decrypted = $client->decrypt($uid2_token);
if ($decrypted->{is_success}) {
    say $result->{uid};
}

DESCRIPTION

This module provides an interface to Unified ID 2.0 API.

CONSTRUCTOR METHODS

new

my $client = UID2::Client->new(\%options);

Creates and returns a new UID2 client with a hashref of options.

Valid options are:

new_euid

my $client = UID2::Client->new_euid(\%options);

Calls new() with EUID identity_scope.

METHODS

refresh

my $result = $client->refresh();

Fetch the latest keys and returns a hashref containing the response. The hashref will have the following keys:

refresh_json

$client->refresh_json($json);

Updates keys with the JSON string and returns a hashref containing the response. The hashref will have same keys of refresh().

get_latest_keys

my $json = $client->get_latest_keys();

Gets latest keys from UID2 API and returns the JSON string.

Dies on errors, e.g. HTTP errors.

decrypt

my $result = $client->decrypt($uid2_token);
# or
my $result = $client->decrypt($uid2_token, $timestamp);

Decrypts an advertising token and returns a hashref containing the response. The hashref will have the following keys:

encrypt_data

my $result = $client->encrypt_data($data, \%request);

Encrypts arbitrary data with a hashref of requests.

Valid options are:

One of advertising_token or site_id must be passed.

Returns a hashref containing the response. The hashref will have the following keys:

decrypt_data

my $result = $client->decrypt_data($encrypted_data);

Decrypts data encrypted with encrypt_data(). Returns a hashref containing the response. The hashref will have the following keys:

SEE ALSO

https://github.com/UnifiedID2/uid2docs

LICENSE

Copyright (C) Jiro Nishiguchi.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Jiro Nishiguchi jiro@cpan.org