Build Status

NAME

WebService::Pixela - It's https://pixe.la API client for Perl.

SYNOPSIS

use strict;
use warnings;

use WebService::Pixela;

# All WebService::Pixela methods use this token and user name in URI, JSON, etc.
my $pixela = WebService::Pixela->new(token => "thisissecret", username => "testname");

$pixela->user->create(); # default agreeTermsOfService and notMinor "yes"
# or...
$pixela->user->create(agree_terms_of_service => "yes", not_minor => "no"); # can input agreeTermsOfService and notMinor

my %graph_params = (
    name     => 'test_graph',
    unit     => 'test',
    type     => 'int',
    color    => 'shibafu',
    timezone => 'Asia/Tokyo',
);

print $pixela->graph->id('graph_id')->create(%graph_params)->{message} . "\n";

#return json text

my $json = $pixela->decode(0)->graph->get();
$pixela->decode(1);
$pixela->webhook->create(type => 'increment');

my $hash = $pixela->webhook->hash() . "\n";
my $pixel = $pixela->pixel->get(date => '20180915');

$pixela->user->delete(); # delete method not require arguments

DESCRIPTION

WebService::Pixela is API client about https://pixe.la

CI_PIXELA

CI activity

ORIGINAL API DOCUMENT

See also https://docs.pixe.la/ .

This module corresponds to version 1.

INTERFACE

Class Methods

WebService::Pixela->new(%args)

It is WebService::Pixela constructor.

%args might be:

What does the WebService::Pixela instance contain?

WebService::Pixela instance have four representative instance methods. Each representative instance methods is an instance of the same class 'WebService::Pixela::' name.

Instance Methods (It does not call other WebService::Pixela::.* instances.)

$pixela->username : Str

Output and set the user name of the instance.

$pixela->token : Str

Output and set the token of the instance.

$pixela->base_url : Str

Output and set the base url of the instance.

$pixela->decode : boolean

Output and set the decode of the instance. If decode is true it returns a Perl object, false it returns json as is.

Instance Methods

It conforms to the official API document. See aloso https://docs.pixe.la/ .

$pixela->user

This instance method uses a WebService::Pixela::User instance.

$pixela->user->create(%opts)

It is Pixe.la user create.

%opts might be:

See also https://docs.pixe.la/#/post-user

$pixela->user->update($newtoken)

Updates the authentication token for the specified user.

$newtoken might be:

See also https://docs.pixe.la/#/update-user

$pixela->user->delete()

Deletes the specified registered user.

See also https://docs.pixe.la/#/delete-user

$pixela->graph

This instance method uses a WebService::Pixela::Graph instance.

$pixela->graph->create(%opts) :$hash_ref

It is Pixe.la graph create.

%opts might be:

See Also https://docs.pixe.la/#/post-graph

$pixela->graph->get()

Get all predefined pixelation graph definitions.

If you setting _$pixela-_decode(1) [default]> return array refs. Otherwise it returns json.

See Also https://docs.pixe.la/#/get-graph

$pixela->graph->get_svg(%args)

%opts might be:

See Also https://docs.pixe.la/#/get-svg

$pixela->graph->update(%args)

%options might be $pixela->graph->create() options.

See Also https://docs.pixe.la/#/put-graph

$pixela->graph->delete()

Delete the predefined pixelation graph definition.

See Also https://docs.pixe.la/#/delete-graph

$pixela->graph->html(%args)

Displays the details of the graph in html format. (This method return html urls)

%args might be

$pixela->graph->pixels(%args)

Get a Date list of Pixel registered in the graph specified by graphID. You can specify a period with from and to parameters.

%args might be

See Also https://docs.pixe.la/#/get-graph-pixels

$pixela->graph->stats($id)

Based on the registered information, get various statistics.

$id might be

See Also https://docs.pixe.la/entry/get-graph-stats

$pixela->pixel

This instance method uses a WebService::Pixela::Pixel instance.

$pixela->pixel->post(%opts)

It records the quantity of the specified date as a "Pixel".

%opts might be:

See also

https://docs.pixe.la/#/post-pixel

$pixela->pixel->get(%opts)

Get registered quantity as "Pixel".

%opts might be:

See also

https://docs.pixe.la/#/get-pixel

$pixela->pixel->update(%opts)

Update the quantity already registered as a "Pixel". If target "Pixel" not exist, create a new "Pixel" and set quantity.

%opts might be:

See also

https://docs.pixe.la/#/put-pixel

$pixela->pixel->increment(%opts)

Increment quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then 1 added, and for float then 0.01 added.

%opts might be:

See also

https://docs.pixe.la/#/increment-pixel

$pixela->pixel->decrement(%opts)

Decrement quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then -1 added, and for float then -0.01 added.

%opts might be:

See also

https://docs.pixe.la/#/decrement-pixel

$pixela->pixel->delete(%opts)

Delete the registered "Pixel".

%opts might be:

See also

https://docs.pixe.la/#/delete-pixel

$pixela->webhook

This instance method uses a WebService::Pixela::Webhook instance.

$pixela->webhook->create(%opts)

Create a new Webhook by Pixe.la This method return webhookHash, this is automatically set instance.

%opts might be:

See also

https://docs.pixe.la/#/post-webhook

$pixela->webhook->hash($webhookhash)

This is webhookHash. Used by Pixela's webhook service.

$webhookhash might be:

$pixela->webhook->get()

Get all predefined webhooks definitions. This method return array_ref or json value(switching decode method).

See also https://docs.pixe.la/#/get-webhook

$pixela->webhook->invoke($webhookhash)

Invoke the webhook registered in advance. It is used “timezone” setting as post date if Graph’s “timezone” is specified, if not specified, calculates it in “UTC”.

$webhookhash might be:

See also https://docs.pixe.la/#/invoke-webhook

$pixela->webhook->delete($webhookhash)

Delete the registered Webhook.

$webhookhash might be:

See also https://docs.pixe.la/#/delete-webhook

LICENSE

Copyright (C) Takahiro SHIMIZU.

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

AUTHOR

Takahiro SHIMIZU anatofuz@gmail.com