/** * @vcr UtilitiesTests/testRedirectToUri.json * @link https://familysearch.org/developers/docs/api/tree/Redirect_to_Uri_usecase */ public function testRedirectToUri() { $factory = new FamilyTreeStateFactory(); $this->collectionState($factory); $uri = "https://sandbox.familysearch.org/platform/redirect?uri=https://familysearch.org/some/path?p1%3Dp1-value%26p2%3Dp2-value"; $request = new Request('GET', $uri); $response = GedcomxApplicationState::send($this->collectionState()->getClient(), $request); $this->assertNotNull($response, "Response is empty."); $this->assertNotEquals($uri, $response->effectiveUri, "Effective URLs should not match"); }
/** * Creates a new collection state from the specified parameters. Since a response is provided as a parameter, a REST API request will not be invoked. * * @param null $uri * @param string $method The method. * @param \GuzzleHttp\Client $client The client to use. * * @return FamilyTreeCollectionState The collection state. */ public function newCollectionState($uri = null, $method = "GET", Client $client = null) { if (!$client) { $client = $this->defaultClient(); } if ($uri == null) { $uri = $this->production ? self::PRODUCTION_URI : self::SANDBOX_URI; } /** @var Request $request */ $request = new Request($method, $uri, ["Accept" => FamilySearchPlatform::JSON_MEDIA_TYPE]); return new FamilyTreeCollectionState($client, $request, GedcomxApplicationState::send($client, $request), null, $this); }
/** * Create a new memories state * * @param null $uri * @param string $method * @param Client $client * * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\Memories\FamilySearchMemories */ public function newMemoriesState($uri = null, $method = "GET", Client $client = null) { if (!$client) { $client = $this->defaultClient(); } if ($uri == null) { $uri = $this->production ? self::MEMORIES_URI : self::MEMORIES_SANDBOX_URI; } /** @var Request $request */ $request = new Request($method, $uri, ['Accept' => Gedcomx::JSON_MEDIA_TYPE]); return new FamilySearchMemories($client, $request, GedcomxApplicationState::send($client, $request), null, $this); }
/** * Returns a new person state by invoking the specified URI and method, using the specified client. * * @param string $uri The URI to the person. * @param \GuzzleHttp\Client $client The client to use. * @param string $method The method. * * @return PersonState The person state. */ public function newPersonState($uri, Client $client = null, $method = "GET") { if (!$client) { $client = $this->defaultClient(); } /** @var Request $request */ $request = new Request($method, $uri, ['Accept' => Gedcomx::JSON_MEDIA_TYPE]); return new PersonState($client, $request, GedcomxApplicationState::send($client, $request), null, $this); }
/** * Get a list of valid pending modifications * * @return array Array of \Gedcomx\Extensions\FamilySearch\Feature */ public function getAvailablePendingModifications() { $uri = $this->homeState->getCollection()->getLink('pending-modifications')->getHref(); $headers = ['Accept' => Gedcomx::JSON_APPLICATION_TYPE]; $request = new Request('GET', $uri, $headers); $response = GedcomxApplicationState::send($this->client, $request); // Get each pending feature $json = json_decode($response->getBody(), true); $fsp = new FamilySearchPlatform($json); $features = array(); foreach ($fsp->getFeatures() as $feature) { $features[] = $feature; } return $features; }