Skip to content

Commit 453b346

Browse files
author
Harry Bragg
committed
Merge pull request #14 from graze/v0.2
V0.2
2 parents 5fc5258 + b37fb91 commit 453b346

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2789
-1536
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor/
22
composer.lock
3+
/tests/report/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

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

5+
## 0.2 - 2015-10-20
6+
7+
### Changed
8+
- Moved Subscribers and Validators to the Gigya object, call these directly
9+
- Constructor of Gigya takes a configuration array with properties
10+
- modification to the order of arguments
11+
- Authentication is done using a Guzzle subscriber and you can supply your own
12+
- You can supply your own response factory for custom response handling
13+
514
## 0.1 - 2015-10-03
615

716
### Added

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.PHONY: test test-coverage test-unit test-unit-coverage test-functional test-functional-coverage install
1+
.PHONY: test lint lint-auto-fix test-coverage test-unit test-unit-coverage test-functional test-functional-coverage test-performance install
22

33
test:
4-
@./vendor/bin/phpunit
4+
@./vendor/bin/phpunit --exclude-group performance
55

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

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

1515
test-unit:
1616
@./vendor/bin/phpunit --testsuite unit
1717

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

21+
test-functional:
22+
@./vendor/bin/phpunit --testsuite functional
23+
24+
test-functional-coverage:
25+
@./vendor/bin/phpunit --testsuite functional --coverage-text --coverage-html ./tests/report
26+
27+
test-performance:
28+
@./vendor/bin/phpunit --testsuite performance
29+
2130
install:
2231
@composer install

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# gigya-client
22

