public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            smsClient.HlrClient.QueryHLRAsync(address, (roaming, e) =>
            {
                if (e == null)
                {
                    Console.WriteLine(roaming);
                }
                else
                {
                    Console.WriteLine(e.Message);
                }
            });
        }
        private static string notifyUrl = ""; //e.g. "http://127.0.0.1:3001/" 3001=Default port for 'Inbound Messages Notifications' server simulator

        #endregion Fields

        #region Methods

        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Add listener(start push server and wait for the 'Inbound Message Notifications')
            smsClient.SmsMessagingClient.AddPushInboundMessageNotificationsListener(new InboundMessageNotificationsListener((smsMessageList) =>
            {
                // Handle pushed 'Inbound Message Notification'
                Console.WriteLine(smsMessageList);
            }));

            // Store 'Inbound Message Notifications' subscription id because we can later remove subscription with it:
            string subscriptionId = smsClient.SmsMessagingClient.SubscribeToInboundMessagesNotifications(new SubscribeToInboundMessagesRequest(destinationAddress, notifyUrl, criteria, notificationFormat, "", ""));

            // Wait 30 seconds for 'Inbound Message Notification' push-es before removing subscription and closing the server connection
            System.Threading.Thread.Sleep(30000);

            // Remove 'Inbound Message Notifications' subscription
            smsClient.SmsMessagingClient.RemoveInboundMessagesNotificationsSubscription(subscriptionId);

            // Remove 'Inbound Message Notifications' push listeners and stop the server
            smsClient.SmsMessagingClient.RemovePushInboundMessageNotificationsListeners();
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            Console.WriteLine("");
            Console.Write("Currency Code: ");
            string currencyCode = Console.ReadLine();
            Console.Write("Account Key: ");
            string accountKey = Console.ReadLine();
            Console.Write("Description: ");
            string description = Console.ReadLine();
            Console.Write("Ammount: ");
            decimal ammount = Convert.ToDecimal(Console.ReadLine());

            var result = smsClient.CustomerProfileClient.AddClientFunds(currencyCode, accountKey, description, ammount);
            Console.WriteLine(result.ToString());
            Console.WriteLine();
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // example:initialize-sms-client
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));
            SMSClient smsClient = new SMSClient(configuration);
            // ----------------------------------------------------------------------------------------------------

            // example:prepare-message-without-notify-url
            SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress);
            // ----------------------------------------------------------------------------------------------------

            // example:send-message
            // Store request id because we can later query for the delivery status with it:
            SendMessageResult sendMessageResult = smsClient.SmsMessagingClient.SendSMS(smsRequest);
            // ----------------------------------------------------------------------------------------------------

            // Few seconds later we can check for the sending status
            System.Threading.Thread.Sleep(10000);

            // example:query-for-delivery-status
            DeliveryInfoList deliveryInfoList = smsClient.SmsMessagingClient.QueryDeliveryStatus(senderAddress, sendMessageResult.ClientCorrelator);
            string deliveryStatus = deliveryInfoList.DeliveryInfos[0].DeliveryStatus;
            // ----------------------------------------------------------------------------------------------------
            Console.WriteLine(deliveryStatus);
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                              System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress);
            smsRequest.Language = new Language(LanguageCode.Default);

            // smsRequest.Language = new Language(LanguageCode.Turkish, true, false);

            smsClient.SmsMessagingClient.SendSMSAsync(smsRequest, (sendMessageResult, e) =>
            {
                if (e == null)
                {
                    Console.WriteLine(sendMessageResult);
                }
                else
                {
                    Console.WriteLine(e.Message);
                }
            });
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Add listener(start retriever and pull 'Inbound Messages')
            smsClient.SmsMessagingClient.AddPullInboundMessageListener(new InboundMessageListener((smsMessageList, e) =>
            {
                // Handle pulled 'Inbound Messages'
                if (e == null)
                {
                    Console.WriteLine(smsMessageList);
                }
                else
                {
                    Console.WriteLine(e.Message);
                }
            }));

            // Wait 30 seconds for the 'Inbound Messages' before stop the retriever
            System.Threading.Thread.Sleep(30000);

            // Remove 'Inbound Messages' pull listeners and stop the retriever
            smsClient.SmsMessagingClient.RemovePullInboundMessageListeners();
        }
        public static void Execute()
        {
            Configuration configuration = new Configuration();
            SMSClient smsClient = new SMSClient(configuration);

            // example:on-mo
            InboundSMSMessageList inboundSMSMessageList = smsClient.SmsMessagingClient.ConvertJsonToInboundSMSMessageNotification(JSON);
            // ----------------------------------------------------------------------------------------------------
            Console.WriteLine(inboundSMSMessageList);
        }
        public static void Execute()
        {
            Configuration configuration = new Configuration();
            SMSClient smsClient = new SMSClient(configuration);

            // example:on-delivery-notification
            DeliveryInfoNotification deliveryInfoNotification = smsClient.SmsMessagingClient.ConvertJsonToDeliveryInfoNotification(JSON);
            // ----------------------------------------------------------------------------------------------------
            Console.WriteLine(deliveryInfoNotification);
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(username, password);

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            try
            {
                // Login sms client
                LoginResponse loginResponse = smsClient.CustomerProfileClient.Login();
                if (loginResponse.Verified == false)
                {
                    Console.WriteLine("User is not verified!");
                    return;
                }
            }
            catch (RequestException e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            // Send SMS
            smsClient.SmsMessagingClient.SendSMSAsync(new SMSRequest(senderAddress, message, recipientAddress), (requestId, e) =>
            {
                if (e == null)
                {
                    // Get 'Delivery Reports'
                    smsClient.SmsMessagingClient.GetDeliveryReportsAsync((deliveryReportList, e1) =>
                    {
                        if (e1 == null)
                        {
                            Console.WriteLine(deliveryReportList);

                            // Logout sms client
                            smsClient.CustomerProfileClient.Logout();
                        }
                        else
                        {
                            Console.WriteLine(e1.Message);
                        }
                    });
                }
                else
                {
                    Console.WriteLine(e.Message);
                }
            });
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));
            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            CustomerProfile[] customerProfiles = smsClient.CustomerProfileClient.GetClients();
            Console.WriteLine(string.Join("Customer Profile: ", customerProfiles.Select<CustomerProfile, string>(cProfile => cProfile != null ? cProfile.ToString() : "{}").ToArray()));
            Console.WriteLine();
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            smsClient.CustomerProfileClient.Logout();
            Console.WriteLine("Logout success.");
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // example:retrieve-inbound-messages
            InboundSMSMessageList inboundSMSMessageList = smsClient.SmsMessagingClient.GetInboundMessages();
            // ----------------------------------------------------------------------------------------------------
            Console.WriteLine(inboundSMSMessageList);
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Querry for networks
            NumberInfo numberInfo = smsClient.NetworksClient.ResolveMSISDN(gsmNumber);

            // Write reposonse
            Console.WriteLine(numberInfo);
        }
