gedcomx-php-client
  • Namespace
  • Class

Namespaces

  • Gedcomx
    • Agent
    • Atom
    • Common
    • Conclusion
    • Extensions
      • FamilySearch
        • Platform
          • Artifacts
          • Discussions
          • Tree
          • Users
        • Rs
          • Client
            • FamilyTree
            • Helpers
            • Memories
            • Util
        • Rt
        • Types
    • GedcomxFile
    • Links
    • Records
    • Rs
      • Client
        • Exception
        • Options
        • Util
    • Rt
    • Search
    • Source
    • Support
    • Types
    • Util
    • Vocab

Classes

  • Gedcomx\Agent\Address
  • Gedcomx\Agent\Agent
  • Gedcomx\Agent\OnlineAccount
  • Gedcomx\Atom\Category
  • Gedcomx\Atom\CommonAttributes
  • Gedcomx\Atom\Content
  • Gedcomx\Atom\Entry
  • Gedcomx\Atom\ExtensibleElement
  • Gedcomx\Atom\Feed
  • Gedcomx\Atom\Generator
  • Gedcomx\Atom\Person
  • Gedcomx\Common\Attribution
  • Gedcomx\Common\CustomEntity
  • Gedcomx\Common\CustomKeyedItem
  • Gedcomx\Common\EvidenceReference
  • Gedcomx\Common\ExtensibleData
  • Gedcomx\Common\Note
  • Gedcomx\Common\Qualifier
  • Gedcomx\Common\ResourceReference
  • Gedcomx\Common\TextValue
  • Gedcomx\Common\UniqueCustomKeyedItem
  • Gedcomx\Conclusion\Conclusion
  • Gedcomx\Conclusion\DateInfo
  • Gedcomx\Conclusion\DisplayProperties
  • Gedcomx\Conclusion\Document
  • Gedcomx\Conclusion\Event
  • Gedcomx\Conclusion\EventRole
  • Gedcomx\Conclusion\Fact
  • Gedcomx\Conclusion\Gender
  • Gedcomx\Conclusion\Identifier
  • Gedcomx\Conclusion\Name
  • Gedcomx\Conclusion\NameForm
  • Gedcomx\Conclusion\NamePart
  • Gedcomx\Conclusion\Person
  • Gedcomx\Conclusion\PlaceDescription
  • Gedcomx\Conclusion\PlaceDisplayProperties
  • Gedcomx\Conclusion\PlaceReference
  • Gedcomx\Conclusion\Relationship
  • Gedcomx\Conclusion\Subject
  • Gedcomx\Extensions\FamilySearch\Error
  • Gedcomx\Extensions\FamilySearch\FamilySearchPlatform
  • Gedcomx\Extensions\FamilySearch\Feature
  • Gedcomx\Extensions\FamilySearch\HealthConfig
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactMetadata
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactType
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Comment
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Discussion
  • Gedcomx\Extensions\FamilySearch\Platform\Error
  • Gedcomx\Extensions\FamilySearch\Platform\HealthConfig
  • Gedcomx\Extensions\FamilySearch\Platform\Tag
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectModifier
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectType
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeOperation
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\DiscussionReference
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchStatus
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\Merge
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeAnalysis
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeConflict
  • Gedcomx\Extensions\FamilySearch\Platform\Users\User
  • Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchClient
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchCollectionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaceDescriptionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaces
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaceState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchSourceDescriptionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchStateFactory
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChangeHistoryState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChildAndParentsRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeCollectionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonChildrenState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonParentsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeRelationshipsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeStateFactory
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Helpers\FamilySearchRequest
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Memories\FamilySearchMemories
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonMatchResultsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonMergeState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonNonMatchesState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Rel
  • Gedcomx\Extensions\FamilySearch\Rs\Client\UserHistoryState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\UserState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ChangeEntry
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ChangeHistoryPage
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\LoggerMiddleware
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ThrottlingMiddleware
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformLocalReferenceResolver
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitorBase
  • Gedcomx\Extensions\FamilySearch\Tag
  • Gedcomx\Extensions\FamilySearch\Types\FactType
  • Gedcomx\Gedcomx
  • Gedcomx\GedcomxFile\DefaultJsonSerialization
  • Gedcomx\GedcomxFile\DefaultXMLSerialization
  • Gedcomx\GedcomxFile\GedcomxFile
  • Gedcomx\GedcomxFile\GedcomxFileEntry
  • Gedcomx\GedcomxFile\GedcomxOutput
  • Gedcomx\GedcomxFile\Manifest
  • Gedcomx\GedcomxFile\ManifestAttribute
  • Gedcomx\Links\HypermediaEnabledData
  • Gedcomx\Links\Link
  • Gedcomx\Records\Collection
  • Gedcomx\Records\CollectionContent
  • Gedcomx\Records\Field
  • Gedcomx\Records\FieldDescriptor
  • Gedcomx\Records\FieldValue
  • Gedcomx\Records\FieldValueDescriptor
  • Gedcomx\Records\RecordDescriptor
  • Gedcomx\Records\RecordSet
  • Gedcomx\Records\RecordSetIterator
  • Gedcomx\Rs\Client\AgentState
  • Gedcomx\Rs\Client\AncestryResultsState
  • Gedcomx\Rs\Client\CollectionsState
  • Gedcomx\Rs\Client\CollectionState
  • Gedcomx\Rs\Client\DescendancyResultsState
  • Gedcomx\Rs\Client\GedcomxApplicationState
  • Gedcomx\Rs\Client\GedcomxSearchQuery
  • Gedcomx\Rs\Client\Options\CacheDirectives
  • Gedcomx\Rs\Client\Options\HeaderParameter
  • Gedcomx\Rs\Client\Options\Preconditions
  • Gedcomx\Rs\Client\Options\QueryParameter
  • Gedcomx\Rs\Client\PersonChildrenState
  • Gedcomx\Rs\Client\PersonParentsState
  • Gedcomx\Rs\Client\PersonSearchResultsState
  • Gedcomx\Rs\Client\PersonSpousesState
  • Gedcomx\Rs\Client\PersonsState
  • Gedcomx\Rs\Client\PersonState
  • Gedcomx\Rs\Client\PlaceDescriptionsState
  • Gedcomx\Rs\Client\PlaceDescriptionState
  • Gedcomx\Rs\Client\PlaceGroupState
  • Gedcomx\Rs\Client\PlaceSearchResultsState
  • Gedcomx\Rs\Client\RecordsState
  • Gedcomx\Rs\Client\RecordState
  • Gedcomx\Rs\Client\Rel
  • Gedcomx\Rs\Client\RelationshipsState
  • Gedcomx\Rs\Client\RelationshipState
  • Gedcomx\Rs\Client\SearchParameter
  • Gedcomx\Rs\Client\SourceDescriptionsState
  • Gedcomx\Rs\Client\SourceDescriptionState
  • Gedcomx\Rs\Client\StateFactory
  • Gedcomx\Rs\Client\Util\AncestryNode
  • Gedcomx\Rs\Client\Util\AncestryTree
  • Gedcomx\Rs\Client\Util\DataSource
  • Gedcomx\Rs\Client\Util\DescendancyNode
  • Gedcomx\Rs\Client\Util\DescendancyTree
  • Gedcomx\Rs\Client\Util\EmbeddedLinkLoader
  • Gedcomx\Rs\Client\Util\Embedding
  • Gedcomx\Rs\Client\Util\GedcomxBaseSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\GedcomxPersonSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\GedcomxPlaceSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\HttpStatus
  • Gedcomx\Rs\Client\Util\RdfCollection
  • Gedcomx\Rs\Client\Util\RdfNode
  • Gedcomx\Rs\Client\Util\SearchParameter
  • Gedcomx\Rs\Client\VocabConstants
  • Gedcomx\Rs\Client\VocabElementListState
  • Gedcomx\Rs\Client\VocabElementState
  • Gedcomx\Rt\GedcomxLocalReferenceResolver
  • Gedcomx\Rt\GedcomxModelVisitorBase
  • Gedcomx\Search\ResultConfidence
  • Gedcomx\Source\CitationField
  • Gedcomx\Source\Coverage
  • Gedcomx\Source\SourceCitation
  • Gedcomx\Source\SourceDescription
  • Gedcomx\Source\SourceReference
  • Gedcomx\Types\ConfidenceLevel
  • Gedcomx\Types\DocumentType
  • Gedcomx\Types\EventRoleType
  • Gedcomx\Types\EventType
  • Gedcomx\Types\FactType
  • Gedcomx\Types\FieldType
  • Gedcomx\Types\FieldValueType
  • Gedcomx\Types\GenderType
  • Gedcomx\Types\IdentifierType
  • Gedcomx\Types\NamePartType
  • Gedcomx\Types\NameType
  • Gedcomx\Types\RecordType
  • Gedcomx\Types\RelationshipType
  • Gedcomx\Types\ResourceType
  • Gedcomx\Util\Collection
  • Gedcomx\Util\Duration
  • Gedcomx\Util\FormalDate
  • Gedcomx\Util\JsonMapper
  • Gedcomx\Util\SimpleDate
  • Gedcomx\Util\XmlMapper
  • Gedcomx\Vocab\VocabElement
  • Gedcomx\Vocab\VocabElementList