3+
<img align="right" src="http://stuffpoint.com/family-guy/image/15298-family-guy-giggedy.gif" width="250" />
4+
35
[![Latest Version on Packagist](https://img.shields.io/packagist/v/graze/gigya-client.svg?style=flat-square)](https://packagist.org/packages/graze/gigya-client)
46
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
57
[![Build Status](https://img.shields.io/travis/graze/gigya-client/master.svg?style=flat-square)](https://travis-ci.org/graze/gigya-client)
68
[![Total Downloads](https://img.shields.io/packagist/dt/graze/gigya-client.svg?style=flat-square)](https://packagist.org/packages/graze/gigya-client)
9+
[![StyleCI](https://styleci.io/repos/43295589/shield)](https://styleci.io/repos/43295589)
710

8-
Basic Client for Gigya's REST API
11+
Client for Gigya's REST API
912

1013
## Install
1114

12-
Via Composer
15+
The simplest way to install the client is with composer and running:
1316

1417
``` bash
1518
$ composer require graze/gigya-client
@@ -18,8 +21,8 @@ $ composer require graze/gigya-client
1821
## Usage
1922

2023
``` php
21-
$client = new \Graze\Gigya\Gigya($key, $secret, Gigya::DC_EU);
22-
$response = $client->accounts()->getAccountInfo(['uid' => $uid]);
24+
$gigya = new Gigya($key, $secret);
25+
$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
2326
$account = $response->getData();
2427
```
2528

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"psr-4": {
4040
"Graze\\Gigya\\Test\\": "tests/src",
4141
"Graze\\Gigya\\Test\\Unit\\": "tests/unit",
42-
"Graze\\Gigya\\Test\\Functional\\": "tests/functional"
42+
"Graze\\Gigya\\Test\\Functional\\": "tests/functional",
43+
"Graze\\Gigya\\Test\\Performance\\": "tests/performance"
4344
}
4445
}
4546
}

phpunit.xml.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
<testsuite name="unit">
1414
<directory>tests/unit</directory>
1515
</testsuite>
16+
<testsuite name="functional">
17+
<directory>tests/functional</directory>
18+
</testsuite>
19+
<testsuite name="performance">
20+
<directory>tests/performance</directory>
21+
</testsuite>
1622
</testsuites>
1723
<filter>
1824
<whitelist>

src/Auth/GigyaAuthInterface.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Graze\Gigya\Auth;
4+
5+
use GuzzleHttp\Event\SubscriberInterface;
6+
7+
interface GigyaAuthInterface extends SubscriberInterface
8+
{
9+
/**
10+
* @return string
11+
*/
12+
public function getApiKey();
13+
14+
/**
15+
* @return string
16+
*/
17+
public function getSecret();
18+
19+
/**
20+
* @return string
21+
*/
22+
public function getUserKey();
23+
}

src/Auth/GigyaHttpsAuth.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace Graze\Gigya\Auth;
4+
5+
use GuzzleHttp\Event\BeforeEvent;
6+
use GuzzleHttp\Event\RequestEvents;
7+
8+
class GigyaHttpsAuth implements GigyaAuthInterface
9+
{
10+
/**
11+
* @var string
12+
*/
13+
private $apiKey;
14+
15+
/**
16+
* @var string
17+
*/
18+
private $secret;
19+
20+
/**
21+
* @var null|string
22+
*/
23+
private $userKey;
24+
25+
/**
26+
* @param string $apiKey
27+
* @param string $secret
28+
* @param string|null $userKey
29+
*/
30+
public function __construct($apiKey, $secret, $userKey = null)
31+
{
32+
$this->apiKey = $apiKey;
33+
$this->secret = $secret;
34+
$this->userKey = $userKey;
35+
}
36+
37+
/**
38+
* Returns an array of event names this subscriber wants to listen to.
39+
*
40+
* @return array
41+
*/
42+
public function getEvents()
43+
{
44+
return ['before' => ['sign', RequestEvents::SIGN_REQUEST]];
45+
}
46+
47+
/**
48+
* Add the authentication params to the request.
49+
*
50+
* @param BeforeEvent $event
51+
*/
52+
public function sign(BeforeEvent $event)
53+
{
54+
$request = $event->getRequest();
55+
if ($request->getScheme() == 'https' && $request->getConfig()->get('auth') == 'gigya') {
56+
$query = $request->getQuery();
57+
$query['apiKey'] = $this->apiKey;
58+
$query['secret'] = $this->secret;
59+
if ($this->userKey) {
60+
$query['userKey'] = $this->userKey;
61+
}
62+
}
63+
}
64+
65+
/**
66+
* @return string
67+
*/
68+
public function getApiKey()
69+
{
70+
return $this->apiKey;
71+
}
72+
73+
/**
74+
* @return string
75+
*/
76+
public function getSecret()
77+
{
78+
return $this->secret;
79+
}
80+
81+
/**
82+
* @return string
83+
*/
84+
public function getUserKey()
85+
{
86+
return $this->userKey;
87+
}
88+
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?php
22

3-
namespace Graze\Gigya\Endpoints;
3+
namespace Graze\Gigya\Endpoint;
44

5-
use Graze\Gigya\Gigya;
65
use Graze\Gigya\Response\ResponseInterface;
76

87
/**
9-
* Class Accounts
8+
* Class Accounts.
109
*
11-
* @package Graze\Gigya\Endpoints
1210
*
1311
* @link http://developers.gigya.com/display/GD/Accounts+REST
1412
*
@@ -86,6 +84,6 @@ class Accounts extends Client
8684
*/
8785
public function tfa()
8886
{
89-
return new AccountsTfa(Gigya::NAMESPACE_ACCOUNTS, $this->params, $this->dataCenter, $this->options);
87+
return $this->endpointFactory(AccountsTfa::class);
9088
}
9189
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
22

3-
namespace Graze\Gigya\Endpoints;
3+
namespace Graze\Gigya\Endpoint;
44

55
use Graze\Gigya\Gigya;
66
use Graze\Gigya\Response\ResponseInterface;
77

88
/**
9-
* Class Accounts
9+
* Class Accounts.
1010
*
11-
* @package Graze\Gigya\Endpoints
1211
*
1312
* @link http://developers.gigya.com/display/GD/Accounts+REST
1413
*

0 commit comments

Comments
 (0)