Beispiel #14
0
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Querry for networks
            Network[] networks = smsClient.NetworksClient.GetNetworks();

            // Write response
            Console.WriteLine(string.Join("Network: ", networks.Select<Network, string>(network => network !=null ? network.ToString(): "{}").ToArray()));
            Console.WriteLine();
        }
        private static string notifyUrl = ""; //e.g. "http://127.0.0.1:3002/" 3002=Default port for 'HLR Notifications' server simulator

        #endregion Fields

        #region Methods

        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            try
            {
                // Initialize Configuration object
                Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                                System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

                // Initialize SMSClient using the Configuration object
                SMSClient smsClient = new SMSClient(configuration);

                // Add listener(start push server and wait for the 'HLR Notifications')
                smsClient.HlrClient.AddPushHLRNotificationsListener(new HLRNotificationsListener((roamingNotification) =>
                {
                    // Handle pushed 'HLR Notification'
                    if (roamingNotification != null)
                    {
                        Console.WriteLine(roamingNotification);
                    }
                }));

                // example:retrieve-roaming-status-with-notify-url
                smsClient.HlrClient.QueryHLR(address, notifyUrl);
                // ----------------------------------------------------------------------------------------------------

                // Wait 30 seconds for 'HLR Notification' push-es before closing the server connection
                System.Threading.Thread.Sleep(30000);

                // Remove 'HLR Notification' push listeners and stop the server
                smsClient.HlrClient.RemovePushHLRNotificationsListeners();
            }
            catch (RequestException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Add listener(start push server and wait for the 'Delivery Info Notifications')
            smsClient.SmsMessagingClient.AddPushDeliveryStatusNotificationsListener(new DeliveryStatusNotificationsListener((deliveryInfoNotification) =>
            {
                // Handle pushed 'Delivery Info Notification'
                if (deliveryInfoNotification != null)
                {
                    string deliveryStatus = deliveryInfoNotification.DeliveryInfo.DeliveryStatus;
                    Console.WriteLine(deliveryStatus);
                }
            }));

            // example:prepare-message-with-notify-url
            SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress);
            // The url where the delivery notification will be pushed:
            smsRequest.NotifyURL = notifyUrl;
            // ----------------------------------------------------------------------------------------------------

            // Send SMS
            smsClient.SmsMessagingClient.SendSMS(smsRequest);

            // Wait 30 seconds for 'Delivery Info Notification' push-es before closing the server connection
            System.Threading.Thread.Sleep(30000);

            // Remove 'Delivery Info Notifications' push listeners and stop the server
            smsClient.SmsMessagingClient.RemovePushDeliveryStatusNotificationsListeners();
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            string[] address = new string[2];
            address[0] = recipientAddress;
            address[1] = recipientAddress;

            SMSRequest smsRequest = new SMSRequest(senderAddress, message, address);

            SendMessageResult sendMessageResult = smsClient.SmsMessagingClient.SendSMS(smsRequest);
            Console.WriteLine(sendMessageResult);
        }
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            // Send SMS
            smsClient.SmsMessagingClient.SendSMS(new SMSRequest(senderAddress, message, recipientAddress));

            // Wait for 30 seconds to give enought time for the message to be delivered
            System.Threading.Thread.Sleep(30000);

            // Get 'Delivery Reports'
            DeliveryReportList deliveryReportList = smsClient.SmsMessagingClient.GetDeliveryReports();
            Console.WriteLine(deliveryReportList);
        }
Beispiel #19
0
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            try
            {
                // example:data-connection-client
                Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                                System.Configuration.ConfigurationManager.AppSettings.Get("Password"));
                SMSClient smsClient = new SMSClient(configuration);
                // ----------------------------------------------------------------------------------------------------

                // example:retrieve-roaming-status
                Roaming roaming = smsClient.HlrClient.QueryHLR(address);
                // ----------------------------------------------------------------------------------------------------
                Console.WriteLine(roaming);
            }
            catch (RequestException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #20
0
        public static void Execute()
        {
            // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example)
            // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration
            XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config"));

            // Initialize Configuration object
            Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"),
                                                            System.Configuration.ConfigurationManager.AppSettings.Get("Password"));

            // Initialize SMSClient using the Configuration object
            SMSClient smsClient = new SMSClient(configuration);

            String response = null;
            while (response == null || !"1".Equals(response))
            {
                // Send USSD and wait for the answer
                InboundSMSMessage inboundMessage = smsClient.UssdClient.SendMessage(destination, message);
                response = inboundMessage.Message;
            }

            // Send message and stop USSD session
            smsClient.UssdClient.StopSession(destination, "Cool");
        }