/** * Restore the current relationship (if it is currently deleted). * * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return mixed|null */ public function restore(StateTransitionOption $option = null) { $link = $this->getLink(Rel::RESTORE); if ($link == null || $link->getHref() == null) { return null; } $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('RelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Reads the merge mirror for the current merge. * * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return PersonMergeState|null */ public function readMergeMirror(StateTransitionOption $option = null) { $link = $this->getLink(Rel::MERGE_MIRROR); if ($link == null || $link->getHref() == null) { return null; } $request = $this->createAuthenticatedRequest('GET', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('PersonMergeState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Restores the specified change if it had been reverted. * * @param \Gedcomx\Atom\Entry $change * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException * @return ChangeHistoryState | null */ public function restoreChange(Entry $change, StateTransitionOption $option = null) { $link = $change->getLink(Rel::RESTORE); if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException("Unrestorable change: " . $change->getId()); } $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('ChangeHistoryState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Remove a preferred relationship from a person * * @param $treeUserId * @param $personId * @param $rel * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return FamilyTreePersonState * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException */ protected function deletePreferredRelationship($treeUserId, $personId, $rel, StateTransitionOption $option = null) { $link = $this->getLink($rel); if ($link == null || $link->getTemplate() == null) { return null; } $uri = array($link->getTemplate(), array("pid" => $personId, "uid" => $treeUserId)); $request = $this->createAuthenticatedRequest('DELETE', $uri, FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('PersonState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Read the list of sources associated with this relationship * * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Rs\Client\SourceDescriptionState|null */ public function readSources(StateTransitionOption $option = null) { $link = $this->getLink(Rel::SOURCE_DESCRIPTIONS); if ($link == null || $link->getHref() == null) { return null; } $request = $this->createAuthenticatedGedcomxRequest('GET', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('SourceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds a discussion to this discussions state instance. * * @param Discussion $discussion * @param StateTransitionOption $option,... * * @return DiscussionState */ public function addDiscussion(Discussion $discussion, StateTransitionOption $option = null) { $entity = new FamilySearchPlatform(); $entity->addDiscussion($discussion); $request = $this->createAuthenticatedRequest('POST', $this->getSelfUri(), FamilySearchRequest::getMediaTypes(), null, $entity->toJson()); return $this->stateFactory->createState('DiscussionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Declares the specified search result entry as not a match for the current person. * * @param Entry $entry * @param StateTransitionOption $options * @return PersonNonMatchesState */ public function addNonMatch(Entry $entry, StateTransitionOption $options = null) { $link = $this->getLink(Rel::NOT_A_MATCHES); if ($link == null || $link->getHref() == null) { return null; } $entity = new Gedcomx(); $person = new Person(); $person->setId($entry->getId()); $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); }
/** * 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); }
/** * Removes the declared non match person from this collection. * * @param \Gedcomx\Conclusion\Person $nonMatch * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return mixed|null */ public function removeNonMatch(Person $nonMatch, StateTransitionOption $option = null) { $link = $nonMatch->getLink(Rel::NOT_A_MATCHES); if ($link == null || $link->getHref() == null) { return null; } $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('PersonNonMatchesState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Return the PlaceGroup with the given id * * @param string $id * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Rs\Client\PlaceGroupState|null */ public function readPlaceGroupById($id, StateTransitionOption $option = null) { $link = $this->getLink(Rel::PLACE_GROUP); if ($link == null || $link->getTemplate() == null) { return null; } $uri = array($link->getTemplate(), array("pgid" => $id)); $request = $this->createAuthenticatedRequest('GET', $uri, FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('PlaceGroupState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Deletes the specified comment from the current discussion. * * @param Comment $comment * @param StateTransitionOption $option,... * * @return DiscussionState * @throws GedcomxApplicationException */ public function deleteComment(Comment $comment, StateTransitionOption $option = null) { $link = $comment->getLink(Rel::COMMENT); $link = $link == null ? $comment->getLink(Rel::SELF) : $link; if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException("Comment cannot be deleted: missing {$link}."); } $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes()); return $this->stateFactory->createState('DiscussionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds a discussion to the current collection. * * @param Discussion $discussion * @param StateTransitionOption $option,... * * @return DiscussionState * @throws GedcomxApplicationException */ public function addDiscussion(Discussion $discussion, StateTransitionOption $option = null) { $link = $this->getLink(Rel::DISCUSSIONS); if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException("Unable to add discussion: missing link."); } $entity = new FamilySearchPlatform(); $entity->addDiscussion($discussion); $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes(), null, $entity->toJson()); return $this->stateFactory->createState('DiscussionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }