/** * @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); }
/** * Constructs a source description state using the specified client, request, response, access token and state factory. * * @param \GuzzleHttp\Client $client * @param \GuzzleHttp\Psr7\Request $request * @param \GuzzleHttp\Psr7\Response $response * @param string $accessToken * @param \Gedcomx\Rs\Client\StateFactory $stateFactory */ function __construct(Client $client, Request $request, Response $response, $accessToken, StateFactory $stateFactory) { parent::__construct($client, $request, $response, $accessToken, $stateFactory); }
/** * 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); }
/** * Sets the state to use for specifying the last modified date and ETag. The last modified date and ETag values * used in the preconditions will come from the specified state instance. * * @param GedcomxApplicationState $state */ public function setState(GedcomxApplicationState $state) { $this->etag = $state->getETag(); $this->lastModified = $state->getLastModified(); }
/** * 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; }
/** * @param \Gedcomx\Rs\Client\GedcomxApplicationState $state * * @return \Gedcomx\Rs\Client\GedcomxApplicationState */ protected function authorize(GedcomxApplicationState $state) { return $state->authenticateViaOAuth2Password(SandboxCredentials::USERNAME, SandboxCredentials::PASSWORD, SandboxCredentials::API_KEY); }