/** * @param Pin $pin * @param string $method * * @throws Exception * @throws InvalidTimelineToken */ private function pinRequest(Pin $pin, $method) { $body = null; if ($method === 'PUT') { $body = $pin->json(); } $uri = trim($this->baseUri, '/') . '/v1/user/pins/' . $pin->id(); $request = new Request($method, $uri, $this->getHeaders(), $body); try { $this->client->send($request); } catch (ClientException $exception) { $this->handleException($exception, $pin); } catch (ServerException $exception) { $this->handleException($exception, $pin); } }
public function test_json_structure() { $id = 'someidentifier-31337'; $dateTime = new \DateTimeImmutable(); $title = 'Some Title'; $pin = Pin::create($id, $dateTime, $title); $json = $pin->json(); $jsonObject = json_decode($json); $this->assertInstanceOf('stdClass', $jsonObject); $this->assertEquals($id, $jsonObject->id); $this->assertEquals($dateTime->format(DATE_ATOM), $jsonObject->time); $this->assertEquals($title, $jsonObject->layout->title); }
private function getTestData() { $id = 'foobar-1234'; $dateTime = new \DateTimeImmutable(); $title = 'SomeTitle'; $pin = Pin::create($id, $dateTime, $title); $token = TimelineToken::fromString(str_repeat('a', 32)); return ['id' => $id, 'dateTime' => $dateTime, 'title' => $title, 'pin' => $pin, 'token' => $token, 'timeline' => new GuzzleTimeline($this->client, $token)]; }
/** * Invalid Pin object * * @param Pin $pin */ public function __construct(Pin $pin) { $this->pin = $pin; parent::__construct("Invalid Pin object: " . $pin->id()); }