Exemplo n.º 1
0
 /// <summary>
 /// Gets an existing APObject by type and id.
 /// </summary>
 /// <param name="type">Object type (schema name).</param>
 /// <param name="id">Object id.</param>
 /// <param name="fields">The object fields to be retrieved.</param>
 /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
 /// <returns>The matching APObject instance.</returns>
 public async static Task<APObject> GetAsync(string type, string id, IEnumerable<string> fields = null, ApiOptions options = null)
 {
     var request = new GetObjectRequest() { Id = id, Type = type, };
     if (fields != null)
         request.Fields.AddRange(fields);
     ApiOptions.Apply(request, options);
     var response = await request.ExecuteAsync();
     if (response.Status.IsSuccessful == false)
         throw response.Status.ToFault();
     Debug.Assert(response.Object != null, "For a successful get call, object should always be returned.");
     return response.Object;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets an existing APObject by type and id.
        /// </summary>
        /// <param name="type">Object type (schema name).</param>
        /// <param name="id">Object id.</param>
        /// <param name="fields">The object fields to be retrieved.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The matching APObject instance.</returns>
        public async static Task <APObject> GetAsync(string type, string id, IEnumerable <string> fields = null, ApiOptions options = null)
        {
            var request = new GetObjectRequest()
            {
                Id = id, Type = type,
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            Debug.Assert(response.Object != null, "For a successful get call, object should always be returned.");
            return(response.Object);
        }