/// <summary> /// Initializes a new instance of the <see cref="DetectAddressApi"/> class /// using Configuration object /// </summary> /// <param name="configuration">An instance of Configuration</param> /// <returns></returns> public DetectAddressApi(IO.ClickSend.Client.Configuration configuration = null) { if (configuration == null) // use the default one in Configuration this.Configuration = IO.ClickSend.Client.Configuration.Default; else this.Configuration = configuration; ExceptionFactory = IO.ClickSend.Client.Configuration.DefaultExceptionFactory; }
/// <summary> /// Initializes a new instance of the <see cref="PostPostcardApi"/> class /// using Configuration object /// </summary> /// <param name="configuration">An instance of Configuration</param> /// <returns></returns> public PostPostcardApi(IO.ClickSend.Client.Configuration configuration = null) { if (configuration == null) // use the default one in Configuration { this.Configuration = IO.ClickSend.Client.Configuration.Default; } else { this.Configuration = configuration; } ExceptionFactory = IO.ClickSend.Client.Configuration.DefaultExceptionFactory; }
private async Task <bool> SendSMSAsync(string number, string message) { var userName = Environment.GetEnvironmentVariable("clickSendUser"); var apiKey = Environment.GetEnvironmentVariable("clickSendApiKey"); var config = new IO.ClickSend.Client.Configuration(); config.Username = userName; config.Password = apiKey; var clickSend = new SMSApi(config); var smsMessage = new SmsMessage(null, message, number); var sms = new List <SmsMessage>() { smsMessage }; var collection = new SmsMessageCollection(sms); var responseTask = clickSend.SmsSendPostAsync(collection); var responseString = await responseTask; ClickSendResponse response = JsonSerializer.Deserialize <ClickSendResponse>(responseString); if (response.http_code == 200) { //TODO: there is a 'data' object in the deserializer that lets us know if the text went through if (_logger != null) { _logger.LogInformation($"We got a positive message back from Clicksend. They say the satus of the message is: {response.data.messages[0].status}"); } return(true); } if (_logger != null) { _logger.LogError($"Our attempt to send an sms message failed. Here's what we know. \nHttp response code: {response.http_code} \nResponse message:{response.response_msg}"); } return(false); }