/// <summary> /// Reads the preferred relationship for the specified person. /// </summary> /// <param name="rel">The rel name of the link to use to perform this operation.</param> /// <param name="treeUserId">The <see cref="P:User.TreeUserId" /> for which the preference will be read. This is typically the current tree user. An API error may result if the user specified /// is someone other than the current tree user (due to a lack of permissions).</param> /// <param name="personId">The person ID for which the preferred relationship will be read.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="IPreferredRelationshipState" /> instance containing the REST API response. /// </returns> /// <remarks> /// Tree users can have varying relationship preferences; therefore, this method will only read what the specified user prefers to /// see for the specified relationship. /// </remarks> protected IPreferredRelationshipState ReadPreferredRelationship(String rel, String treeUserId, String personId, IStateTransitionOption[] options) { Link link = GetLink(rel); if (link == null || link.Template == null) { return(null); } String template = link.Template; String uri = new UriTemplate(template).AddParameter("pid", personId).AddParameter("uid", treeUserId).Resolve(); IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(uri, Method.GET); IRestResponse response = Invoke(request, options); if (response.StatusCode == HttpStatusCode.NoContent) { return(null); } FamilySearchPlatform fsp = response.ToIRestResponse <FamilySearchPlatform>().Data; if (fsp != null && fsp.ChildAndParentsRelationships != null && fsp.ChildAndParentsRelationships.Count > 0) { return(((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, response, this.Client, this.CurrentAccessToken)); } else { return((IPreferredRelationshipState)((FamilyTreeStateFactory)this.stateFactory).NewRelationshipStateInt(request, response, this.Client, this.CurrentAccessToken)); } }
public void VisitFamilySearchPlatform(FamilySearchPlatform fsp) { VisitGedcomx(fsp); this.contextStack.Push(fsp); List <Discussion> discussions = fsp.Discussions; if (discussions != null) { foreach (Discussion discussion in discussions) { discussion.Accept(this); } } List <Merge> merges = fsp.Merges; if (merges != null) { foreach (Merge merge in merges) { merge.Accept(this); } } List <MergeAnalysis> mergeAnalyses = fsp.MergeAnalyses; if (mergeAnalyses != null) { foreach (MergeAnalysis merge in mergeAnalyses) { merge.Accept(this); } } List <ChildAndParentsRelationship> childAndParentsRelationships = fsp.ChildAndParentsRelationships; if (childAndParentsRelationships != null) { foreach (ChildAndParentsRelationship pcr in childAndParentsRelationships) { pcr.Accept(this); } } List <User> users = fsp.Users; if (users != null) { foreach (User user in users) { user.Accept(this); } } this.contextStack.Pop(); }
/// <summary> /// Returns the <see cref="Gx.Gedcomx"/> from the REST API response. /// </summary> /// <param name="response">The REST API response.</param> /// <returns>The <see cref="Gx.Gedcomx"/> from the REST API response.</returns> protected override Gx.Gedcomx LoadEntity(IRestResponse response) { FamilySearchPlatform result = null; if (response != null) { result = response.ToIRestResponse <FamilySearchPlatform>().Data; } return(result); }
/// <summary> /// Adds a child and parents relationship to the current relationships collection. /// </summary> /// <param name="chap">The relationship to add to the current relationships collection, with the father, mother, and child set as desired.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response. /// </returns> public ChildAndParentsRelationshipState AddChildAndParentsRelationship(ChildAndParentsRelationship chap, params IStateTransitionOption[] options) { FamilySearchPlatform entity = new FamilySearchPlatform(); entity.ChildAndParentsRelationships = new List <ChildAndParentsRelationship>() { chap }; IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(GetSelfUri(), Method.POST); return(((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken)); }
public void VisitFamilySearchPlatform(FamilySearchPlatform fsp) { VisitGedcomx(fsp); this.contextStack.Push(fsp); List<Discussion> discussions = fsp.Discussions; if (discussions != null) { foreach (Discussion discussion in discussions) { discussion.Accept(this); } } List<Merge> merges = fsp.Merges; if (merges != null) { foreach (Merge merge in merges) { merge.Accept(this); } } List<MergeAnalysis> mergeAnalyses = fsp.MergeAnalyses; if (mergeAnalyses != null) { foreach (MergeAnalysis merge in mergeAnalyses) { merge.Accept(this); } } List<ChildAndParentsRelationship> childAndParentsRelationships = fsp.ChildAndParentsRelationships; if (childAndParentsRelationships != null) { foreach (ChildAndParentsRelationship pcr in childAndParentsRelationships) { pcr.Accept(this); } } List<User> users = fsp.Users; if (users != null) { foreach (User user in users) { user.Accept(this); } } this.contextStack.Pop(); }
/// <summary> /// Adds a discussion to the current collection. /// </summary> /// <param name="discussion">The discussion.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="DiscussionState"/> instance containing the REST API response. /// </returns> /// <exception cref="Gx.Rs.Api.GedcomxApplicationException">Thrown if a link to the required resource cannot be found.</exception> public DiscussionState AddDiscussion(Discussion discussion, params IStateTransitionOption[] options) { Link link = GetLink(Rel.DISCUSSIONS); if (link == null || link.Href == null) { throw new GedcomxApplicationException("Unable to add discussion: missing link."); } FamilySearchPlatform entity = new FamilySearchPlatform(); entity.AddDiscussion(discussion); IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(entity).Build(link.Href, Method.POST); return(((FamilySearchStateFactory)this.stateFactory).NewDiscussionState(request, Invoke(request, options), this.Client, this.CurrentAccessToken)); }
/// <summary> /// Adds the child and parents relationships to the collection. /// </summary> /// <param name="chaps">The child and parent relationships to add.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="RelationshipsState"/> instance containing the REST API response. /// </returns> /// <exception cref="Gx.Rs.Api.GedcomxApplicationException">Thrown if a link to the required resource cannot be found.</exception> public RelationshipsState AddChildAndParentsRelationships(List <ChildAndParentsRelationship> chaps, params IStateTransitionOption[] options) { Link link = GetLink(Rel.RELATIONSHIPS); if (link == null || link.Href == null) { throw new GedcomxApplicationException(String.Format("FamilySearch Family Tree at {0} didn't provide a 'relationships' link.", GetUri())); } FamilySearchPlatform entity = new FamilySearchPlatform(); entity.ChildAndParentsRelationships = chaps; IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.POST); request.SetEntity(entity); return(((FamilyTreeStateFactory)this.stateFactory).NewRelationshipsStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken)); }