2017 © Pedro Peláez
 

package whiteworks-api

WhiteWorks API client for PHP 5.5+, based on Guzzle 6

image

schakel/whiteworks-api

WhiteWorks API client for PHP 5.5+, based on Guzzle 6

  • Tuesday, October 10, 2017
  • by SirQuack
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WhiteWorks API client for PHP

Build status ![Coverage Status][cov] License, (*1)

A WhiteWorks API client for PHP5.5+, based on Guzzle 6, (*2)

Features

  • Read-only access for most API endpoints
  • Models for each kind of response, which are Iterable, Json Serializable and have array access.
  • Extensive Unit Tests with code coverage
  • GPLv3 License

License

The software is licensed under a GPLv3 license. We chose this license to invite others to help improve this repository, instead of improving it and keeping the code closed-source., (*3)

In case this does not meet your business needs, please contact us., (*4)

Requirements

This library has the following requirements:, (*5)

  • cURL
  • PHP 5.6, 7.0+ or HHVM
  • PSR-4 compliant autoloader (when not using Composer)

Installation

The easiest way to start using this library, is by installing it via Composer., (*6)

composer require schakel/whiteworks-api

If you don't have access to composer, you can download or clone the repository. Make sure you map the \Schakel\WhiteWorks namespace to the src/ directory of this project in your PSR-4 compliant autoloader., (*7)

Usage

Constructing a client

The main client can be found as Schakel\WhiteWorks\Client. As this is an extension of the Guzzle-based [JSON-RPC client][json-client], calling the constructor requires a few presets, which can be easily loade using the Client::factory method., (*8)

The Factory method requires an api_key and a hostname. These are expected as the first and only argument of Client::factory., (*9)

<?php

$client = Schakel\WhiteWorks\Client::factory([
    'api_key' => 'YOUR-API-KEY',
    'hostname' => 'YOUR-BUSINESS-NAME.whiteworks.nl'
]);

Optionally, you can add 'debug' => true to get more debug messages. This is, ofcourse, not recommended for production systems., (*10)

Getting an API

The Schakel\WhiteWorks\Client has a getApi method, that will return the correct Api for the entity you'd like to retrieve. A list of APIs can be found in the doc/ folder., (*11)

Examples

Retrieving all contacts

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Schakel\WhiteWorks\Client;

$client = Client::factory([
    'api_key': 'ci2ahp7eebeir3Oochai9oo4aWe7ac' // Your API key
    'hostname': 'mycompany.whiteworks.nl' // Hostname, /without/ scheme
]);

$allClients = $client->getApi('contact')->getAll();

foreach ($allClients as $client) {
    echo "{$client->getName()}\n";
}

Contributing

Everyone is welcome to help us realise this program, there are however a few requirements:, (*12)

  • You must pick up an issue or open one concerning your change, so we don't get redundant work.
  • Your work must match our programming standards.
  • Your work must not bring unneeded dependancies (no left-pad phenomena)
  • You need to write proper unit tests.

All pull requests are tested by Travis CI and Coveralls to make sure they work as intended. We aim for a coverage rate > 70%., (*13)

Please add your name and e-mail or handle above all classes you write, so we can contact you should anything go awol afterwards. Adding yourself to AUTHORS is also highly recommended., (*14)

The Versions

10/10 2017

dev-master

9999999-dev

WhiteWorks API client for PHP 5.5+, based on Guzzle 6

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Roelof Roos