diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f0251f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +composer.phar +vendor/ +.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7a216a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 gw2treasures.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e493b3a --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# gw2treasures/gw2api + +PHP wrapper for the Guild Wars 2 API + +## Requirements + + - PHP > 5.4 + +## Setup + +``` +$ composer require gw2treasures/gw2api +``` + +## License + +[MIT](LICENSE) © 2015 gw2treasures.com diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a4cd16a --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ + "name": "gw2treasures/gw2api", + "type": "library", + "description": "PHP wrapper for the Guild Wars 2 API.", + "keywords": ["guildwars2","guild wars 2","api","wrapper"], + "homepage": "https://github.com/GW2Treasures/gw2api", + "license": "MIT", + "authors": [ + { + "name": "darthmaim", + "email": "darth.maim@arcor.de" + } + ], + "support": { + "issues": "https://github.com/GW2Treasures/gw2api/issues", + "source": "https://github.com/GW2Treasures/gw2api" + }, + "require": { + "php": ">=5.4.0", + "chuyskywalker/rolling-curl": "~3.1" + }, + "require-dev": { + "phpunit/phpunit": "~4.5" + }, + "autoload": { + "psr-4": { + "GW2Treasures\\GW2Api\\": "src" + } + }, + "autoload-dev": { + "classmap": [ "tests/" ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..9fde641 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1094 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "d5b71f8bcfd1b3afdbb75cb09669c46a", + "packages": [ + { + "name": "chuyskywalker/rolling-curl", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/chuyskywalker/rolling-curl.git", + "reference": "fc1d28c221962f25e9615bd3991dd82732420c8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chuyskywalker/rolling-curl/zipball/fc1d28c221962f25e9615bd3991dd82732420c8c", + "reference": "fc1d28c221962f25e9615bd3991dd82732420c8c", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "lib-curl": "*", + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "RollingCurl": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Jeff Minard", + "homepage": "http://jrm.cc/", + "role": "Developer" + }, + { + "name": "Josh Fraser", + "email": "joshfraz@gmail.com", + "homepage": "http://joshfraser.com/", + "role": "Developer" + }, + { + "name": "Alexander Makarov", + "email": "sam@rmcreative.ru", + "homepage": "http://rmcreative.ru/", + "role": "Developer" + } + ], + "description": "Rolling-Curl: A non-blocking, non-dos multi-curl library for PHP", + "homepage": "https://github.com/chuyskywalker/rolling-curl", + "keywords": [ + "asynchronous", + "curl", + "http", + "multi", + "parallel", + "requests" + ], + "time": "2014-08-30 03:39:25" + }, + { + "name": "lusitanian/oauth", + "version": "v0.3.5", + "source": { + "type": "git", + "url": "https://github.com/Lusitanian/PHPoAuthLib.git", + "reference": "ac5a1cd5a4519143728dce2213936eea302edf8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/ac5a1cd5a4519143728dce2213936eea302edf8a", + "reference": "ac5a1cd5a4519143728dce2213936eea302edf8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "predis/predis": "0.8.*@dev", + "symfony/http-foundation": "~2.1" + }, + "suggest": { + "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", + "predis/predis": "Allows using the Redis storage backend.", + "symfony/http-foundation": "Allows using the Symfony Session storage backend." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + }, + "autoload": { + "psr-0": { + "OAuth": "src", + "OAuth\\Unit": "tests" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Desberg", + "email": "david@daviddesberg.com" + }, + { + "name": "Pieter Hordijk", + "email": "info@pieterhordijk.com" + } + ], + "description": "PHP 5.3+ oAuth 1/2 Library", + "keywords": [ + "Authentication", + "authorization", + "oauth", + "security" + ], + "time": "2014-09-05 15:19:58" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/9ca52329bcdd1500de24427542577ebf3fc2f1c9", + "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "phpdocumentor/reflection-docblock": "~2.0" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "http://phpspec.org", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2014-11-17 16:23:49" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.15", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-01-24 10:06:35" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-01-17 09:51:32" + }, + { + "name": "phpunit/phpunit", + "version": "4.5.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "5b578d3865a9128b9c209b011fda6539ec06e7a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5b578d3865a9128b9c209b011fda6539ec06e7a5", + "reference": "5b578d3865a9128b9c209b011fda6539ec06e7a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3.1", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.5.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-02-05 15:51:19" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "c63d2367247365f688544f0d500af90a11a44c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.1", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2014-10-03 05:12:11" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2014-08-15 10:29:00" + }, + { + "name": "sebastian/environment", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7", + "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-10-25 08:00:45" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a77d9123f8e809db3fbdea15038c27a95da4058b", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-12-15 14:25:24" + }, + { + "name": "symfony/yaml", + "version": "v2.6.4", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/60ed7751671113cf1ee7d7778e691642c2e9acd8", + "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2015-01-25 04:39:26" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.4.0" + }, + "platform-dev": [] +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..d8abb38 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + ./src + + + + + ./tests/ + + + diff --git a/src/Endpoint/AuthenticatedEndpoint.php b/src/Endpoint/AuthenticatedEndpoint.php new file mode 100644 index 0000000..4f1842f --- /dev/null +++ b/src/Endpoint/AuthenticatedEndpoint.php @@ -0,0 +1,28 @@ +_token = $token; + } + + /** + * {@inheritdoc} + */ + protected function request( array $query = [] ) { + return $this->requestManager->request( $this->url(), $query, ['Authorization' => 'Bearer ' . $this->_token ]); + } + + /** + * {@inheritdoc} + */ + protected function requestMany( array $queries ) { + return $this->requestManager->request( $this->url(), $queries, ['Authorization' => 'Bearer ' . $this->_token ]); + } +} diff --git a/src/Endpoint/BulkEndpoint.php b/src/Endpoint/BulkEndpoint.php new file mode 100644 index 0000000..a3ac53f --- /dev/null +++ b/src/Endpoint/BulkEndpoint.php @@ -0,0 +1,110 @@ +maxPageSize ) ? $this->maxPageSize : 200; + } + + + /** + * Support of ?ids=all of this endpoint. + * + * If the base class the $supportsIdsAll property it will be used, otherwise defaults to true. + * + * @return bool + */ + protected function supportsIdsAll() { + return isset( $this->supportsIdsAll ) ? $this->supportsIdsAll : true; + } + + /** + * All ids of this BulkEndpoint. + * + * @return string[]|int[] + */ + public function ids() { + return $this->request()->json(); + } + + /** + * Single entry by id. + * + * @param $id + * @return mixed + */ + public function get( $id ) { + return $this->request([ 'id' => $id ])->json(); + } + + /** + * Multiple entries by ids. + * + * @param string[]|int[] $ids + * @return array + */ + public function many( array $ids = [] ) { + if( count( $ids ) === 0 ) { + return []; + } + + $pages = array_chunk( $ids, $this->maxPageSize() ); + + $queries = []; + foreach( $pages as $page ) { + $queries[] = ['ids' => implode( ',', $page )]; + } + + $result = []; + $responses = $this->requestMany( $queries ); + foreach( $responses as $response ) { + $result = array_merge( $result, $response->json() ); + } + + return $result; + } + + /** + * All entries. + * + * If this endpoints supports ?ids=all it will be used, otherwise it will first get all ids and then request + * the entries with multiple requests. + * + * @return array + */ + public function all() { + if( $this->supportsIdsAll() ) { + return $this->request(['ids' => 'all'])->json(); + } else { + $ids = $this->ids(); + return $this->many( $ids ); + } + } + + /** + * Implemented by GW2Treasures\GW2Api\Endpoint\Endpoint. + * + * @param string[] $query + * @return Response + */ + protected abstract function request( array $query = [] ); + + /** + * Implemented by GW2Treasures\GW2Api\Endpoint\Endpoint. + * + * @param string[][] $queries + * @return \GW2Treasures\GW2Api\Request\Response[] + */ + protected abstract function requestMany( array $queries ); +} diff --git a/src/Endpoint/Endpoint.php b/src/Endpoint/Endpoint.php new file mode 100644 index 0000000..0665d38 --- /dev/null +++ b/src/Endpoint/Endpoint.php @@ -0,0 +1,55 @@ +requestManager = $requestManager; + } + + /** + * Make a request. + * + * @param string[] $query + * @return \GW2Treasures\GW2Api\Request\Response + */ + protected function request( array $query = [] ) { + return $this->requestManager->request( $this->url(), $query ); + } + + /** + * Make multiple requests at once. If the RequestManager supports parallel requests, this will be way faster. + * Otherwise the RequestManager will fallback to multiple simple requests. + * + * @param string[][] $queries + * @return \GW2Treasures\GW2Api\Request\Response[] + */ + protected function requestMany( array $queries ) { + return $this->requestManager->requestMany( $this->url(), $queries ); + } + + /** + * The url of this endpoint. + * + * @return string + */ + protected abstract function url(); + + /** + * String representation of this endpoint. + * + * @return string + */ + function __toString() { + return '[' . get_class( $this ) . '(' . $this->url() . ']'; + } +} diff --git a/src/Endpoint/LocalizedEndpoint.php b/src/Endpoint/LocalizedEndpoint.php new file mode 100644 index 0000000..2b73583 --- /dev/null +++ b/src/Endpoint/LocalizedEndpoint.php @@ -0,0 +1,19 @@ +origin = $origin; + $this->lang = $lang; + } + + /** + * Dark magic, rebinding the origin method to $this context + * + * @todo: find a way that doesn't involve reflection, rebinding, ... to do this. + * + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call( $name, $arguments ) { + if( is_callable([ $this->origin, $name ])) { + $method = new \ReflectionMethod( $this->origin, $name ); + $closure = $method->getClosure( $this->origin )->bindTo( $this, $this->origin ); + return call_user_func_array( $closure, $arguments ); + } else { + trigger_error( 'Call to undefined method '.__CLASS__.'::'.$name.'()', E_USER_ERROR ); + return false; + } + } + + /** + * {@inheritdoc} + */ + protected function request( array $query = [] ) { + return $this->origin->request( [ 'lang' => $this->lang ] + $query ); + } + + /** + * {@inheritdoc} + */ + protected function requestMany( array $queries ) { + $queries = array_map( function( $query ) { + return [ 'lang' => $this->lang ] + $query; + }, $queries ); + return $this->origin->requestMany( $queries ); + } + + + /** + * {@inheritdoc} + */ + protected function url() { + return $this->origin->url(); + } + + /** + * String representation of this localized endpoint. + * + * @return string + */ + function __toString() { + return '[' . get_class( $this ) . + '<' . get_class( $this->origin ) . '(' . $this->url() . ')>' . + '(' . $this->lang . ')]'; + } +} diff --git a/src/Endpoint/V2/AccountEndpoint.php b/src/Endpoint/V2/AccountEndpoint.php new file mode 100644 index 0000000..e6cf115 --- /dev/null +++ b/src/Endpoint/V2/AccountEndpoint.php @@ -0,0 +1,24 @@ +request()->json(); + } +} diff --git a/src/Endpoint/V2/BuildEndpoint.php b/src/Endpoint/V2/BuildEndpoint.php new file mode 100644 index 0000000..9f2f4a1 --- /dev/null +++ b/src/Endpoint/V2/BuildEndpoint.php @@ -0,0 +1,24 @@ +request()->json()->id; + } +} diff --git a/src/Endpoint/V2/ColorEndpoint.php b/src/Endpoint/V2/ColorEndpoint.php new file mode 100644 index 0000000..bc137da --- /dev/null +++ b/src/Endpoint/V2/ColorEndpoint.php @@ -0,0 +1,18 @@ +requestManager ); + } + + /** + * @return CommerceListingEndpoint + */ + public function listings() { + return new CommerceListingEndpoint( $this->requestManager ); + } + + /** + * @return CommercePriceEndpoint + */ + public function prices() { + return new CommercePriceEndpoint( $this->requestManager ); + } +} diff --git a/src/Endpoint/V2/CommerceExchangeEndpoint.php b/src/Endpoint/V2/CommerceExchangeEndpoint.php new file mode 100644 index 0000000..577c5d4 --- /dev/null +++ b/src/Endpoint/V2/CommerceExchangeEndpoint.php @@ -0,0 +1,35 @@ +requestManager->request( $this->url() . '/gems', [ 'quantity' => $quantity ])->json(); + } + + /** + * Current coins to gems exchange rate. + * + * @param int $quantity coins + * @return mixed + */ + public function coins( $quantity ) { + return $this->requestManager->request( $this->url() . '/coins', [ 'quantity' => $quantity ])->json(); + } +} diff --git a/src/Endpoint/V2/CommerceListingEndpoint.php b/src/Endpoint/V2/CommerceListingEndpoint.php new file mode 100644 index 0000000..eca3f5a --- /dev/null +++ b/src/Endpoint/V2/CommerceListingEndpoint.php @@ -0,0 +1,19 @@ +requestManager ); + } +} diff --git a/src/Endpoint/V2/RecipeSearchEndpoint.php b/src/Endpoint/V2/RecipeSearchEndpoint.php new file mode 100644 index 0000000..75c607b --- /dev/null +++ b/src/Endpoint/V2/RecipeSearchEndpoint.php @@ -0,0 +1,32 @@ +request([ 'input' => $id ])->json(); + } + + /** + * @param int|string $id + * @return mixed + */ + public function output( $id ) { + return $this->request([ 'output' => $id ])->json(); + } +} diff --git a/src/Endpoint/V2/SkinEndpoint.php b/src/Endpoint/V2/SkinEndpoint.php new file mode 100644 index 0000000..26ac732 --- /dev/null +++ b/src/Endpoint/V2/SkinEndpoint.php @@ -0,0 +1,21 @@ +requestManager = $requestManager ?: new RollingCurlRequestManager( $this->apiUrl ); + } + + public function account( $access_token ) { + return new AccountEndpoint( $this->requestManager, $access_token ); + } + + public function build() { + return new BuildEndpoint( $this->requestManager ); + } + + public function colors() { + return new ColorEndpoint( $this->requestManager ); + } + + public function commerce() { + return new CommerceEndpoint( $this->requestManager ); + } + + public function continents() { + return new ContinentEndpoint( $this->requestManager ); + } + + public function files() { + return new FileEndpoint( $this->requestManager ); + } + + public function items() { + return new ItemEndpoint( $this->requestManager ); + } + + public function maps() { + return new MapEndpoint( $this->requestManager ); + } + + public function quaggans() { + return new QuagganEndpoint( $this->requestManager ); + } + + public function recipes() { + return new RecipeEndpoint( $this->requestManager ); + } + + public function skins() { + return new SkinEndpoint( $this->requestManager ); + } + + public function worlds() { + return new WorldEndpoint( $this->requestManager ); + } +} diff --git a/src/Request/RequestManager.php b/src/Request/RequestManager.php new file mode 100644 index 0000000..bb9ee1a --- /dev/null +++ b/src/Request/RequestManager.php @@ -0,0 +1,41 @@ +baseUrl = $baseUrl; + } + + public function getCertPath() { + return __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem'; + } + + /** + * @param string $url + * @param string[] $query + * @param string[] $header + * @return Response + */ + public abstract function request( $url, array $query = [], array $header = [] ); + + /** + * @param string $url + * @param string[][] $queries + * @param string[] $header + */ + public abstract function requestMany( $url, array $queries, array $header = [] ); + + /** + * @param string $useragent + */ + public function setUseragent( $useragent) { + $this->useragent = $useragent; + } +} diff --git a/src/Request/Response.php b/src/Request/Response.php new file mode 100644 index 0000000..ac0c84a --- /dev/null +++ b/src/Request/Response.php @@ -0,0 +1,50 @@ +headers(); + return array_key_exists( $name, $headers ) + ? $headers[ $name ] + : $default; + } + + /** + * Content of this Response parsed as json. + * + * @return mixed + */ + public function json() { + return json_decode( $this->body() ); + } +} diff --git a/src/Request/RollingCurl/RequestManager.php b/src/Request/RollingCurl/RequestManager.php new file mode 100644 index 0000000..a216380 --- /dev/null +++ b/src/Request/RollingCurl/RequestManager.php @@ -0,0 +1,71 @@ +requestMany( $url, [ $query ], $header )[0]; + } + + /** + * @param string $url + * @param string[][] $queries + * @param array $header + * @return Response[] + * @throws \Exception + */ + public function requestMany( $url, array $queries, array $header = [] ) { + $curl = $this->getCurl(); + + // build curl header array from associative array + $header = array_map( function( $v, $k ) { + return $k . ': ' . $v; + }, $header, array_keys($header) ); + + $responses = []; + + //echo '[GET] --- start ---' . PHP_EOL; + //$start = -microtime(true); + + foreach( $queries as $query ) { + $queryUrl = $url; + if( count( $query ) > 0 ) { + $queryUrl .= '?' . http_build_query( $query ); + } + //echo '[GET] ' . $queryUrl . PHP_EOL; + $curl->get( $this->baseUrl . $queryUrl, null, [ CURLOPT_HTTPHEADER => $header ] ); + } + + $curl->setCallback( function( Request $request ) use ( &$responses ) { + $responses[] = new Response( $request ); + }); + + $curl->execute(); + //echo '[GET] --- end: ' . ( ($start + microtime( true )) * 1000 ) . 'ms ---' . PHP_EOL; + + return $responses; + } + + protected function getCurl() { + $curl = new RollingCurl(); + $curl->addOptions([ + CURLOPT_CAINFO => $this->getCertPath(), + CURLOPT_HEADER => true, + CURLOPT_FAILONERROR => false, +// CURLOPT_USERAGENT => 'GW2Treasures Bot/1.0 (+https://gw2treasures.com/contact)' + ]); + return $curl; + } + +} diff --git a/src/Request/RollingCurl/Response.php b/src/Request/RollingCurl/Response.php new file mode 100644 index 0000000..4b5f700 --- /dev/null +++ b/src/Request/RollingCurl/Response.php @@ -0,0 +1,66 @@ +parseResponse( $request ); + } + + /** + * @param Request $request + */ + protected function parseResponse( Request $request ) { + $info = $request->getResponseInfo(); + $text = $request->getResponseText(); + $header_size = $info['header_size']; + + $headerRaw = trim( substr( $text, 0, $header_size )); + $headers = array(); + foreach( explode( "\n", $headerRaw ) as $i => $line ) { + if( $i === 0 ) { + $headers['http_code'] = trim($line); + } else { + list( $key, $value ) = explode( ': ', $line, 2 ); + $headers[ trim( $key ) ] = trim( $value ); + } + } + + $this->status = $info['http_code']; + $this->headers = $headers; + $this->body = substr( $text, $header_size ); + } + + /** + * {@inheritdoc} + */ + public function headers() { + return $this->headers; + } + + /** + * {@inheritdoc} + */ + public function body() { + return $this->body; + } + + /** + * {@inheritdoc} + */ + public function status() { + return $this->status; + } +} diff --git a/src/Request/cacert.pem b/src/Request/cacert.pem new file mode 100644 index 0000000..d594a17 --- /dev/null +++ b/src/Request/cacert.pem @@ -0,0 +1,23 @@ +Go Daddy Class 2 CA +=================== +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY +VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG +A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g +RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD +ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv +2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32 +qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j +YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY +vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O +BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o +atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu +MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG +A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim +PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt +I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI +Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b +vZ8= +-----END CERTIFICATE----- diff --git a/tests/BasicTest.php b/tests/BasicTest.php new file mode 100644 index 0000000..279a57f --- /dev/null +++ b/tests/BasicTest.php @@ -0,0 +1,56 @@ +api()->quaggans()->all(); + $this->assertCount( 35, $quaggans ); + + $quagganEndpoint = $this->api()->quaggans(); + $q2 = $quagganEndpoint->many( $quagganEndpoint->ids() ); + } + + public function testWorlds() { + $anvilRock = $this->api()->worlds()->get(1001); + $this->assertEquals("Anvil Rock", $anvilRock->name); + + $ambossfels = $this->api()->worlds()->lang('de')->get(1001); + $this->assertEquals("Ambossfels", $ambossfels->name); + } + + public function testSkins() { + $skinIds = $this->api()->skins()->ids(); + $skins = $this->api()->skins()->all(); + + $this->assertCount( count( $skinIds ), $skins ); + } + + public function testItems() { +// $itemIds = $this->api()->items()->ids(); +// $items = $this->api()->items()->all(); +// +// $this->assertCount( count( $itemIds ), $items ); + } + + public function testLocalization() { + $worlds = $this->api()->worlds(); + + $worlds_de = $worlds->lang('de'); + $this->assertEquals( 'Ambossfels', $worlds_de->get(1001)->name, + 'Localized endpoint returns localized response' ); + $this->assertEquals( 'Ambossfels', $worlds_de->get(1001)->name, + 'Repeated usage of localized endpoint keeps language' ); + + $worlds_es = $worlds->lang('es'); + $this->assertEquals( 'Roca del Yunque', $worlds_es->get(1001)->name, + 'Endpoint can be localized in different languages' ); + + $this->assertEquals( 'Ambossfels', $worlds_de->get(1001)->name, + 'Creating a new localized version of origin endpoint doesn\'t alter existing localizations' ); + + $this->assertEquals("Anvil Rock", $worlds->get(1001)->name, + 'Creating localized endpoint doesn\'t alter origin endpoint' ); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..c5b1e2c --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,16 @@ +api = $this->api ?: new GW2Api(); + return $this->api; + } + + protected function setUp() { + ini_set('memory_limit','256M'); + } +}