ryo iinuma
and 1 contributors

NAME

Spica::Spec::Declare

SYNOPSIS

    package Your::Spec;
    use Spica::Spec::Declare;

    client {
        name 'example';
        endpoint 'search' => '/examples' => [qw(access_token)];
        columns (
            'access_token' => +{from => 'accessToken', no_row_accessor => 1},
            'id'           => +{from => 'exampleId'},
            'name'         => +{from => 'exampleName'},
            'status',
        );
    };

DESCRIPTIOM

FUNCTIONS

client(\&callback)

client defines the specification of the API. client In Spica is a power that defines the structure of each data, not URI.

    client {
        .. client's settings ..
    };

name($client_name)

name defines the name of the client. name fields are required.

    client {
        name 'client_name';
    };

on fetch calling:

    $spica->fetch('client_name', ...);

endpoint

endpoint defines the path and requires param. endpoint it is possible to define more than one against client one.

endpoint($endpoin_name, $path, \@requires)

Make the request using the GET method as the initial value in this definition. If you want to specify the HTTP method, please refer to the matter.

    client {
        name 'client_name';
        endpoint 'endpoint_name' => '/path/to' => [qw(id)];
    };

on fetch:

    $spica->fetch('client_name', 'endpoint_name', \%param);

If you specify a string of default to $endpoint_name, you can omit the $endpoint_name when you use the Spica->fetch.

    client {
        name 'client_name';
        endpoint 'default' => '/path/to' => [qw(id)];
    };

on fetch:

    $spica->fetch('client_name', \%param);
endpoint(\%settings)

endpoint defines the path and request method and requires param.

    client {
        name 'client_name';
        endpoint 'default' => +{
            method   => 'POST',
            path     => '/path/to',
            requires => [qw(id)],
        };
    };

receiver

Specify an Iterator class. Spica::Receiver::Iterator Is used by default.

    client {
        ...
        receiver 'Your::Iterator';
    };

row_class

Specify an Row class. Spica::Receiver::Row::* Is used by default.

    client {
        ...
        row_class 'Your::Row::Example';
    };

hooks

trigger($hook_point_name, \&code);
filter($hook_point_name, \&code);

SEE ALSO

Spica