Git Product home page Git Product logo

whiteworks-api's Introduction

WhiteWorks API client for PHP

Build status Coverage Status

A WhiteWorks API client for PHP5.5+, based on Guzzle 6

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.

In case this does not meet your business needs, please contact us.

Requirements

This library has the following requirements:

  • 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.

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.

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.

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

<?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.

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.

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:

  • 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%.

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.

whiteworks-api's People

Contributors

freddyamsterdam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.