diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f11f0..1cbe02e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All Notable changes to `gigya-client` will be documented in this file -## 1.0 - 2016-11-28 +## 1.0 - 2016-12-02 ### Changed - Upgrade Guzzle from v5 to v6 diff --git a/Makefile b/Makefile index 4785733..6d06cea 100644 --- a/Makefile +++ b/Makefile @@ -4,17 +4,19 @@ DOCKER ?= $(shell which docker) DOCKER_REPOSITORY := graze/php-alpine VOLUME := /srv VOLUME_MAP := -v $$(pwd):${VOLUME} +DOCKER_TAG := test DOCKER_RUN_BASE := ${DOCKER} run --rm -t ${VOLUME_MAP} -w ${VOLUME} -DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:test +DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:${DOCKER_TAG} .PHONY: install composer clean help .PHONY: test lint lint-fix test-unit test-integration test-matrix test-coverage test-coverage-html test-coverage-clover .SILENT: help +.DEFAULT_GOAL=help # Building -install: ## Download the dependencies then build the image :rocket:. +install: ## Download the dependencies then build the image 🚀 make 'composer-install --optimize-autoloader --ignore-platform-reqs' composer-%: ## Run a composer command, `make "composer- [...]"`. @@ -24,9 +26,6 @@ composer-%: ## Run a composer command, `make "composer- [...]"`. -v ~/.ssh:/root/.ssh:ro \ composer/composer:alpine --ansi --no-interaction $* $(filter-out $@,$(MAKECMDGOALS)) -clean: ## Clean up any images. - $(DOCKER) rmi ${DOCKER_REPOSITORY}:latest - # Testing test: ## Run the unit and integration testsuites. @@ -42,8 +41,9 @@ test-unit: ## Run the unit testsuite. $(DOCKER_RUN) vendor/bin/phpunit --colors=always --testsuite unit test-matrix: ## Run the unit tests against multiple targets. - make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-cli" test - make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-cli" test + make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-alpine" test + make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-alpine" test + make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.1-alpine" test make DOCKER_RUN="${DOCKER_RUN_BASE} diegomarangoni/hhvm:cli" test test-integration: ## Run the integration testsuite. diff --git a/README.md b/README.md index 13d0a45..2c6b1e4 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,12 @@ Client for Gigya's REST API * Endpoint call hierarchy: `$gigya->accounts()->tfa()->getCertificate()` * List of endpoints: `accounts`, `accounts->tfa`, `audit`, `socialize`, `comments`, `gameMechanics`, `reports`, `dataStore`, `identityStorage`, `saml`, `saml->idp` +* Populated classes with auto completion helpers for the available methods from Gigya * Different authentication methods: - * `standard`: add api_key and secret to https web requests - * `gigya-oauth2`: gets an oauth2 token and uses that each time - * `custom`: provide you own token retrieved independently + * `gigya`: add `api_key` and `secret` to https web requests + * `credentials`: uses `client_id` and `client_secret` for use with oauth2 token retrieval + * `gigya-oauth2`: uses an automatically retrieved OAuth2 token + * `custom`: use your own custom authentication (or use oauth2 with a provided token) ## Install @@ -28,14 +30,21 @@ $ composer require graze/gigya-client ## Usage +By Default the Gigya client uses `gigya` auth and appends the api_key and secret onto the query string when calling gigya over https. + ```php $gigya = new Gigya($key, $secret); + $response = $gigya->accounts()->getAccountInfo(['uid' => $uid]); -$account = $response->getData(); +if ($response->getErrorCode() === ErrorCode::OK) { + $account = $response->getData(); +} ``` ### OAuth 2 +You can also use `oauth2` in server mode and retrieve information about all accounts + ```php $gigya = new Gigya($key, $secret, $region, $user, ['auth'=>'gigya-oauth2']); $response = $gigya->accounts()->getAccountInfo(['uid' => $uid]); @@ -44,10 +53,12 @@ $account = $response->getData(); #### Social OAuth 2 +OAuth2 can also be used to retrieve information about a single account without knowledge of the `uid`. + ```php $grant = new ManualGrant(); $gigya = new Gigya($key, $secret, $region, null, ['auth' => 'oauth2-custom']); -$gigya->addHandler(OAuth2Subscriber::middleware($grant)); +$gigya->addHandler(OAuth2Subscriber::middleware($grant, 'oauth2-custom')); $tokenResponse = $gigya->socialize()->getToken([ 'grant_type' => 'code', diff --git a/tests/performance/GigyaTest.php b/tests/performance/GigyaTest.php index 0258b7f..508bdef 100644 --- a/tests/performance/GigyaTest.php +++ b/tests/performance/GigyaTest.php @@ -132,6 +132,13 @@ public function testSingleCall() $this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']); $this->printBenchmark(__METHOD__, 1); + + list($duration) = $this->endBenchmark(); + static::assertLessThan( + 1000, + $duration, + 'An individual request should take less than 2s of prep and response validation' + ); } public function testSingleChildCall() @@ -145,6 +152,13 @@ public function testSingleChildCall() } $this->printBenchmark(__METHOD__, $num); + + list($duration) = $this->endBenchmark(); + static::assertLessThan( + 1000, + $duration, + 'An individual request should take less than 2s of prep and response validation' + ); } public function testDoubleChildCall() @@ -185,14 +199,4 @@ public function testUidValidationResponse() 'An individual request should take less than 2ms of prep and response validation' ); } - - public function testSingleCallAgain() - { - $this->createBasicHandler(); - $this->startBenchmark(); - - $this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']); - - $this->printBenchmark(__METHOD__, 1); - } }