Interfaces

  • Gedcomx\Common\Attributable
  • Gedcomx\Common\HasNotes
  • Gedcomx\Conclusion\HasFacts
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\PreferredRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitor
  • Gedcomx\GedcomxFile\GedcomxEntryDeserializer
  • Gedcomx\GedcomxFile\GedcomxEntrySerializer
  • Gedcomx\Links\SupportsLinks
  • Gedcomx\Records\HasFields
  • Gedcomx\Rs\Client\Options\StateTransitionOption
  • Gedcomx\Rs\Client\SupportsExtensionElements
  • Gedcomx\Rt\GedcomxModelVisitor
  • Gedcomx\Source\ReferencesSources
  • Gedcomx\Support\HasJsonKey

Exceptions

  • Gedcomx\GedcomxFile\GedcomxFileException
  • Gedcomx\Rs\Client\Exception\GedcomxApplicationException
  • Gedcomx\Rs\Client\Exception\GedcomxInvalidQueryParameter
  • Gedcomx\Rs\Client\Exception\NullValueException
  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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 
<?php


namespace Gedcomx\Rs\Client;

use Gedcomx\Common\EvidenceReference;
use Gedcomx\Common\Note;
use Gedcomx\Conclusion\Fact;
use Gedcomx\Conclusion\Relationship;
use Gedcomx\Gedcomx;
use Gedcomx\Rs\Client\Exception\GedcomxApplicationException;
use Gedcomx\Rs\Client\Options\StateTransitionOption;
use Gedcomx\Source\SourceReference;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;

