Ejemplo n.º 1
0
        public IEnumerator FulfillUserItem(string @namespace, string userId, string accessToken,
                                           FulfillmentRequest fulfillmentRequest, ResultCallback <FulfillmentResult> callback)
        {
            Assert.IsNotNull(@namespace, $"{nameof(@namespace)} cannot be null");
            Assert.IsNotNull(userId, $"{nameof(userId)} cannot be null");
            Assert.IsNotNull(accessToken, $"{nameof(accessToken)} cannot be null");
            Assert.IsNotNull(fulfillmentRequest, $"{nameof(fulfillmentRequest)} cannot be null");

            var request = HttpRequestBuilder
                          .CreatePost(this.baseUrl + "/admin/namespaces/{namespace}/users/{userId}/fulfillment")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBody(fulfillmentRequest.ToUtf8Json())
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <FulfillmentResult>();

            callback.Try(result);
        }