API-Name

 view release on metacpan or  search on metacpan

lib/API/Name.pm  view on Meta::CPAN

    my $url        = $self->url;

    $agent->transactor->name($identifier);

    # $url->path("/api/$version");
    $url->path("/api");

    return $self;

};

# METHODS

method PREPARE ($ua, $tx, %args) {

    my $headers = $tx->req->headers;
    my $url     = $tx->req->url;

    my $user  = $self->user;
    my $token = $self->token;

    # default headers
    $headers->header('Content-Type' => 'application/json');
    $headers->header('Api-Username' => $user);
    $headers->header('Api-Token'    => $token);

}

method resource (@segments) {

    # build new resource instance
    my $instance = __PACKAGE__->new(
        debug      => $self->debug,
        fatal      => $self->fatal,
        retries    => $self->retries,
        timeout    => $self->timeout,
        user_agent => $self->user_agent,
        identifier => $self->identifier,
        token      => $self->token,
        user       => $self->user,
        version    => $self->version,
    );

    # resource locator
    my $url = $instance->url;

    # modify resource locator if possible
    $url->path(join '/', $self->url->path, @segments);

    # return resource instance
    return $instance;

}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

API::Name - Name.com API Client

=head1 VERSION

version 0.06

=head1 SYNOPSIS

    use API::Name;

    my $name = API::Name->new(
        user       => 'USER',
        token      => 'TOKEN',
        identifier => 'APPLICATION NAME',
    );

    $name->debug(1);
    $name->fatal(1);

    my $domain = $name->domains(get => 'example.com');
    my $results = $domain->fetch;

    # after some introspection

    $domain->update( ... );

=head1 DESCRIPTION

This distribution provides an object-oriented thin-client library for
interacting with the Name (L<https://www.name.com>) API. For usage and
documentation information visit L<https://www.name.com/reseller/API-documentation>.
API::Name is derived from L<API::Client> and inherits all of it's
functionality. Please read the documentation for API::Client for more usage
information.

=head1 ATTRIBUTES

=head2 token

    $name->token;
    $name->token('TOKEN');

The token attribute should be set to the API token assigned to the account
holder.

=head2 user

    $name->user;
    $name->user('USER');

The user attribute should be set to the API user assgined to the account
holder.

=head2 identifier

    $name->identifier;
    $name->identifier('IDENTIFIER');



( run in 1.572 second using v1.01-cache-2.11-cpan-e1769b4cff6 )