Skip to content

Commit

Permalink
Merge pull request #14 from graze/v0.2
Browse files Browse the repository at this point in the history
V0.2
  • Loading branch information
Harry Bragg committed Oct 26, 2015
2 parents 5fc5258 + b37fb91 commit 453b346
Show file tree
Hide file tree
Showing 57 changed files with 2,789 additions and 1,536 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
composer.lock
/tests/report/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All Notable changes to `gigya-client` will be documented in this file

## 0.2 - 2015-10-20

### Changed
- Moved Subscribers and Validators to the Gigya object, call these directly
- Constructor of Gigya takes a configuration array with properties
- modification to the order of arguments
- Authentication is done using a Guzzle subscriber and you can supply your own
- You can supply your own response factory for custom response handling

## 0.1 - 2015-10-03

### Added
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test test-coverage test-unit test-unit-coverage test-functional test-functional-coverage install
.PHONY: test lint lint-auto-fix test-coverage test-unit test-unit-coverage test-functional test-functional-coverage test-performance install

test:
@./vendor/bin/phpunit
@./vendor/bin/phpunit --exclude-group performance

lint:
@./vendor/bin/phpcs -p --standard=PSR2 --warning-severity=0 src/ tests/
Expand All @@ -10,13 +10,22 @@ lint-auto-fix:
@./vendor/bin/phpcbf -p --standard=PSR2 src/ tests/

test-coverage:
@./vendor/bin/phpunit --coverage-text --coverage-html ./tests/report
@./vendor/bin/phpunit --coverage-text --coverage-html ./tests/report --exclude-group performance

test-unit:
@./vendor/bin/phpunit --testsuite unit

test-unit-coverage:
@./vendor/bin/phpunit --testsuite unit --coverage-text --coverage-html ./tests/report

test-functional:
@./vendor/bin/phpunit --testsuite functional

test-functional-coverage:
@./vendor/bin/phpunit --testsuite functional --coverage-text --coverage-html ./tests/report

test-performance:
@./vendor/bin/phpunit --testsuite performance

install:
@composer install
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# gigya-client

<img align="right" src="http://stuffpoint.com/family-guy/image/15298-family-guy-giggedy.gif" width="250" />

[![Latest Version on Packagist](https://img.shields.io/packagist/v/graze/gigya-client.svg?style=flat-square)](https://packagist.org/packages/graze/gigya-client)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/graze/gigya-client/master.svg?style=flat-square)](https://travis-ci.org/graze/gigya-client)
[![Total Downloads](https://img.shields.io/packagist/dt/graze/gigya-client.svg?style=flat-square)](https://packagist.org/packages/graze/gigya-client)
[![StyleCI](https://styleci.io/repos/43295589/shield)](https://styleci.io/repos/43295589)

Basic Client for Gigya's REST API
Client for Gigya's REST API

## Install

Via Composer
The simplest way to install the client is with composer and running:

``` bash
$ composer require graze/gigya-client
Expand All @@ -18,8 +21,8 @@ $ composer require graze/gigya-client
## Usage

``` php
$client = new \Graze\Gigya\Gigya($key, $secret, Gigya::DC_EU);
$response = $client->accounts()->getAccountInfo(['uid' => $uid]);
$gigya = new Gigya($key, $secret);
$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
$account = $response->getData();
```

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"psr-4": {
"Graze\\Gigya\\Test\\": "tests/src",
"Graze\\Gigya\\Test\\Unit\\": "tests/unit",
"Graze\\Gigya\\Test\\Functional\\": "tests/functional"
"Graze\\Gigya\\Test\\Functional\\": "tests/functional",
"Graze\\Gigya\\Test\\Performance\\": "tests/performance"
}
}
}
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<testsuite name="unit">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="functional">
<directory>tests/functional</directory>
</testsuite>
<testsuite name="performance">
<directory>tests/performance</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
Expand Down
23 changes: 23 additions & 0 deletions src/Auth/GigyaAuthInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Graze\Gigya\Auth;

use GuzzleHttp\Event\SubscriberInterface;

interface GigyaAuthInterface extends SubscriberInterface
{
/**
* @return string
*/
public function getApiKey();

/**
* @return string
*/
public function getSecret();

/**
* @return string
*/
public function getUserKey();
}
88 changes: 88 additions & 0 deletions src/Auth/GigyaHttpsAuth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Graze\Gigya\Auth;

use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Event\RequestEvents;

class GigyaHttpsAuth implements GigyaAuthInterface
{
/**
* @var string
*/
private $apiKey;

/**
* @var string
*/
private $secret;

/**
* @var null|string
*/
private $userKey;

/**
* @param string $apiKey
* @param string $secret
* @param string|null $userKey
*/
public function __construct($apiKey, $secret, $userKey = null)
{
$this->apiKey = $apiKey;
$this->secret = $secret;
$this->userKey = $userKey;
}

/**
* Returns an array of event names this subscriber wants to listen to.
*
* @return array
*/
public function getEvents()
{
return ['before' => ['sign', RequestEvents::SIGN_REQUEST]];
}

/**
* Add the authentication params to the request.
*
* @param BeforeEvent $event
*/
public function sign(BeforeEvent $event)
{
$request = $event->getRequest();
if ($request->getScheme() == 'https' && $request->getConfig()->get('auth') == 'gigya') {
$query = $request->getQuery();
$query['apiKey'] = $this->apiKey;
$query['secret'] = $this->secret;
if ($this->userKey) {
$query['userKey'] = $this->userKey;
}
}
}

/**
* @return string
*/
public function getApiKey()
{
return $this->apiKey;
}

/**
* @return string
*/
public function getSecret()
{
return $this->secret;
}

/**
* @return string
*/
public function getUserKey()
{
return $this->userKey;
}
}
8 changes: 3 additions & 5 deletions src/Endpoints/Accounts.php → src/Endpoint/Accounts.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php

namespace Graze\Gigya\Endpoints;
namespace Graze\Gigya\Endpoint;

use Graze\Gigya\Gigya;
use Graze\Gigya\Response\ResponseInterface;

/**
* Class Accounts
* Class Accounts.
*
* @package Graze\Gigya\Endpoints
*
* @link http://developers.gigya.com/display/GD/Accounts+REST
*
Expand Down Expand Up @@ -86,6 +84,6 @@ class Accounts extends Client
*/
public function tfa()
{
return new AccountsTfa(Gigya::NAMESPACE_ACCOUNTS, $this->params, $this->dataCenter, $this->options);
return $this->endpointFactory(AccountsTfa::class);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

namespace Graze\Gigya\Endpoints;
namespace Graze\Gigya\Endpoint;

use Graze\Gigya\Gigya;
use Graze\Gigya\Response\ResponseInterface;

/**
* Class Accounts
* Class Accounts.
*
* @package Graze\Gigya\Endpoints
*
* @link http://developers.gigya.com/display/GD/Accounts+REST
*
Expand Down
5 changes: 2 additions & 3 deletions src/Endpoints/Audit.php → src/Endpoint/Audit.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

namespace Graze\Gigya\Endpoints;
namespace Graze\Gigya\Endpoint;

use Graze\Gigya\Response\ResponseInterface;

/**
* Class Audit
* Class Audit.
*
* @package Graze\Gigya\Endpoints
*
* @link http://developers.gigya.com/display/GD/Audit+REST
*
Expand Down
Loading

0 comments on commit 453b346

Please sign in to comment.