-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from elifesciences/import-api-client
import ApiClient classes from api-client
- Loading branch information
Showing
132 changed files
with
2,345 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
suites: | ||
api-client: | ||
namespace: eLife\ApiSdk | ||
psr4_prefix: eLife\ApiSdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class AnnotationsClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_lists_annotations() | ||
{ | ||
$request = new Request('GET', 'annotations?by=user&page=1&per-page=20&order=desc&use-date=updated&access=restricted', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.annotation-list+json; version=1', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.annotation-list+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->listAnnotations(['Accept' => 'application/vnd.elife.annotation-list+json; version=1'], 'user', 1, 20, true, 'updated', 'restricted') | ||
->shouldBeLike($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class AnnualReportsClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_gets_an_annual_report() | ||
{ | ||
$request = new Request('GET', 'annual-reports/2012', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.annual-report+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.annual-report+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getReport(['Accept' => 'application/vnd.elife.annual-report+json; version=2'], 2012) | ||
->shouldBeLike($response); | ||
} | ||
|
||
public function it_lists_annual_reports() | ||
{ | ||
$request = new Request('GET', 'annual-reports?page=1&per-page=20&order=desc', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.annual-report-list+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.annual-report-list+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->listReports(['Accept' => 'application/vnd.elife.annual-report-list+json; version=2'], 1, 20, true) | ||
->shouldBeLike($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class ArticlesClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_gets_a_latest_version_for_an_article() | ||
{ | ||
$request = new Request('GET', 'articles/3', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.article-poa+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.article-poa+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getArticleLatestVersion(['Accept' => 'application/vnd.elife.article-poa+json; version=2'], '3') | ||
->shouldBeLike($response) | ||
; | ||
} | ||
|
||
public function it_gets_a_history_for_an_article() | ||
{ | ||
$request = new Request('GET', 'articles/3/versions', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.article-history+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.article-history+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getArticleHistory(['Accept' => 'application/vnd.elife.article-history+json; version=2'], '3') | ||
->shouldBeLike($response) | ||
; | ||
} | ||
|
||
public function it_gets_related_articles_for_an_article() | ||
{ | ||
$request = new Request('GET', 'articles/3/related', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.article-related+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.article-related+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getRelatedArticles(['Accept' => 'application/vnd.elife.article-related+json; version=2'], '3') | ||
->shouldBeLike($response); | ||
} | ||
|
||
public function it_gets_a_version_for_an_article() | ||
{ | ||
$request = new Request('GET', 'articles/3/versions/2', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.article-poa+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.article-poa+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getArticleVersion(['Accept' => 'application/vnd.elife.article-poa+json; version=2'], '3', 2) | ||
->shouldBeLike($response) | ||
; | ||
} | ||
|
||
public function it_lists_articles() | ||
{ | ||
$request = new Request('GET', 'articles?page=1&per-page=20&order=desc&subject[]=cell-biology', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.articles-list+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.articles-list+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->listArticles(['Accept' => 'application/vnd.elife.articles-list+json; version=2'], | ||
1, 20, true, ['cell-biology']) | ||
->shouldBeLike($response) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class BioprotocolClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_queries() | ||
{ | ||
$request = new Request('GET', 'bioprotocol/article/12345', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.bioprotocol+json; version=1', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.bioprotocol+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->list(['Accept' => 'application/vnd.elife.bioprotocol+json; version=1'], 'article', '12345') | ||
->shouldBeLike($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class BlogClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_gets_an_article() | ||
{ | ||
$request = new Request('GET', 'blog-articles/3', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.blog-article+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.blog-article+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getArticle(['Accept' => 'application/vnd.elife.blog-article+json; version=2'], '3') | ||
->shouldBeLike($response) | ||
; | ||
} | ||
|
||
public function it_lists_articles() | ||
{ | ||
$request = new Request('GET', 'blog-articles?page=1&per-page=20&order=desc&subject[]=cell-biology', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.blog-article-list+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.blog-article-list+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->listArticles(['Accept' => 'application/vnd.elife.blog-article-list+json; version=2'], | ||
1, 20, true, | ||
['cell-biology'])->shouldBeLike($response) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace spec\eLife\ApiSdk\ApiClient; | ||
|
||
use eLife\ApiClient\HttpClient; | ||
use eLife\ApiClient\MediaType; | ||
use eLife\ApiClient\Result\ArrayResult; | ||
use eLife\ApiClient\Version; | ||
use GuzzleHttp\Promise\FulfilledPromise; | ||
use GuzzleHttp\Psr7\Request; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class CollectionsClientSpec extends ObjectBehavior | ||
{ | ||
private $httpClient; | ||
|
||
public function let(HttpClient $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
|
||
$this->beConstructedWith($httpClient, ['X-Foo' => 'bar']); | ||
} | ||
|
||
public function it_gets_a_collection() | ||
{ | ||
$request = new Request('GET', 'collections/3', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.collection+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.collection+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->getCollection(['Accept' => 'application/vnd.elife.collection+json; version=2'], '3') | ||
->shouldBeLike($response) | ||
; | ||
} | ||
|
||
public function it_lists_collections() | ||
{ | ||
$request = new Request('GET', 'collections?page=1&per-page=20&order=desc&subject[]=cell-biology&containing[]=article/1234&containing[]=interview/5678', | ||
['X-Foo' => 'bar', 'Accept' => 'application/vnd.elife.collection-list+json; version=2', 'User-Agent' => 'eLifeApiClient/'.Version::get()]); | ||
$response = new FulfilledPromise(new ArrayResult(new MediaType('application/vnd.elife.collection-list+json', | ||
2), ['foo' => ['bar', 'baz']])); | ||
|
||
$this->httpClient->send($request)->willReturn($response); | ||
|
||
$this->listCollections(['Accept' => 'application/vnd.elife.collection-list+json; version=2'], | ||
1, 20, true, | ||
['cell-biology'], ['article/1234', 'interview/5678'])->shouldBeLike($response) | ||
; | ||
} | ||
} |
Oops, something went wrong.