navarr / verticalresponse
Vertical Response API Wrapper - converted from official Vertical Response repository
Fund package maintenance!
navarr
Installs: 1 154
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- navarr/verticalresponse-provider-implementation: ^3.0
- psr/http-message: ^1.0
Requires (Dev)
Suggests
This package is auto-updated.
Last update: 2024-11-12 04:20:49 UTC
README
Introduction
Everyone loves an API Wrapper! This one wraps the VerticalResponse API (v1).
VerticalResponse's own wrapper was pretty good - but in a PHP folder, with no composer support, strange class names, and everything else - I figured it was time to update it!
How to Use
Installation
Because I'm crazy, I tried to keep this library from having any opinions on what library to use for sending HTTP requests. That's neat, because it means you can throw in your own HTTP client if you want to.
On that note, however, I also made it default to using Guzzle if you didn't specify one - so that you could keep the constructor as clean as possible.
HOWEVER, I didn't want all of Guzzle packaged with every installation of this - so it's only a suggested dependency.
TL;DR: To use this library, it's recommended you composer require navarr/verticalresponse navarr/verticalresponse-guzzle
.
Usage in Code
You will first have to get an Authorization Token from the VerticalResponse OAuth 2.0 API Endpoint. This is left as an exercise to the reader.
Once you've done that, just pipe it in to the VerticalResponse Client, like so:
$vr = new \VerticalResponse\Client($authorizationToken);
$response = $vr->get('lists');
var_dump($response);
For a new VerticalResponse account, the output would look something like this:
class stdClass#35 (3) {
public $url =>
string(47) "https://vrapi.verticalresponse.com/api/v1/lists"
public $items =>
array(1) {
[0] =>
class stdClass#29 (2) {
public $url =>
string(62) "https://vrapi.verticalresponse.com/api/v1/lists/25288767452069"
public $attributes =>
class stdClass#22 (4) {
...
}
}
}
public $links =>
class stdClass#33 (1) {
public $up =>
class stdClass#36 (1) {
public $url =>
string(41) "https://vrapi.verticalresponse.com/api/v1"
}
}
}
The current version of this library does not provide any sort of ActiveRecord utilities for managing the data from this API. That, too, is left as an exercise to the reader.