tsmsogn/pixela

Pixela client for PHP

0.0.1 2019-01-31 02:33 UTC

This package is auto-updated.

Last update: 2024-11-05 21:07:34 UTC


README

Pixela client for PHP

Requirements

  • PHP 5.5 or later

Installation

composer require tsmsogn/pixela

Usage

Client

<?php
$client = new \Pixela\Client('tsmsogn-ghost', 'thisissecret');

User

<?php
$user = $client->api('User');

// Create user
$user->create();
        
// Update user
$user->update('thisisnewsecret');

// Delete user
$user->delete();

Graphs

<?php
$graph = $client->api('Graphs');

// Create graph
$graph->setId('test-graph')
    ->setName('graph-name')
    ->setUnit('commit')
    ->setType('int')
   ->setColor('shibafu');
$graph->create();

// Get graphs
$graph->get();

// Get SVG
$graph->getSVG()

// Update graph
$graph->setName('new-test-graph')
    ->setUnit('calory')
    ->setColor('momiji')
    ->setTimezone('UTC')
    ->setPurgeCacheURLs(array(
        'https://camo.githubusercontent.com/xxx/xxxx'
    ));
$graph->update();

// Delete graph
$graph->delete();

// Get URL
$graph->getURL();

Pixel

<?php
$pixel = $client->api('Pixel');

// Create pixel
$pixel->setGraphID('test-graph')
    ->setDatetime(new \DateTime())
    ->setQuantity(1);
$pixel->post();

// Get pixel
$pixel->get();

// Update pixel
$pixel->setQuantity(10)
    ->setOptionalData(json_encode('foo'));
$pixel->update();

// Increment pixel
$pixel->increment();

// Decrement pixel
$pixel->decrement();

// Delete pixel
$pixel->delete();

Webhooks

<?php
$webhook = $client->api('Webhooks');

// Create webhook
$webhook->setGraphID('test-graph')
    ->setType('increment');
$webhook->create();

// Get webhooks
$webhook->get();

// Invoke webhook
$webhook->invoke();

// Delete webhook
$webhook->delete();