public override async Task RunExampleAsync() { GetSentSmsLogs client = new GetSentSmsLogs(BASIC_AUTH_CONFIGURATION); GetSentSmsLogsExecuteContext context = new GetSentSmsLogsExecuteContext() { From = null, To = null, BulkId = null, MessageId = null, GeneralStatus = null, SentSince = null, SentUntil = null, Limit = 10, Mcc = null, Mnc = null }; SMSLogsResponse response = await client.ExecuteAsync(context); if (!response.Results.Any()) { Console.WriteLine("No logs to display."); return; } foreach (SMSLog log in response.Results) { Console.WriteLine("-------------------------------"); Console.WriteLine("Message ID: " + log.MessageId); Console.WriteLine("Sent at: " + log.SentAt); Console.WriteLine("Sender: " + log.From); Console.WriteLine("Receiver: " + log.To); Console.WriteLine("Message text: " + log.Text); Console.WriteLine("Status: " + log.Status.Name); Console.WriteLine("Price: " + log.Price.PricePerMessage + " " + log.Price.Currency); } Console.WriteLine("-------------------------------"); }
public async Task <SMSLogsResponse> ExecuteAsync(GetSentSmsLogsExecuteContext context) { using (var client = HttpClientProvider.GetHttpClient(configuration)) { NameValueCollection queryParameters = new NameValueCollection(); SetQueryParamIfNotNull(queryParameters, "from", context.From); SetQueryParamIfNotNull(queryParameters, "to", context.To); SetQueryParamIfNotNull(queryParameters, "bulkId", context.BulkId); SetQueryParamIfNotNull(queryParameters, "messageId", context.MessageId); SetQueryParamIfNotNull(queryParameters, "generalStatus", context.GeneralStatus); SetQueryParamIfNotNull(queryParameters, "sentSince", context.SentSince); SetQueryParamIfNotNull(queryParameters, "sentUntil", context.SentUntil); SetQueryParamIfNotNull(queryParameters, "limit", context.Limit); SetQueryParamIfNotNull(queryParameters, "mcc", context.Mcc); SetQueryParamIfNotNull(queryParameters, "mnc", context.Mnc); string queryString = queryParameters.ToQueryString(); string endpoint = path + "?" + queryString; var response = await client.GetAsync(endpoint); string contents = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <SMSLogsResponse>(contents, Settings)); } else { throw new InfobipApiException( response.StatusCode, JsonConvert.DeserializeObject <ApiErrorResponse>(contents, Settings) ); } } }