/**
 * The RelationshipState exposes management functions for a relationship.
 */
class RelationshipState extends GedcomxApplicationState
{
    /**
     * Constructs a relationship 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);
    }

    /**
     * Clones the current state instance.
     *
     * @param \GuzzleHttp\Psr7\Request  $request
     * @param \GuzzleHttp\Psr7\Response $response
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    protected function reconstruct(Request $request, Response $response)
    {
        return new RelationshipState($this->client, $request, $response, $this->accessToken, $this->stateFactory);
    }

    /**
     * Instantiates a new relationship and only sets the relationship ID to the current relationship's ID.
     * @return \Gedcomx\Conclusion\Relationship
     */
    protected function createEmptySelf()
    {
        $relationship = new Relationship();
        $relationship->setId($this->getLocalSelfId());
        return $relationship;
    }

    /**
     * Gets the current relationship ID.
     * @return null|string
     */
    protected function getLocalSelfId()
    {
        $me = $this->getRelationship();
        return $me == null ? null : $me->getId();
    }

    /**
     * Gets the entity represented by this state (if applicable). Not all responses produce entities.
     *
     * @return \Gedcomx\Gedcomx
     */
    protected function loadEntity()
    {
        $json = json_decode($this->response->getBody(), true);

        return new Gedcomx($json);
    }

    /**
     * Gets the main data element represented by this state instance.
     *
     * @return \Gedcomx\Conclusion\Relationship
     */
    protected function getScope()
    {
        return $this->getRelationship();
    }

    /**
     * Gets the first relationship of the current relationships.
     * @return Relationship
     */
    public function getRelationship()
    {
        if ($this->entity) {
            $relationships = $this->entity->getRelationships();
            if (count($relationships) > 0) {
                return $relationships[0];
            }
        }

        return null;
    }

