2017 © Pedro Peláez
 

library yo-client

Another Yo API client

image

mattjmattj/yo-client

Another Yo API client

  • Thursday, April 9, 2015
  • by mattjmattj
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

yo-client

Build Status Scrutinizer Code Quality Code Coverage, (*1)

Rationale

There are several Yo API wrapper available for PHP, but none of them are satisfying to me., (*2)

First I wanted to find an implementation that was compatible with composer and PSR-4 autoloading. If you don't care about that, you might be interested in this very lightweight implementation : https://github.com/nanexcool/yo-php., (*3)

I also wanted to avoid any subsidiary dependency. That's why https://github.com/toin0u/yo didn't do the trick for me, but if you don't care about dependencies then this repo is definitely worth a try., (*4)

One last thing : I was not sure whether or not I was right to hate PSR-2 conventions, so I had to find an excuse to try and follow them. So the code here is PSR-2 compliant... and I really don't like that., (*5)

Install

with composer, (*6)

composer.phar require mattjmattj/yo-client

Usage

One of the main goal was no dependencies / maximum interoperability. This means that, to use yo-client, you will have to implement an adapter to your favorite HTTP client, since none is provided. To do that you need to create a class that implements Yo\HTTP\Client. This interface is pretty straightforward since it only has one method:, (*7)

public function post(\Yo\HTTP\Request $request) : \Yo\HTTP\Response

As long as you know how to send a POST request and return the response you're done. (Actually if you really need an already done adapter, a very light implementation based on curl is provided with yo-client, for testing purpose only)., (*8)

The second thing you need is an API token. You can grab one in your Yo dashboard : https://dev.justyo.co/., (*9)

Now that the hard part is complete, just :, (*10)

// no : you should not use that one, but...
$http = new \Yo\HTTP\Client\LightCurl();
$api_token = '12345-67890-12345-345678';

$yo = new \Yo\Client($http, $api_token);

// you're done. You can Yo me right now :
$yo->yo('MATTJMATTJ');

// or maybe you want to Yo all your subscribers
$yo->yoAll();

// or Yo me a link to an amazing github repo
$yo->yo('MATTJMATTJ', new \Yo\Link('https://github.com/mattjmattj/yo-client'));

// or Yo me your location
$lat = 12.345;
$long = 67.891;

$yo->yo('MATTJMATTJ', new \Yo\Location($lat, $long);

The Yo client will return Yo API response encapsulated into a Yo\HTTP\Response., (*11)

Contributing

You don't really want to do that, do you?, (*12)

Every contribution is welcome, particularly if you have implemented an HTTP client adapter and want to share it., (*13)

The source code if delivered with a makefile that performs some checks, like syntax check or PSR-2 standards compliance. Make sure you run make all before submitting a pull request., (*14)

Next (roadmap)

Currently only sending Yos is available. We will implement the rest of Yo's API in the future., (*15)

License

Yo-client is licensed under BSD-2-Clause., (*16)

The Versions

09/04 2015

dev-master

9999999-dev

Another Yo API client

  Sources   Download

BSD-2-Clause

The Development Requires

by Matthias Jouan

09/04 2015

1.0.1

1.0.1.0

Another Yo API client

  Sources   Download

BSD-2-Clause

The Development Requires

by Matthias Jouan

07/04 2015

1.0

1.0.0.0

Another Yo API client

  Sources   Download

BSD-2-Clause

The Development Requires

by Matthias Jouan