コード例 #1
0
        public virtual History Put <T, TSource, TSourceRequest, TSourceResponse>(XeroCreateEndpoint <T, TSource, TSourceRequest, TSourceResponse> sourceEndpoint, TSource source, string noteContent)
            where T : XeroReadEndpoint <T, TSource, TSourceResponse>
            where TSourceResponse : IXeroResponse <TSource>, new()
            where TSourceRequest : IXeroRequest <TSource>, new()
            where TSource : IHasId
        {
            var data = new HistoryRequest();

            data.Add(new History {
                Details = noteContent
            });
            try
            {
                Client.Where         = null;
                Client.Order         = null;
                Client.ModifiedSince = null;
                Client.Parameters    = null;

                Type         sourceEndpointType         = sourceEndpoint.GetType();
                PropertyInfo apiEndpointUrlPropertyInfo = sourceEndpointType.GetProperty("ApiEndpointUrl", BindingFlags.Instance | BindingFlags.NonPublic);
                if (apiEndpointUrlPropertyInfo == null)
                {
                    throw new InvalidOperationException("History is not avaialble.");
                }
                string rawApiEndpointUrl = (string)apiEndpointUrlPropertyInfo.GetValue(sourceEndpoint, null);

                return(Client.Put <History, HistoryResponse>(string.Format("{0}/{1}/history", rawApiEndpointUrl, source.Id), data).First());
            }
            finally
            {
                ClearQueryString();
            }
        }
コード例 #2
0
 /// <summary>
 /// Add/link/associate a note to the <paramref name="source"/>
 /// as per https://developer.xero.com/documentation/api/history-and-notes.
 /// </summary>
 /// <param name="endpoint">The <see cref="XeroReadEndpoint{T,TResult,TResponse}">endpoint</see> to leverage to communicate with the Xero API.</param>
 /// <param name="source">The item/object that you want to get history for.</param>
 /// <param name="noteContent">The content of the note to add/link/associate.</param>
 /// <returns>The created history/note information.</returns>
 public static History AddNote <T, TResult, TRequest, TResponse>(this XeroCreateEndpoint <T, TResult, TRequest, TResponse> endpoint, TResult source, string noteContent)
     where T : XeroReadEndpoint <T, TResult, TResponse>
     where TResponse : IXeroResponse <TResult>, new()
     where TRequest : IXeroRequest <TResult>, new()
     where TResult : IHasId
 {
     return(new HistoryEndpoint(endpoint.Client).Put(endpoint, source, noteContent));
 }