    /**
     * Adds a fact to the current relationship.
     *
     * @param Fact                          $fact
     * @param Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addFacts', array(array($fact)), func_get_args());
    }

    /**
     * Adds facts to the current relationship.
     *
     * @param Fact[]                        $facts
     * @param Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, REL::CONCLUSIONS), func_get_args());
    }

    /**
     * Updates the fact of the current relationship.
     *
     * @param Fact                          $fact
     * @param Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateFacts', array(array($fact)), func_get_args());
    }

    /**
     * Updates the facts of the current relationship.
     *
     * @param Fact[]                        $facts
     * @param Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, REL::CONCLUSIONS), func_get_args());
    }

    /**
     * Deletes the fact of the current relationship.
     *
     * @param Fact                          $fact
     * @param Options\StateTransitionOption $option,...
     *
     * @throws GedcomxApplicationException
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function deleteFact(Fact $fact, StateTransitionOption $option = null)
    {
        $link = $fact->getLink(Rel::CONCLUSION);
        $link = $link == null ? $fact->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Conclusion cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Adds the specified source reference (in the SourceDescriptionState) to the current relationship.
     *
     * @param \Gedcomx\Rs\Client\SourceDescriptionState $source
     * @param Options\StateTransitionOption             $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addSourceDescriptionState(SourceDescriptionState $source, StateTransitionOption $option = null)
    {
        $reference = new SourceReference();
        $reference->setDescriptionRef($source->getSelfUri());
        return $this->passOptionsTo('addSourceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Adds the specified source reference to the current relationship.
     *
     * @param \Gedcomx\Source\SourceReference $reference
     * @param Options\StateTransitionOption   $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addSourceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Adds the specified source references to the current relationship.
     *
     * @param \Gedcomx\Source\SourceReference[] $refs
     * @param Options\StateTransitionOption     $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addSourceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setSources($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::SOURCE_REFERENCES), func_get_args());

    }

    /**
     * Updates the specified source reference for the current relationship.
     *
     * @param \Gedcomx\Source\SourceReference $reference
     * @param Options\StateTransitionOption   $option,...
     *
     * @internal param \Gedcomx\Source\SourceReference $sourceReference
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateSourceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Updates the specified source references for the current relationship.
     *
     * @param array                         $refs
     * @param Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateSourceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setSources($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::SOURCE_REFERENCES), func_get_args());

    }

    /**
     * Deletes the specified source reference from the current relationship.
     *
     * @param \Gedcomx\Source\SourceReference $reference
     * @param Options\StateTransitionOption   $option,...
     *
     * @throws Exception\GedcomxApplicationException
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function deleteSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::SOURCE_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Source reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Adds a media reference to the current relationship.
     *
     * @param SourceDescriptionState $description
     * @param StateTransitionOption  $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addMediaReferenceState(SourceDescriptionState $description, StateTransitionOption $option = null)
    {
        $reference = new SourceReference();
        $reference->setDescriptionRef($description->getSelfUri());
        return $this->passOptionsTo('addMediaReference', array($reference), func_get_args());
    }

    /**
     * Adds a media reference to the current relationship.
     *
     * @param SourceReference       $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addMediaReferences', array(array($reference)), func_get_args());
    }

    /**
     * Adds media references to the current relationship.
     *
     * @param array                 $refs
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addMediaReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMedia($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::MEDIA_REFERENCES), func_get_args());
    }

    /**
     * Updates the media reference for the current relationship.
     *
     * @param SourceReference       $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateMediaReferences', array(array($reference)), func_get_args());
    }

    /**
     * Updates the media references for the current relationship.
     *
     * @param array                 $refs
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateMediaReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMedia($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::MEDIA_REFERENCES), func_get_args());
    }

    /**
     * Deletes the specified media reference from the current relationship.
     *
     * @param SourceReference       $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     * @throws Exception\GedcomxApplicationException
     */
    public function deleteMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::MEDIA_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Media reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }


    /**
     * Adds an evidence reference to the current relationship.
     *
     * @param RelationshipState     $evidence
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addEvidenceReferenceState(RelationshipState $evidence, StateTransitionOption $option = null)
    {
        $reference = new EvidenceReference();
        $reference->setResource($evidence->getSelfUri());
        return $this->passOptionsTo('addEvidenceReference', array($reference), func_get_args());
    }

    /**
     * Adds an evidence reference to the current relationship.
     *
     * @param EvidenceReference     $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addEvidenceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Adds the evidence references to the current relationship.
     *
     * @param array                 $refs
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addEvidenceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setEvidence($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::EVIDENCE_REFERENCES), func_get_args());
    }

    /**
     * Update the evidence reference for the current relationship.
     *
     * @param EvidenceReference     $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateEvidenceReferences', array($reference), func_get_args());
    }

    /**
     * Updates the evidence references for the current relationship.
     *
     * @param array                 $refs
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateEvidenceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setEvidence($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::EVIDENCE_REFERENCES), func_get_args());
    }

    /**
     * Deletes the evidence reference from the current relationship.
     *
     * @param EvidenceReference     $reference
     * @param StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     * @throws Exception\GedcomxApplicationException
     */
    public function deleteEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::EVIDENCE_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Evidence reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Gets the first note from the current relationship notes.
     * @return \Gedcomx\Common\Note|null
     */
    public function getNote()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            if ($relationship->getNotes() != null && count($relationship->getNotes()) > 0) {
                $notes = $relationship->getNotes();

                return $notes[0];
            }
        }

        return null;
    }

    /**
     * Gets the first source reference from the current relationship sources.
     * @return \Gedcomx\Source\SourceReference|null
     */
    public function getSourceReference()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            if ($relationship->getSources() != null && count($relationship->getSources()) > 0) {
                $sources = $relationship->getSources();

                return $sources[0];
            }
        }

        return null;
    }

    /**
     * Reads the specified note.
     *
     * @param Note                  $note
     * @param StateTransitionOption $options
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     * @throws Exception\GedcomxApplicationException
     */
    public function readNote(Note $note, StateTransitionOption $options = null)
    {
        $link = $note->getLink(Rel::NOTE);
        $link = $link == null ? $note->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Note cannot be read: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('GET', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }


    /**
     * Adds a note to the current relationship.
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addNote(Note $note, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addNotes', array(array($note)), func_get_args());
    }

    /**
     * Add the notes to the current relationship.
     *
     * @param \Gedcomx\Common\Note[]                           $notes
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function addNotes(array $notes, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setNotes($notes);
        return $this->passOptionsTo('updateRelationshipNotes', array($relationship), func_get_args());
    }

    /**
     * Updates the specified note for the current relationship.
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateNote(Note $note, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateNotes', array(array($note)), func_get_args());
    }

    /**
     * Update the specified notes for the current relationship.
     *
     * @param \Gedcomx\Common\Note[]                           $notes
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateNotes(array $notes, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setNotes($notes);
        return $this->passOptionsTo('updateRelationshipNotes', array($relationship), func_get_args());
    }

    /**
     * Update the notes on the specified relationship.
     *
     * @param \Gedcomx\Conclusion\Relationship                 $relationship
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function updateRelationshipNotes(Relationship $relationship, StateTransitionOption $option = null)
    {
        $target = $this->getSelfUri();
        $link = $this->getLink(Rel::NOTES);
        if ($link != null && $link->getHref() != null) {
            $target = $link->getHref();
        }

        $gx = new Gedcomx();
        $gx->setRelationships(array($relationship));
        $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
        );
    }

    /**
     * Delete the specified note from the current relationship.
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @throws GedcomxApplicationException
     * @return \Gedcomx\Rs\Client\RelationshipState
     */
    public function deleteNote(Note $note, StateTransitionOption $option = null)
    {
        $link = $note->getLink(Rel::NOTE);
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Note cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'RelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Updates the specified relationship.
     *
     * @param \Gedcomx\Conclusion\Relationship $relationship
     *
     * @return mixed
     */
    public function updateSelf(Relationship $relationship)
    {
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::SELF), 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
        );
    }

    /**
     * Loads conclusions for the current relationship.
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return mixed
     */
    public function loadConclusions(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::CONCLUSIONS)), func_get_args());
    }

    /**
     * Loads source references for the current relationship.
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return mixed
     */
    public function loadSourceReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::SOURCE_REFERENCES)), func_get_args());
    }

    /**
     * Loads media references for the current relationship.
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return mixed
     */
    public function loadMediaReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::MEDIA_REFERENCES)), func_get_args());
    }

    /**
     * Loads evidence references for the current relationship.
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return mixed
     */
    public function loadEvidenceReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::EVIDENCE_REFERENCES)), func_get_args());
    }

    /**
     * Loads notes for the current relationship.
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return mixed
     */
    public function loadNotes(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::NOTES)), func_get_args());
    }

    /**
     * Loads the embedded resources for the specified links.
     *
     * @param array                                            $rels
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return $this
     */
    public function loadEmbeddedResources(array $rels, StateTransitionOption $option = null)
    {
        foreach ($rels as $rel) {
            $link = $this->getLink($rel);
            if ($this->entity != null && $link != null && $link->getHref() != null) {
                $this->passOptionsTo('embed', array($link), func_get_args());
            }
        }
        return $this;
    }

    /**
     * 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());
        return $this->stateFactory->createState(
            'SourceDescriptionState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Gets the rel name for the current state instance.
     * @return string
     */
    public function getSelfRel()
    {
        return Rel::RELATIONSHIP;
    }
}
gedcomx-php-client API documentation generated by ApiGen