コード例 #1
0
        /// <summary>
        /// Deletes the preferred relationship for the specified person.
        /// </summary>
        /// <param name="treeUserId">The <see cref="P:User.TreeUserId" /> for which the preference will be set. 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="rel">The rel name of the link to use to perform this operation.</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 delete what the specified user prefers to
        /// see for the specified relationship.
        /// </remarks>
        protected FamilyTreePersonState DeletePreferredRelationship(String treeUserId, String personId, String rel, 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.DELETE);
            return (FamilyTreePersonState)((FamilyTreeStateFactory)this.stateFactory).NewPersonStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
コード例 #2
0
        /// <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);
            }
        }