1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
<?php
namespace Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree;
use Gedcomx\Rs\Client\GedcomxApplicationState;
use Gedcomx\Extensions\FamilySearch\FamilySearchPlatform;
use Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchStateFactory;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
/**
* The state factory is responsible for instantiating state classes from REST API responses.
*
* Class FamilyTreeStateFactory
*
* @package Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree
*/
class FamilyTreeStateFactory extends FamilySearchStateFactory
{
/**
* 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::INTEGRATION_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);
}
/**
* Builds a new child and parents relationship state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionsState
*/
protected function buildChildAndParentsRelationshipState(Client $client, Request $request, Response $response, $accessToken)
{
return new ChildAndParentsRelationshipState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new relationships state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionsState
*/
protected function buildRelationshipsState(Client $client, Request $request, Response $response, $accessToken)
{
return new FamilyTreeRelationshipsState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new person state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonState
*/
protected function buildPersonState(Client $client, Request $request, Response $response, $accessToken)
{
return new FamilyTreePersonState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new relationship state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeRelationshipState
*/
protected function buildRelationshipState(Client $client, Request $request, Response $response, $accessToken)
{
return new FamilyTreeRelationshipState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new person parents state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonParentsState
*/
protected function buildPersonParentsState(Client $client, Request $request, Response $response, $accessToken)
{
return new FamilyTreePersonParentsState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new person children state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonChildrenState
*/
protected function buildPersonChildrenState(Client $client, Request $request, Response $response, $accessToken)
{
return new FamilyTreePersonChildrenState($client, $request, $response, $accessToken, $this);
}
/**
* Builds a new change history state from the specified parameters.
*
* @param \GuzzleHttp\Client $client
* @param \GuzzleHttp\Psr7\Request $request
* @param \GuzzleHttp\Psr7\Response $response
* @param string $accessToken The access token for this session
*
* @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChangeHistoryState
*/
protected function buildChangeHistoryState(Client $client, Request $request, Response $response, $accessToken)
{
return new ChangeHistoryState($client, $request, $response, $accessToken, $this);
}
}