SYNOPSIS

        use API::Name;
    
        my $name = API::Name->new(
            apiuser    => 'USER',
            apitoken   => 'TOKEN',
            identifier => 'APPLICATION (yourname@example.com)',
        );
    
        my $domain = $name->domain(get => 'example.com');
        my $results = $domain->fetch;

DESCRIPTION

    This distribution provides an object-oriented thin-client library for
    interacting with the Name (https://www.name.com) API. For usage and
    documentation information visit
    https://www.name.com/reseller/API-documentation.

THIN CLIENT

    A thin-client library is advantageous as it has complete coverage and
    can easily adapt to changes in the API with minimal effort. As a
    thin-client library, this module does not map specific HTTP requests to
    specific routines nor does it provide parameter validation, pagination,
    or other conventions found in typical API client implementations,
    instead, it simply provides a simple and consistent mechanism for
    dynamically generating HTTP requests. Additionally, this module has
    support for debugging and retrying API calls as well as throwing
    exceptions when 4xx and 5xx server response codes are received.

 Building

        my $example = $name->domain(get => 'example.com');
        my $result  = $example->fetch;
    
        $example->action; # GET /domain/get/example.com
        $example->action('head'); # HEAD /domain/get/example.com

    Building up an HTTP request object is extremely easy, simply call
    method names which correspond to the API's path segments in the
    resource you wish to execute a request against. This module uses
    autoloading and returns a new instance with each method call. The
    following is the equivalent:

        my $domain = $name->resource(domain => 'get');
        my $example = $domain->resource('example.com');
    
        # or
    
        my $example = $name->resource('domains', 'get', 'example.com');
    
        # then
    
        $example->action('post', %args); # POST /domains/get/example.com

    Because each call returns a new API instance configured with a resource
    locator based on the supplied parameters, reuse and request isolation
    are made simple, i.e., you will only need to configure the client once
    in your application.

 Fetching

        my $login = $name->login('get');
    
        $login->fetch(
            query => {
                # query-string parameters
            },
        );
    
        # equivalent to
    
        $name->resource('login')->action(
            get => ( query => { ... } )
        );

    This example illustrates how you might fetch an API resource.

 Creating

        my $login = $name->login;
    
        $login->create(
            data => {
                # content-body parameters
            },
            query => {
                # query-string parameters
            },
        );
    
        # or
    
        my $login = $name->login->create(...);
    
        # equivalent to
    
        $name->resource('login')->action(
            post => ( query => { ... }, data => { ... } )
        );

    This example illustrates how you might create a new API resource.

 Updating

        my $login = $name->login;
        my $login  = $login->resource('get');
    
        $login->update(
            data => {
                # content-body parameters
            },
            query => {
                # query-string parameters
            },
        );
    
        # or
    
        my $login = $name->login('get');
    
        $login->update(...);
    
        # equivalent to
    
        $name->resource('login')->action(
            put => ( query => { ... }, data => { ... } )
        );

    This example illustrates how you might update an new API resource.

 Deleting

        my $login = $name->login;
        my $login  = $login->resource('get');
    
        $login->delete(
            data => {
                # content-body parameters
            },
            query => {
                # query-string parameters
            },
        );
    
        # or
    
        my $login = $name->login('get');
    
        $login->delete(...);
    
        # equivalent to
    
        $name->resource('login')->action(
            delete => ( query => { ... }, data => { ... } )
        );

    This example illustrates how you might delete an API resource.

 Transacting

        my $login = $name->resource('login', 'get');
    
        my ($results, $transaction) = $login->fetch(...);

    This example illustrates how you can access the transaction object used
    to submit the HTTP request.

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

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

        $name->apiuser;
        $name->apiuser('APIUSER');

    The apiuser parameter should be set to the API apiuser assgined to the
    account holder.

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

    The debug attribute if true prints HTTP requests and responses to
    standard out.

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

    The fatal attribute if true promotes 4xx and 5xx server response codes
    to exceptions, a API::Name::Exception object.

        $name->retries;
        $name->retries(10);

    The retries attribute determines how many times an HTTP request should
    be retried if a 4xx or 5xx response is received. This attribute
    defaults to 1.

        $name->timeout;
        $name->timeout(5);

    The timeout attribute determines how long an HTTP connection should be
    kept alive. This attribute defaults to 10.

        $name->url;
        $name->url(Mojo::URL->new('https://www.name.com'));

    The url attribute set the base/pre-configured URL object that will be
    used in all HTTP requests. This attribute expects a Mojo::URL object.

        $name->user_agent;
        $name->user_agent(Mojo::UserAgent->new);

    The user_agent attribute set the pre-configured UserAgent object that
    will be used in all HTTP requests. This attribute expects a
    Mojo::UserAgent object.

        my $result = $name->action($verb, %args);
    
        # e.g.
    
        $name->action('head', %args);   # HEAD request
        $name->action('optons', %args); # OPTIONS request
        $name->action('patch', %args);  # PATCH request

    The action method issues a request to the API resource represented by
    the object. The first parameter will be used as the HTTP request
    method. The arguments, expected to be a list of key/value pairs, will
    be included in the request if the key is either data or query.

        my $results = $name->create(%args);
    
        # or
    
        $name->POST(%args);

    The create method issues a POST request to the API resource represented
    by the object. The arguments, expected to be a list of key/value pairs,
    will be included in the request if the key is either data or query.

        my $results = $name->delete(%args);
    
        # or
    
        $name->DELETE(%args);

    The delete method issues a DELETE request to the API resource
    represented by the object. The arguments, expected to be a list of
    key/value pairs, will be included in the request if the key is either
    data or query.

        my $results = $name->fetch(%args);
    
        # or
    
        $name->GET(%args);

    The fetch method issues a GET request to the API resource represented
    by the object. The arguments, expected to be a list of key/value pairs,
    will be included in the request if the key is either data or query.

        my $results = $name->update(%args);
    
        # or
    
        $name->PUT(%args);

    The update method issues a PUT request to the API resource represented
    by the object. The arguments, expected to be a list of key/value pairs,
    will be included in the request if the key is either data or query.

        $name->account;

    The account method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->dns;

    The dns method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->domain;

    The domain method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->host;

    The host method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->login;

    The login method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->logout;

    The logout method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

        $name->order;

    The order method returns a new instance representative of the API
    resource requested. This method accepts a list of path segments which
    will be used in the HTTP request. The following documentation can be
    used to find more information.
    https://www.name.com/reseller/API-documentation.

POD ERRORS

    Hey! The above document had some coding errors, which are explained
    below:

    Around line 170:

      Unknown directive: =param

    Around line 178:

      Unknown directive: =param

    Around line 185:

      Unknown directive: =attr

    Around line 192:

      Unknown directive: =attr

    Around line 200:

      Unknown directive: =attr

    Around line 208:

      Unknown directive: =attr

    Around line 216:

      Unknown directive: =attr

    Around line 224:

      Unknown directive: =attr

    Around line 232:

      Unknown directive: =method

    Around line 248:

      Unknown directive: =method

    Around line 260:

      Unknown directive: =method

    Around line 272:

      Unknown directive: =method

    Around line 284:

      Unknown directive: =method

    Around line 296:

      Unknown directive: =resource

    Around line 305:

      Unknown directive: =resource

    Around line 314:

      Unknown directive: =resource

    Around line 323:

      Unknown directive: =resource

    Around line 332:

      Unknown directive: =resource

    Around line 341:

      Unknown directive: =resource

    Around line 350:

      Unknown directive: =resource

