forked from viagogo/gogokit.php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Viagogo API SDK for PHP
- Loading branch information
0 parents
commit 92df715
Showing
40 changed files
with
1,255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Composer | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# GogoKit - viagogo API Client Library for PHP | ||
|
||
[![Build status](https://ci.appveyor.com/api/projects/status/ri2rbvoinudw27en/branch/master?svg=true)][appveyor] | ||
[![NuGet version](https://badge.fury.io/nu/gogokit.svg)][badgefury] | ||
|
||
[appveyor]: https://ci.appveyor.com/project/viagogo/gogokit-net/branch/master | ||
[badgefury]: https://badge.fury.io/nu/gogokit | ||
|
||
GogoKit is a lightweight, async viagogo API client library for PHP. | ||
|
||
## Usage | ||
|
||
```php | ||
// All methods require authentication. To get your viagogo OAuth credentials, | ||
// See TODO: docs url | ||
$clientId = 'CLIENT_ID'; | ||
$clientSecret = 'CLIENT_SECRET'; | ||
|
||
$viagogo = new Viagogo\ViagogoClient($clientId, $clientSecret); | ||
$viagogo->setToken($viagogo->getOAuthClient()->getClientAccessToken()); | ||
|
||
$event = $client->getEventClient()->getEvent(676615); | ||
// Get a list of results that match your search query | ||
$searchResults = $client->getEventClient()->getEvent(676615)("FC Barcelona tickets"); | ||
``` | ||
|
||
## Getting Started | ||
|
||
GogoKit will be available on Composer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "gogokit", | ||
"description": "Viagogo API SDK for PHP", | ||
"keywords": ["viagogo", "sdk"], | ||
"type": "library", | ||
"homepage": "https://github.com/viagogo/gogokit.php", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Viagogo", | ||
"homepage": "https://github.com/viagogo/gogokit.php" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.4.*", | ||
"mockery/mockery": "0.9.*", | ||
"guzzlehttp/guzzle": "~5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Viagogo\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace Viagogo; | ||
|
||
use Viagogo\Clients as Clients; | ||
use Viagogo\Common as Common; | ||
use Viagogo\Hal\HalClient; | ||
/** | ||
* | ||
*/ | ||
class ViagogoClient | ||
{ | ||
private $oauthClient; | ||
private $tokenStore; | ||
private $halClient; | ||
private $categoryClient; | ||
private $eventClient; | ||
private $venueClient; | ||
private $listingClient; | ||
private $searchClient; | ||
private $currencyClient; | ||
private $countryClient; | ||
private $languageClient; | ||
|
||
function __construct($clientId, $clientSecret) | ||
{ | ||
$this->oauthClient = new Common\OAuthClient($clientId, $clientSecret); | ||
$this->tokenStore = new Common\OAuthTokenStore(); | ||
$this->halClient = new HalClient($this->tokenStore); | ||
$this->categoryClient = new Clients\CategoryClient($this->halClient); | ||
$this->eventClient = new Clients\EventClient($this->halClient); | ||
$this->venueClient = new Clients\VenueClient($this->halClient); | ||
$this->listingClient = new Clients\ListingClient($this->halClient); | ||
$this->searchClient = new Clients\SearchClient($this->halClient); | ||
$this->currencyClient = new Clients\CurrencyClient($this->halClient); | ||
$this->countryClient = new Clients\CountryClient($this->halClient); | ||
$this->languageClient = new Clients\LanguageClient($this->halClient); | ||
} | ||
|
||
public function setToken(Common\OAuthToken $token) | ||
{ | ||
$this->tokenStore->setToken($token); | ||
|
||
return $this; | ||
} | ||
|
||
public function getOAuthClient() | ||
{ | ||
return $this->oauthClient; | ||
} | ||
|
||
public function getHalClient() | ||
{ | ||
return $this->halClient; | ||
} | ||
|
||
public function getCategoryClient() | ||
{ | ||
return $this->categoryClient; | ||
} | ||
|
||
public function getEventClient() | ||
{ | ||
return $this->eventClient; | ||
} | ||
|
||
public function getVenueClient() | ||
{ | ||
return $this->venueClient; | ||
} | ||
|
||
public function getListingClient() | ||
{ | ||
return $this->listingClient; | ||
} | ||
|
||
public function getSearchClient() | ||
{ | ||
return $this->searchClient; | ||
} | ||
|
||
public function getCountryClient() | ||
{ | ||
return $this->countryClient; | ||
} | ||
|
||
public function getCurrencyClient() | ||
{ | ||
return $this->currencyClient; | ||
} | ||
|
||
public function getLanguageClient() | ||
{ | ||
return $this->languageClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Category; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class CategoryClient extends Client | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
|
||
/** | ||
* | ||
*/ | ||
abstract class Client | ||
{ | ||
protected $client; | ||
|
||
function __construct(HalClient $halClient) | ||
{ | ||
$this->client = $halClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Country; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class CountryClient extends Client | ||
{ | ||
public function getCountry($countryCode, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/countries/'.$countryCode; | ||
|
||
return $this->client->getResource($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getCountries(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/countries'; | ||
|
||
return new PagedResource($this->client->getResource($link, $params), 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getAllCountries(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/countries'; | ||
|
||
return $this->client->getAllResources($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Currency; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class CurrencyClient extends Client | ||
{ | ||
public function getCurrency($currencyCode, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getCurrenciesLink()->getHref().'/'.$countryCode; | ||
|
||
return $this->client->getResource($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getCurrencies(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getCurrenciesLink()->getHref(); | ||
|
||
return new PagedResource($this->client->getResource($link, $params), 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getAllCurrencies(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getCurrenciesLink()->getHref(); | ||
|
||
return $this->client->getAllResources($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Event; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class EventClient extends Client | ||
{ | ||
public function getEvent($eventId, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/events/'.$eventId; | ||
|
||
return $this->client->getResource($link, $params, 'Viagogo\Resources\Event'); | ||
} | ||
|
||
public function getEventsByCategory($categoryId, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/categories/'.$categoryId.'/events'; | ||
|
||
return new PagedResource($this->client->getResource($link, $params), 'Viagogo\Resources\Event'); | ||
} | ||
|
||
public function getAllEventsByCategory($categoryId, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getSelfLink()->getHref().'/categories/'.$categoryId.'/events'; | ||
|
||
return $this->client->getAllResources($link, $params, 'Viagogo\Resources\Event'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Language; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class LanguageClient extends Client | ||
{ | ||
public function getLanguage($languageCode, ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getLanguagesLink()->getHref().'/'.$languageCode; | ||
|
||
return $this->client->getResource($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getLanguages(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getLanguagesLink()->getHref(); | ||
|
||
return new PagedResource($this->client->getResource($link, $params), 'Viagogo\Resources\Country'); | ||
} | ||
|
||
public function getAllLanguages(ViagogoRequestParams $params = null) | ||
{ | ||
$root = $this->client->getRoot(); | ||
$link = $root->getLanguagesLink()->getHref(); | ||
|
||
return $this->client->getAllResources($link, $params, 'Viagogo\Resources\Country'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\Listing; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class ListingClient extends Client | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Viagogo\Clients; | ||
|
||
use Viagogo\Hal\HalClient; | ||
use Viagogo\Hal\PagedResource; | ||
use Viagogo\Resources\MetroArea; | ||
use Viagogo\Common\ViagogoRequestParams; | ||
|
||
/** | ||
* | ||
*/ | ||
class MetroAreaClient extends Client | ||
{ | ||
} |
Oops, something went wrong.