Skip to content

Commit 915aa4d

Browse files
author
Harry Bragg
authored
prepare for final v1 release (#22)
* updated v1 * some more comments * clarity * update makefile * add duration checks for all performance tests
1 parent ff1c4b5 commit 915aa4d

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
## 1.0 - 2016-11-28
5+
## 1.0 - 2016-12-02
66

77
### Changed
88
- Upgrade Guzzle from v5 to v6

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ DOCKER ?= $(shell which docker)
44
DOCKER_REPOSITORY := graze/php-alpine
55
VOLUME := /srv
66
VOLUME_MAP := -v $$(pwd):${VOLUME}
7+
DOCKER_TAG := test
78
DOCKER_RUN_BASE := ${DOCKER} run --rm -t ${VOLUME_MAP} -w ${VOLUME}
8-
DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:test
9+
DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:${DOCKER_TAG}
910

1011
.PHONY: install composer clean help
1112
.PHONY: test lint lint-fix test-unit test-integration test-matrix test-coverage test-coverage-html test-coverage-clover
1213

1314
.SILENT: help
15+
.DEFAULT_GOAL=help
1416

1517
# Building
1618

17-
install: ## Download the dependencies then build the image :rocket:.
19+
install: ## Download the dependencies then build the image 🚀
1820
make 'composer-install --optimize-autoloader --ignore-platform-reqs'
1921

2022
composer-%: ## Run a composer command, `make "composer-<command> [...]"`.
@@ -24,9 +26,6 @@ composer-%: ## Run a composer command, `make "composer-<command> [...]"`.
2426
-v ~/.ssh:/root/.ssh:ro \
2527
composer/composer:alpine --ansi --no-interaction $* $(filter-out $@,$(MAKECMDGOALS))
2628

27-
clean: ## Clean up any images.
28-
$(DOCKER) rmi ${DOCKER_REPOSITORY}:latest
29-
3029
# Testing
3130

3231
test: ## Run the unit and integration testsuites.
@@ -42,8 +41,9 @@ test-unit: ## Run the unit testsuite.
4241
$(DOCKER_RUN) vendor/bin/phpunit --colors=always --testsuite unit
4342

4443
test-matrix: ## Run the unit tests against multiple targets.
45-
make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-cli" test
46-
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-cli" test
44+
make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-alpine" test
45+
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-alpine" test
46+
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.1-alpine" test
4747
make DOCKER_RUN="${DOCKER_RUN_BASE} diegomarangoni/hhvm:cli" test
4848

4949
test-integration: ## Run the integration testsuite.

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Client for Gigya's REST API
1313

1414
* Endpoint call hierarchy: `$gigya->accounts()->tfa()->getCertificate()`
1515
* List of endpoints: `accounts`, `accounts->tfa`, `audit`, `socialize`, `comments`, `gameMechanics`, `reports`, `dataStore`, `identityStorage`, `saml`, `saml->idp`
16+
* Populated classes with auto completion helpers for the available methods from Gigya
1617
* Different authentication methods:
17-
* `standard`: add api_key and secret to https web requests
18-
* `gigya-oauth2`: gets an oauth2 token and uses that each time
19-
* `custom`: provide you own token retrieved independently
18+
* `gigya`: add `api_key` and `secret` to https web requests
19+
* `credentials`: uses `client_id` and `client_secret` for use with oauth2 token retrieval
20+
* `gigya-oauth2`: uses an automatically retrieved OAuth2 token
21+
* `custom`: use your own custom authentication (or use oauth2 with a provided token)
2022

2123
## Install
2224

@@ -28,14 +30,21 @@ $ composer require graze/gigya-client
2830

2931
## Usage
3032

33+
By Default the Gigya client uses `gigya` auth and appends the api_key and secret onto the query string when calling gigya over https.
34+
3135
```php
3236
$gigya = new Gigya($key, $secret);
37+
3338
$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
34-
$account = $response->getData();
39+
if ($response->getErrorCode() === ErrorCode::OK) {
40+
$account = $response->getData();
41+
}
3542
```
3643

3744
### OAuth 2
3845

46+
You can also use `oauth2` in server mode and retrieve information about all accounts
47+
3948
```php
4049
$gigya = new Gigya($key, $secret, $region, $user, ['auth'=>'gigya-oauth2']);
4150
$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
@@ -44,10 +53,12 @@ $account = $response->getData();
4453

4554
#### Social OAuth 2
4655

56+
OAuth2 can also be used to retrieve information about a single account without knowledge of the `uid`.
57+
4758
```php
4859
$grant = new ManualGrant();
4960
$gigya = new Gigya($key, $secret, $region, null, ['auth' => 'oauth2-custom']);
50-
$gigya->addHandler(OAuth2Subscriber::middleware($grant));
61+
$gigya->addHandler(OAuth2Subscriber::middleware($grant, 'oauth2-custom'));
5162

5263
$tokenResponse = $gigya->socialize()->getToken([
5364
'grant_type' => 'code',

tests/performance/GigyaTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ public function testSingleCall()
132132
$this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']);
133133

134134
$this->printBenchmark(__METHOD__, 1);
135+
136+
list($duration) = $this->endBenchmark();
137+
static::assertLessThan(
138+
1000,
139+
$duration,
140+
'An individual request should take less than 2s of prep and response validation'
141+
);
135142
}
136143

137144
public function testSingleChildCall()
@@ -145,6 +152,13 @@ public function testSingleChildCall()
145152
}
146153

147154
$this->printBenchmark(__METHOD__, $num);
155+
156+
list($duration) = $this->endBenchmark();
157+
static::assertLessThan(
158+
1000,
159+
$duration,
160+
'An individual request should take less than 2s of prep and response validation'
161+
);
148162
}
149163

150164
public function testDoubleChildCall()
@@ -185,14 +199,4 @@ public function testUidValidationResponse()
185199
'An individual request should take less than 2ms of prep and response validation'
186200
);
187201
}
188-
189-
public function testSingleCallAgain()
190-
{
191-
$this->createBasicHandler();
192-
$this->startBenchmark();
193-
194-
$this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']);
195-
196-
$this->printBenchmark(__METHOD__, 1);
197-
}
198202
}

0 commit comments

Comments
 (0)