Beispiel #1
0
        public async Task <Letter> SendLetterAsync(LetterRequest letterRequest = null)
        {
            if (!HasSends())
            {
                throw new EntityException("Send letter operation not supported on object.");
            }

            string responseText;

            var url = GetEndpoint(true) + "/letters";

            if (letterRequest != null)
            {
                var jsonRequestBody = letterRequest.ToJsonString();
                responseText = await _connection.PostAsync(url, null, jsonRequestBody).ConfigureAwait(false);
            }
            else
            {
                responseText = _connection.Post(url, null, "");
            }

            return(JsonConvert.DeserializeObject <Letter>(responseText,
                                                          new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore
            }));
        }
Beispiel #2
0
        public Letter SendLetter(LetterRequest letterRequest = null)
        {
            if (!this.HasSends())
            {
                throw new EntityException("Send letter operation not supported on object.");
            }

            Letter letter       = null;
            string responseText = null;

            string url = this.GetEndpoint(true) + "/letters";

            if (letterRequest != null)
            {
                string jsonRequestBody = letterRequest.ToJsonString();
                responseText = this.Connection.Post(url, null, jsonRequestBody);
            }
            else
            {
                responseText = this.Connection.Post(url, null, "");
            }

            letter = JsonConvert.DeserializeObject <Letter>(responseText,
                                                            new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore
            });

            return(letter);
        }
Beispiel #3
0
 public Letter SendStatementLetter(LetterRequest letterRequest = null)
 {
     return(this.SendLetter(letterRequest));
 }