2017 © Pedro Peláez
 

library geckoboard-datasets

A Geckoboard dataset rest client

image

stefanvinding/geckoboard-datasets

A Geckoboard dataset rest client

  • Tuesday, May 9, 2017
  • by stefanvinding
  • Repository
  • 3 Watchers
  • 3 Stars
  • 11,811 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 36 % Grown

The README.md

GECKOBOARD DATASET REST CLIENT

1. What is it?

A rest client library for PHP 7.2+ that allows to perform CRUD operations against the new Geckoboard Dataset API., (*1)

2. How it works?

2.1 Create / Update dataset

Using the helper:, (*2)

     $schema =
     [
        ['name' => 'MyAmount'    , 'type' => 'number'  , 'optional' => true                           ],
        ['name' => 'MyText'      , 'type' => 'string'                                                 ],
        ['name' => 'MyDate'      , 'type' => 'datetime', 'optional' => true                           ],
        ['name' => 'Danish Krone', 'type' => 'money'   , 'optional' => false, 'currency_code' => 'DKK']
     ];


     // Create / Update "mydataset" and set "MyDate" as unique field
     \Stefanvinding\Geckoboard\Dataset\Helper::factory(['key' => 'YOUR API KEY HERE'])->createDataset('mydataset', $schema, 'MyDate');

Using low level API:, (*3)

     $schema = (new \Stefanvinding\Geckoboard\Dataset\Row())->addTypes([
        new \Stefanvinding\Geckoboard\Dataset\Type\TypeNumber('MyAmount', true),
        new \Stefanvinding\Geckoboard\Dataset\Type\TypeString('MyText'),
        new \Stefanvinding\Geckoboard\Dataset\Type\TypeDatetime('MyDate', true),
        new \Stefanvinding\Geckoboard\Dataset\Type\TypeMoney('Danish Krone', 'DKK', true)             
     ]);

     (new \Stefanvinding\Geckoboard\Dataset\Request(['key' => 'YOUR API KEY HERE']))->createDataset('mydataset', $schema, 'MyDate');

2.2 Delete dataset

Using the helper:, (*4)

    \Stefanvinding\Geckoboard\Dataset\Helper::factory(['key' => 'YOUR API KEY HERE'])->deleteDataset('mydataset');

Using low level API:, (*5)

    (new \Stefanvinding\Geckoboard\Dataset\Request(['key' => 'YOUR API KEY HERE']))->deleteDataset('mydataset');

2.3 Append data into dataset

Using the helper:, (*6)

    $records = 
    [
        [
            ['name' => 'MyDate'      , 'type' => 'datetime', 'value' => date('Y-m-d\TH:i:s\Z')],
            ['name' => 'MyAmount'    , 'type' => 'number'  , 'value' => rand(1, 10000)        ],
            ['name' => 'MyText'      , 'type' => 'String'  , 'value' => uniqid()              ],
            ['name' => 'Danish Krone', 'type' => 'money'   , 'value' => rand(1, 10000)        ]
        ],
        // Add more records ....            
    ];

    // Unique by "MyDate" field
    \Stefanvinding\Geckoboard\Dataset\Helper::factory(['key' => 'YOUR API KEY HERE'])->appendData('mydataset', $records, ['MyDate']);

Using the low level API:, (*7)

    $records =
    [
        (new \Stefanvinding\Geckoboard\Dataset\Row())->addTypes([
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeDatetime('MyDate'))->setValue(date('Y-m-d\TH:i:s\Z')),
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeNumber('MyAmount'))->setValue(rand(1, 1000))         ,
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeString('MyText'))->setValue(uniqid())                ,               
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeMoney('Danish Krone'))->setValue(rand(1, 10000))
        ]),                                
        // Add more records ....            
    ];

    // Unique by "MyDate" field
    (new \Stefanvinding\Geckoboard\Dataset\Request(['key' => 'YOUR API KEY HERE']))->appendData('mydataset', $records, ['MyDate']);

2.4 Replace data into dataset

Using the helper:, (*8)

    $records = 
    [
        [
            ['name' => 'MyDate'      , 'type' => 'datetime', 'value' => date('Y-m-d\TH:i:s\Z')],
            ['name' => 'MyAmount'    , 'type' => 'number'  , 'value' => rand(1, 10000)        ],
            ['name' => 'MyText'      , 'type' => 'String'  , 'value' => uniqid()              ],
            ['name' => 'Danish Krone', 'type' => 'money'   , 'value' => rand(1, 10000)        ]
        ],
        // Add more records ....            
    ];

    \Stefanvinding\Geckoboard\Dataset\Helper::factory(['key' => 'YOUR API KEY HERE'])->replaceData('mydataset', $records);

Using the low level API:, (*9)

    $records =
    [
        (new \Stefanvinding\Geckoboard\Dataset\Row())->addTypes([
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeDatetime('MyDate'))->setValue(date('Y-m-d\TH:i:s\Z')),
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeNumber('MyAmount'))->setValue(rand(1, 1000))         ,
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeString('MyText'))->setValue(uniqid())                ,               
                    (new \Stefanvinding\Geckoboard\Dataset\Type\TypeMoney('Danish Krone'))->setValue(rand(1, 10000))
        ]),                                
        // Add more records ....            
    ];

    (new \Stefanvinding\Geckoboard\Dataset\Request(['key' => 'YOUR API KEY HERE']))->replaceData('mydataset', $records);

3. Test

1) Add your API key into tests/BaseTest.php 2) Run PHPUnit ("vendor/phpunit/phpunit/phpunit"), (*10)

Supported by

The Versions

09/05 2017

dev-master

9999999-dev

A Geckoboard dataset rest client

  Sources   Download

GPL

The Requires

 

The Development Requires

by Juan Lago
by Stefan Vinding

09/05 2017

1.3

1.3.0.0

A Geckoboard dataset rest client

  Sources   Download

GPL

The Requires

 

The Development Requires

by Juan Lago
by Stefan Vinding

09/05 2017

1.2

1.2.0.0

A Geckoboard dataset rest client

  Sources   Download

GPL

The Requires

 

The Development Requires

by Juan Lago
by Stefan Vinding

09/05 2017

1.1

1.1.0.0

A Geckoboard dataset rest client

  Sources   Download

GPL

The Requires

 

The Development Requires

by Juan Lago
by Stefan Vinding

08/05 2017

1.0

1.0.0.0

A Geckoboard dataset rest client

  Sources   Download

GPL

The Requires

 

The Development Requires

by Juan Lago
by Stefan Vinding