/**
  * Returns an slice of the results.
  *
  * @param integer $offset The offset.
  * @param integer $length The length.
  *
  * @return array|stdClass|\Traversable The slice.
  *
  * @throws InvalidDataException
  */
 public function getSlice($offset, $length)
 {
     $paginationRequest = new PaginationDecorator($this->request);
     $paginationRequest->addPagination($offset, $length);
     $response = $this->doCall($paginationRequest);
     return $response->getResources();
 }
 function its_method_get_slice_should_return_items($client, $request, $sdk, $resolveAssociations)
 {
     $paginationRequest = new PaginationDecorator($request->getWrappedObject());
     $paginationRequest->addPagination(1, 1);
     $response = new Response('{"_meta": {"max_results": 2, "total": 45, "page": 3}, "_links": {"self": {"title": "packages", "href": "packages?start_date=2015-01-01&max_results=2&page=3"}, "parent": {"title": "home", "href": "/"}, "next": {"title": "next page", "href": "packages?max_results=2&page=4"}, "prev": {"title": "previous page", "href": "packages?max_results=2&page=2"}, "last": {"title": "last page", "href": "packages?max_results=2&page=23"}}, "_items": [{"body_html": "<p>SAUDI-LED COALITION SPOKESMAN SAYS COALITION JETS WERE IN ACTION\\nIN SAADA GOVERNORATE, BUT NOT INSIDE CITY</p>", "pubstatus": "usable", "subject": [{"qcode": "16009000", "name": "war"}, {"qcode": "11002000", "name": "diplomacy"}, {"qcode": "10000000", "name": "lifestyle and leisure"}, {"qcode": "11000000", "name": "politics"}, {"qcode": "16000000", "name": "unrest, conflicts and  war"}], "uri": "http://api.master.dev.superdesk.org/packages/urn%3Anewsml%3Alocalhost%3A2015-10-27T17%3A53%3A17.408024%3Aa53e9fb0-d43e-41a4-a767-0dddaa549842", "headline": "SAUDI-LED COALITION SPOKESMAN SAYS CO", "priority": 1, "associations": {"main": [{"uri": "http://api.master.dev.superdesk.org/items/tag%3Alocalhost%3A2015%3A120dfa7c-62eb-40c4-8972-7e0d41e3c220", "type": "text"}]}, "_type": "items", "version": 2, "_links": {"self": {"title": "Package", "href": "packages/urn:newsml:localhost:2015-10-27T17:53:17.408024:a53e9fb0-d43e-41a4-a767-0dddaa549842"}}, "urgency": 1, "language": "en", "versioncreated": "2015-10-27T17:53:17+0000", "byline": "mkk", "located": "Santa Fe", "type": "composite"}, {"body_html": "<p>NAREG DARWIN</p>", "pubstatus": "usable", "subject": [{"qcode": "01001000", "parent": "01000000", "name": "archaeology"}], "uri": "http://api.master.dev.superdesk.org/packages/urn%3Anewsml%3Alocalhost%3A2015-10-27T21%3A26%3A35.366266%3Acbdb917d-5e5e-4796-b384-c784baa766d2", "headline": "NAREG DARWIN", "priority": 1, "associations": {"main": [{"uri": "http://api.master.dev.superdesk.org/items/urn%3Anewsml%3Alocalhost%3A2015-10-27T21%3A26%3A07.748901%3A49745a57-04d8-4645-8e63-b3a06f2ca36b", "type": "text"}]}, "_type": "items", "version": 2, "_links": {"self": {"title": "Package", "href": "packages/urn:newsml:localhost:2015-10-27T21:26:35.366266:cbdb917d-5e5e-4796-b384-c784baa766d2"}}, "urgency": 1, "language": "en", "versioncreated": "2015-10-27T21:26:35+0000", "byline": "N", "located": "Holdfast Bay", "type": "composite"}]}');
     $client->makeApiCall($paginationRequest)->willReturn($response);
     $this->getSlice(1, 1)->shouldContainPackages();
 }
 function its_method_get_slice_should_return_items($client, $request)
 {
     $paginationRequest = new PaginationDecorator($request->getWrappedObject());
     $paginationRequest->addPagination(1, 1);
     $response = new Response('{"_links": {"self": {"title": "items", "href": "items?start_date=2015-01-01&max_results=2&page=1"}, "parent": {"title": "home", "href": "/"}}, "_meta": {"total": 2, "max_results": 2, "page": 1}, "_items": [{"headline": "Andromeda on a collision course", "body_text": "Andromeda and Milky Way will collide in about 2 billion years", "_links": {"self": {"title": "Item", "href": "items/tag:example.com,0001:newsml_BRE9A607"}}, "versioncreated": "2015-03-09T16:32:23+0000", "pubstatus": "usable", "version": "2", "uri": "http://api.master.dev.superdesk.org/items/tag%3Aexample.com%2C0001%3Anewsml_BRE9A607", "_type": "items", "language": "en", "type": "text"}, {"headline": "Die Lore-Ley", "body_text": "Ich wei\\u00df nicht was soll es bedeuten", "_links": {"self": {"title": "Item", "href": "items/tag:example.com,0001:newsml_BRE9A608"}}, "versioncreated": "2015-04-19T13:45:54+0000", "pubstatus": "usable", "version": "3", "uri": "http://api.master.dev.superdesk.org/items/tag%3Aexample.com%2C0001%3Anewsml_BRE9A608", "_type": "items", "language": "de", "type": "text"}]}');
     $client->makeApiCall($paginationRequest)->shouldBeCalled()->willReturn($response);
     $this->getSlice(1, 1)->shouldContainItems();
 }