/** * Adds a place description to the current collection of place descriptions. * * @param \Gedcomx\Conclusion\PlaceDescription $place * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return PlaceDescriptionState */ public function addPlaceDescription(PlaceDescription $place, StateTransitionOption $option = null) { $entity = new Gedcomx(); $entity->addPlace($place); $request = $this->createAuthenticatedGedcomxRequest('POST', $this->getSelfUri(), [], null, $entity->toJson()); return $this->stateFactory->createState('PlaceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds a persona to the current source description using a GEDCOM X object. * * @param Gedcomx $persona * @param StateTransitionOption $option,... * * @return PersonState */ public function addGedcomxPersona(Gedcomx $persona, StateTransitionOption $option = null) { $target = $this->getSelfUri(); $link = $this->getLink(Rel::PERSONS); if ($link != null && $link->getHref() != null) { $target = $link->getHref(); } $request = $this->createAuthenticatedGedcomxRequest('POST', $target, [], null, $persona->toJson()); return $this->stateFactory->createState('PersonState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Update notes added to a person. * * @param \Gedcomx\Conclusion\Person $person * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Rs\Client\PersonState */ public function updatePersonNotes(Person $person, StateTransitionOption $option = null) { $target = $this->getSelfUri(); $conclusionsLink = $this->getLink(Rel::NOTES); if ($conclusionsLink != null && $conclusionsLink->getHref() != null) { $target = $conclusionsLink->getHref(); } $gx = new Gedcomx(); $gx->setPersons(array($person)); /** @var EntityEnclosingRequest $request */ $request = $this->createAuthenticatedGedcomxRequest('POST', $target, [], null, $gx->toJson()); return $this->stateFactory->createState('PersonState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds a collection to the subcollection resource specified by this state instance. * * @param Collection $collection * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException * @return \Gedcomx\Rs\Client\CollectionState|null */ public function addCollection(Collection $collection, StateTransitionOption $option = null) { $link = $this->getLink(Rel::SUBCOLLECTIONS); if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException(sprintf("Collection at %s doesn't support adding subcollections.", $this->getUri())); } $entity = new Gedcomx(); $entity->setCollections(array($collection)); $request = $this->createAuthenticatedGedcomxRequest('POST', $link->getHref(), null, null, $entity->toJson()); return $this->stateFactory->createState('CollectionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Executes a POST verb request against the current REST API request and returns a state instance with the response. * * @param \Gedcomx\Gedcomx $entity * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return mixed */ public function post(Gedcomx $entity, StateTransitionOption $option = null) { $headers = []; $accept = $this->request->getHeader("Accept"); if (count($accept) > 0) { $headers["Accept"] = $accept[0]; } $contentType = $this->request->getHeader("Content-Type"); if (count($contentType) > 0) { $headers["Content-Type"] = $contentType[0]; } if ($entity instanceof Gedcomx && !isset($headers["Content-Type"])) { $headers["Content-Type"] = Gedcomx::JSON_MEDIA_TYPE; } $request = $this->createAuthenticatedRequest('POST', $this->getSelfUri(), $headers, null, $entity->toJson()); return $this->reconstruct($request, $this->passOptionsTo('invoke', array($request), func_get_args())); }
/** * Updates the specified relationship. * * @param \Gedcomx\Conclusion\Relationship $relationship * @param $rel * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return mixed */ protected function updateRelationship(Relationship $relationship, $rel, StateTransitionOption $option = null) { $target = $this->getSelfUri(); $link = $this->getLink($rel); if ($link != null && $link->getHref() != null) { $target = $link->getHref(); } $gx = new Gedcomx(); $gx->setRelationships(array($relationship)); /** @var $request EntityEnclosingRequest */ $request = $this->createAuthenticatedGedcomxRequest('POST', $target, [], null, $gx->toJson()); return $this->stateFactory->createState('RelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Declares the match status for the current person the specified search result entry. * * @param Entry $entry * @param string $status * @param StateTransitionOption $options * @return PersonMatchResultsState */ public function updateMatchStatus(Entry $entry, $status, StateTransitionOption $options = null) { $updateStatusUri = $this->getSelfUri(); $entity = new Gedcomx(); $person = new Person(); $id = new Identifier(); $id->setType(IdentifierType::PERSISTENT); $id->setValue($entry->getId()); $person->setIdentifiers(array($id)); $entity->setPersons(array($person)); $request = $this->createAuthenticatedGedcomxRequest("POST", $updateStatusUri, [], null, $entity->toJson()); $request = $request->withoutHeader("Accept"); return $this->stateFactory->createState("PersonMatchResultsState", $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Moves the current source description to the specified collection. * * @param CollectionState $collection * @param StateTransitionOption $options,... * @return FamilySearchSourceDescriptionState|null */ public function moveToCollection(CollectionState $collection, StateTransitionOption $options = null) { $link = $collection->getLink(Rel::SOURCE_DESCRIPTIONS); if ($link == null || $link->getHref() == null) { return null; } /** @var SourceDescription $me */ $me = $this->getSourceDescription(); if ($me == null || $me->getId() == null) { return null; } /** @var Gedcomx $gx */ $gx = new Gedcomx(); $sd = new SourceDescription(); $sd->setId($me->getId()); $gx->setSourceDescriptions(array($sd)); $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes(), null, $gx->toJson()); return $this->stateFactory->createState('SourceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Flag the Person passed as not a match to the current person using a Person conclusion object * * @param \Gedcomx\Conclusion\Person $person * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\PersonNonMatchesState|null */ public function addNonMatchPerson(Person $person, StateTransitionOption $option = null) { $link = $this->getLink(Rel::NOT_A_MATCHES); if ($link == null || $link->getHref() == null) { return null; } $entity = new Gedcomx(); $entity->addPerson($person); $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes(), null, $entity->toJson()); return $this->stateFactory->createState('PersonNonMatchesState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }