public MessagingSenderIdServiceTest(MockHttpClientFixture mockHttpClientFixture)
            : base(mockHttpClientFixture)
        {
            this.service = new MessagingSenderIdService();

            this.sendMessageOptions = new NewMessagingSenderId
            {
                From = "+18665552368", // alphanumeric sender id
                To   = "+18665552367",
                Text = "Hello, World!"
            };

            this.sendMessageUsingNumberPoolOptions = new NewMessagingSenderId
            {
                MessagingProfileId = new Guid("dd50eba1-a0c0-4563-9925-b25e842a7cb6"),
                To   = "+18005550199",
                Text = "Hello, World!"
            };

            this.updateOptions = new MessagingSenderIdUpdate
            {
                MessagingProfileId = new Guid("3fa85f64-5717-4562-b3fc-2c963f66afa6")
            };

            this.requestOptions = new RequestOptions();

            this.cancellationToken = default(CancellationToken);
        }
        public async Task <IActionResult> Post(object messageBody)
        {
            // Deserialize incoming message
            dynamic   message   = JsonConvert.DeserializeObject(messageBody.ToString());
            EventType eventType = ToEnum <EventType>(message.data.event_type.ToString());

            // Respond only to received messages, not status updates
            if (eventType == EventType.MessageReceived)
            {
                // Determing how to repond to sender
                string responseText;
                switch (message.data.payload.text.ToString().ToLower())
                {
                case "pizza":
                    responseText = "Chicago pizza is the best";
                    break;

                case "ice cream":
                    responseText = "I prefer gelato";
                    break;

                default:
                    responseText = "Please send either the word ‘pizza’ or ‘ice cream’ for a different response";
                    break;
                }

                // Create return message
                string to   = message.data.payload.to[0].phone_number;
                string from = message.data.payload.from.phone_number;
                TelnyxConfiguration.SetApiKey(TELNYX_API_KEY);
                NewMessagingSenderId options = new NewMessagingSenderId
                {
                    From = to,
                    To   = from,
                    Text = responseText
                };

                // Send message back to sender
                MessagingSenderIdService service = new MessagingSenderIdService();
                try
                {
                    MessagingSenderId messageResponse = await service.CreateAsync(options);

                    Logger.LogInformation($"Sent message with ID: {messageResponse.Id}");
                }
                catch (TelnyxException ex)
                {
                    Logger.LogInformation(ex.Message);
                }
            }

            return(Ok());
        }
        public MessagingSenderIdServiceTest(MockHttpClientFixture mockHttpClientFixture)
            : base(mockHttpClientFixture)
        {
            this.service = new MessagingSenderIdService();

            this.sendMessageOptions = new NewMessagingSenderId
            {
                From = "+18665552368", // alphanumeric sender id
                To   = "+18665552367",
                Text = "Hello, World!",
                MessagingProfileId = Guid.NewGuid(),
                Subject            = "Subject",
                MediaUrls          = new List <string> {
                    "url1", "url2"
                },
                WebhookUrl         = "webhookUrl",
                WebhookFailoverUrl = "failureUrl",
                UseProfileWebhooks = true,
                AutoDetect         = true,
            };

            this.sendMessageUsingNumberPoolOptions = new NewMessagingSenderId
            {
                MessagingProfileId = new Guid("dd50eba1-a0c0-4563-9925-b25e842a7cb6"),
                From      = "+18665552368",
                To        = "+18005550199",
                Text      = "Hello, World!",
                Subject   = "Subject",
                MediaUrls = new List <string> {
                    "url1", "url2"
                },
                WebhookUrl         = "webhookUrl",
                WebhookFailoverUrl = "failureUrl",
                UseProfileWebhooks = false
            };

            this.requestOptions = new RequestOptions();

            this.cancellationToken = default(CancellationToken);
        }