public async Task <MOLogsResponse> ExecuteAsync(GetReceivedSmsLogsExecuteContext context) { using (var client = HttpClientProvider.GetHttpClient(configuration)) { NameValueCollection queryParameters = HttpUtility.ParseQueryString(string.Empty); SetQueryParamIfNotNull(queryParameters, "to", context.To); SetQueryParamIfNotNull(queryParameters, "receivedSince", context.ReceivedSince); SetQueryParamIfNotNull(queryParameters, "receivedUntil", context.ReceivedUntil); SetQueryParamIfNotNull(queryParameters, "limit", context.Limit); SetQueryParamIfNotNull(queryParameters, "keyword", context.Keyword); string queryString = queryParameters.ToString(); string endpoint = path + "?" + queryString; var response = await client.GetAsync(endpoint); string contents = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <MOLogsResponse>(contents, Settings)); } else { throw new InfobipApiException( response.StatusCode, JsonConvert.DeserializeObject <ApiErrorResponse>(contents, Settings) ); } } }
public override async Task RunExampleAsync() { GetReceivedSmsLogs client = new GetReceivedSmsLogs(BASIC_AUTH_CONFIGURATION); GetReceivedSmsLogsExecuteContext context = new GetReceivedSmsLogsExecuteContext { To = null, ReceivedSince = null, ReceivedUntil = null, Limit = 10, Keyword = null }; MOLogsResponse response = await client.ExecuteAsync(context); if (!response.Results.Any()) { Console.WriteLine("No reports to display."); return; } foreach (MOLog log in response.Results) { Console.WriteLine("-------------------------------"); Console.WriteLine("Message ID: " + log.MessageId); Console.WriteLine("Received at: " + log.ReceivedAt); Console.WriteLine("Sender: " + log.From); Console.WriteLine("Receiver: " + log.To); Console.WriteLine("Message text: " + log.Text); Console.WriteLine("Keyword: " + log.Keyword); Console.WriteLine("Clean text: " + log.CleanText); Console.WriteLine("Sms count: " + log.SmsCount); } Console.WriteLine("-------------------------------"); }