NAME

Net::Azure::CognitiveServices::Face::Base - Base class of Cognitive Services APIs

DESCRIPTION

This is a base class for writting wrapper classes of Face APIs more easy.

ATTRIBUTES

access_key

The access key for accessing to Azure Cognitive Services APIs

endpoint

Endpoint URL string

METHODS

path

An interface that returns the endpoint path string.

my $path_string = $obj->path;

uri

Build an URI object.

my $uri = $obj->uri('/base/uri', name => 'foobar', page => 3); ## => '/base/uri?name=foobar&page=3'

json

Returns a JSON.pm object.

my $hash = $obj->json->decode('{"name":"foobar","page":3}'); ## => {name => "foobar", page => 3}

agent

Returns a HTTP::Tiny object.

my $res = $obj->agent->get('http://example.com');

request

Send a http request, and returns a json content as a hashref.

my $method = 'POST';
my $uri = "https://example.com/endpoint/to/face-api?parameter=foo&other=bar";
my $options = {
    headers => {
        'Content-Type': 'application/json',
    }, 
    content => '{"key": "value", "key2": "value2"}',
};
my $req  = [$method, $uri, $options];
my $hash = $obj->request($req);

build_headers

Build and returns http headers with authorization header.

my $obj = Net::Azure::CognitiveServices::Face::Base->new(access_key => 'SECRET', ...);
my @headers = $obj->build_headers('Content-Length' => 60);

build_request

Build and returns a HTTP::Request object.

### arguments
my $path      = '/foo/bar';
my %param     = (page => 2, name => 'hoge');
my @headers   = ("X-HTTP-Foobar" => 123);
my $json_data = {url => 'http://example.com'};
### build request object
my $req = $obj->build_request([$path, %param], [@headers], $json_data);

LICENSE

Copyright (C) ytnobody.

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

AUTHOR

ytnobody <ytnobody@gmail.com>