The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

$class - A client for the ORCID $name API

CREATING A NEW INSTANCE

The new method returns a new $name API client.

Arguments to new:

client_id

Your ORCID client id (required).

client_secret

Your ORCID client secret (required).

sandbox

The client will talk to the ORCID sandbox API if set to 1.

transport

Specify the HTTP client to use. Possible values are LWP or HTTP::Tiny. Default is LWP.

METHODS

client_id

Returns the ORCID client id used by the client.

client_secret

Returns the ORCID client secret used by the client.

sandbox

Returns 1 if the client is using the sandbox API, 0 otherwise.

transport

Returns what HTTP transport the client is using.

api_url

Returns the base API url used by the client.

oauth_url

Returns the base OAuth url used by the client.

access_token

Request a new access token.

    my \$token = \$client->access_token(
        grant_type => 'client_credentials',
        scope => '/read-public',
    );

authorize_url

Returns an authorization url for 3-legged OAuth requests.

    # in your web application
    redirect(\$client->authorize_url(
        show_login => 'true',
        scope => '/person/update',
        response_type => 'code',
        redirect_uri => 'http://your.callback/url',
    ));

See the /authorize and /authorized routes in the included playground application for an example.

read_public_token

Return an access token with scope /read-public. EOF

$pod .= <<EOF if $class->can('read_limited_token');

read_limited_token

Return an access token with scope /read-limited. EOF

$pod .= <<EOF if $class->can('client');

client

Get details about the current client. EOF

$pod .= <<EOF if $class->can('search');

    my \$hits = \$client->search(q => "johnson");
EOF

$pod .= <<EOF;

EOF

for my $op (sort keys %$ops) { my $spec = $ops->{$op}; my $sym = $op; $sym =~ s|[-/]|_|g;

    if ($spec->{get} || $spec->{get_pc} || $spec->{get_pc_bulk}) {
        $pod .= "=head2 C<${sym}>\n\n";

        if ($spec->{get} && ($spec->{get_pc} || $spec->{get_pc_bulk})) {
            $pod .= "    my \$recs = \$client->${sym}(token => \$token);\n";
        }
        elsif ($spec->{get}) {
            $pod .= "    my \$rec = \$client->${sym}(token => \$token);\n";
        }
        if ($spec->{get_pc}) {
            $pod .= "    my \$rec = \$client->${sym}(token => \$token, put_code => '123');\n";
        }
        if ($spec->{get_pc_bulk}) {
            $pod .= "    my \$recs = \$client->${sym}(token => \$token, put_code => ['123', '456']);\n";
        }
        $pod .= "\nEquivalent to:\n\n    \$client->get('${op}', \%opts)\n\n";
    }

    if ($spec->{add}) {
        $pod .= "=head2 C<add_${sym}>\n\n";
        $pod .= "    \$client->add_${sym}(\$data, token => \$token);\n";
        $pod .= "\nEquivalent to:\n\n    \$client->add('${op}', \$data, \%opts)\n\n";
    }

    if ($spec->{update}) {
        $pod .= "=head2 C<update_${sym}>\n\n";
        $pod .= "    \$client->update_${sym}(\$data, token => \$token, put_code => '123');\n";
        $pod .= "\nEquivalent to:\n\n    \$client->update('${op}', \$data, \%opts)\n\n";
    }

    if ($spec->{delete}) {
        $pod .= "=head2 C<delete_${sym}>\n\n";
        $pod .= "    my \$ok = \$client->delete_${sym}(token => \$token, put_code => '123');\n";
        $pod .= "\nEquivalent to:\n\n    \$client->delete('${op}', \%opts)\n\n";
    }
}

$pod .= <<EOF; =head2 last_error

Returns the last error returned by the ORCID API, if any.

log

Returns the Log::Any logger.