/// <summary>
 /// Send an USSD over OneAPI to one mobile terminal
 /// </summary>
 /// <param name="address"></param>
 /// <param name="message"></param>
 /// <returns> InboundSMSMessage </returns>
 public InboundSMSMessage SendMessage(String address, String message)
 {
     RequestData requestData = new RequestData(USSD_URL_BASE, Method.POST);
     requestData.FormParams = new USSDRequest(address, message);
     requestData.ContentType = RequestData.JSON_CONTENT_TYPE;
     return ExecuteMethod<InboundSMSMessage>(requestData);
 }
 /// <summary>
 /// Add funds to (top-up) reseller client/subaccount </summary>
 /// </summary>
 /// <returns> int </returns>
 public AddClientFundsResponse AddClientFunds(string currencyCode, string accountKey, string description, decimal ammount)
 {
     AddClientFundsRequest request = new AddClientFundsRequest(currencyCode, accountKey, description, ammount);
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/payments/funds", Method.POST, request);
     requestData.ContentType = RequestData.JSON_CONTENT_TYPE;
     return ExecuteMethod<AddClientFundsResponse>(requestData);
 }
 /// <summary>
 /// User Login </summary>
 /// <returns> LoginResponse </returns>
 public LoginResponse Login()
 {
     LoginRequest loginRequest = new LoginRequest(Configuration.Authentication.Username, Configuration.Authentication.Password);
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/login", Method.POST, "login", loginRequest);
     LoginResponse loginResponse = ExecuteMethod<LoginResponse>(requestData);
     onLogin(loginResponse);
     return loginResponse;
 }
        /// <summary>
        /// Gets the given GSM number's informations
        /// </summary>
        /// <param name="gsmNumber">The GSM number</param>
        /// <returns>NumberInfo</returns>
        public NumberInfo ResolveMSISDN(string gsmNumber)
        {
            StringBuilder sb = new StringBuilder(NETWORKS_URL_BASE);
            sb.Append("/resolve").Append("/").Append(gsmNumber);

            RequestData requestData = new RequestData(sb.ToString(), Method.POST);
            return ExecuteMethod<NumberInfo>(requestData);
        }
        /// <summary>
        /// Get specific user customer profile by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns> CustomerProfile </returns>
        public CustomerProfile GetCustomerProfileByUserId(int id)
        {
            StringBuilder urlBuilder = new StringBuilder(CUSTOMER_PROFILE_URL_BASE).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(id.ToString()));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET);
            return ExecuteMethod<CustomerProfile>(requestData);
        }
        /// <summary>
        /// Get delivery notifications subscriptions by sender address </summary>
        /// <param name="senderAddress"> </param>
        /// <returns> DeliveryReportSubscription[] </returns>
        public DeliveryReportSubscription[] GetDeliveryNotificationsSubscriptionsBySender(string senderAddress)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(senderAddress));
            urlBuilder.Append("/subscriptions");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "deliveryReceiptSubscriptions");
            return ExecuteMethod<DeliveryReportSubscription[]>(requestData);
        }
 /// <summary>
 /// Get logged user account balance </summary>
 /// </summary>
 /// <returns> AccountBalance </returns>
 public AccountBalance GetAccountBalance()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/balance", Method.GET);
     return ExecuteMethod<AccountBalance>(requestData);
 }
 /// <summary>
 /// Start subscribing to notifications of SMS messages sent to your application over OneAPI </summary>
 /// <param name="subscribeToInboundMessagesRequest"> (mandatory) contains inbound messages subscription data </param>
 /// <returns>string - Subscription Id </returns>
 public string SubscribeToInboundMessagesNotifications(SubscribeToInboundMessagesRequest subscribeToInboundMessagesRequest)
 {
     RequestData requestData = new RequestData(SMS_MESSAGING_INBOUND_URL_BASE + "/subscriptions", Method.POST, "resourceReference", subscribeToInboundMessagesRequest);
     ResourceReference resourceReference = ExecuteMethod<ResourceReference>(requestData);
     return GetIdFromResourceUrl(resourceReference.ResourceURL);
 }
 /// <summary>
 /// User Logout </summary>
 public void Logout()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/logout", Method.POST);
     ExecuteMethod(requestData);
     onLogout();
 }
 /// <summary>
 /// Gets an array of Networks
 /// </summary>
 /// <returns>Network[]</returns>
 public Network[] GetNetworks()
 {
     RequestData requestData = new RequestData(NETWORKS_URL_BASE, Method.GET, "networks");
     return ExecuteMethod<Network[]>(requestData);
 }
        /// <summary>
        /// Get delivery reports asynchronously by Request Id </summary>
        /// <param name="requestId"> </param>
        /// <param name="limit"> </param>
        /// <param name="callback"> (mandatory) method to call after receiving delivery reports </param>
        public void GetDeliveryReportsByRequestIdAsync(string requestId, int limit, Action<DeliveryReportList, RequestException> callback)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/requests/");
            urlBuilder.Append(HttpUtility.UrlEncode(requestId));
            urlBuilder.Append("/deliveryReports");
            urlBuilder.Append("?limit=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(limit)));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET);
            ExecuteMethodAsync<DeliveryReportList>(requestData, callback);
        }
        /// <summary>
        /// Stop subscribing to message receipt notifications for all your received SMS over OneAPI </summary>
        /// <param name="subscriptionId"> (mandatory) contains the subscriptionId of a previously created SMS message receipt subscription </param>
        public void RemoveInboundMessagesNotificationsSubscription(string subscriptionId)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_INBOUND_URL_BASE)).Append("/subscriptions/");
            urlBuilder.Append(HttpUtility.UrlEncode(subscriptionId));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.DELETE);
            ExecuteMethod(requestData);
        }
 /// <summary>
 /// Get logged user customer profiles list </summary>
 /// </summary>
 /// <returns> CustomerProfile[] </returns>
 public CustomerProfile[] GetCustomerProfiles()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/all", Method.GET);
     CustomerProfileArrayWrapper wrapped = ExecuteMethod<CustomerProfileArrayWrapper>(requestData);
     return wrapped.profiles;
 }
        /// <summary>
        /// Query the delivery status over OneAPI for an SMS sent to one or more mobile terminals </summary>
        /// <param name="senderAddress"> (mandatory) is the address from which SMS messages are being sent. Do not URL encode this value prior to passing to this function </param>
        /// <param name="requestId"> (mandatory) contains the requestId returned from a previous call to the sendSMS function </param>
        /// <returns> DeliveryInfoList </returns>
        public DeliveryInfoList QueryDeliveryStatus(string senderAddress, string requestId)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(senderAddress));
            urlBuilder.Append("/requests/");
            urlBuilder.Append(HttpUtility.UrlEncode(requestId));
            urlBuilder.Append("/deliveryInfos");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "deliveryInfoList");
            return ExecuteMethod<DeliveryInfoList>(requestData);
        }
        /// <summary>
        /// Query the delivery status asynchronously over OneAPI for an SMS sent to one or more mobile terminals </summary>
        /// <param name="senderAddress"> (mandatory) is the address from which SMS messages are being sent. Do not URL encode this value prior to passing to this function </param>
        /// <param name="requestId"> (mandatory) contains the requestId returned from a previous call to the sendSMS function </param>
        /// <param name="callback"> (mandatory) method to call after receiving delivery status </param>
        public void QueryDeliveryStatusAsync(string senderAddress, string requestId, Action<DeliveryInfoList, RequestException> callback)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(senderAddress));
            urlBuilder.Append("/requests/");
            urlBuilder.Append(HttpUtility.UrlEncode(requestId));
            urlBuilder.Append("/deliveryInfos");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "deliveryInfoList");
            ExecuteMethodAsync<DeliveryInfoList>(requestData, callback);
        }
        /// <summary>
        /// Get inbound messages notifications subscriptions for the current user </summary>
        /// <returns> MoSubscription[] </returns>
        public MoSubscription[] GetInboundMessagesNotificationsSubscriptions(int page, int pageSize)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_INBOUND_URL_BASE)).Append("/subscriptions");
            urlBuilder.Append("?page=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(page)));
            urlBuilder.Append("&pageSize=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(pageSize)));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "subscriptions");
            return ExecuteMethod<MoSubscription[]>(requestData);
        }
        /// <summary>
        /// Get asynchronously SMS messages sent to your Web application over OneAPI </summary>
        /// <param name="maxBatchSize"> (optional) is the maximum number of messages to get in this request </param>
        /// <param name="callback"> (mandatory) method to call after receiving inbound messages </param>
        public void GetInboundMessagesAsync(int maxBatchSize, Action<InboundSMSMessageList, RequestException> callback)
        {
            //Registration ID is obsolete so any string can be put: e.g. INBOUND
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_INBOUND_URL_BASE)).Append("/registrations/INBOUND/messages");
            urlBuilder.Append("?maxBatchSize=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(maxBatchSize)));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "inboundSMSMessageList");
            ExecuteMethodAsync<InboundSMSMessageList>(requestData, callback);
        }
        /// <summary>
        /// Get SMS messages sent to your Web application over OneAPI </summary>
        /// <param name="maxBatchSize"> (optional) is the maximum number of messages to get in this request </param>
        /// <returns> InboundSMSMessageList </returns>
        public InboundSMSMessageList GetInboundMessages(int maxBatchSize)
        {
            //Registration ID is obsolete so any string can be put: e.g. INBOUND
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_INBOUND_URL_BASE)).Append("/registrations/INBOUND/messages");
            urlBuilder.Append("?maxBatchSize=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(maxBatchSize)));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET, "inboundSMSMessageList");
            return ExecuteMethod<InboundSMSMessageList>(requestData);
        }
 /// <summary>
 /// Get all reseller clients/subaccounts </summary>
 /// </summary>
 /// <returns> CustomerProfileList </returns>
 public CustomerProfile[] GetClients()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/account/clients", Method.GET);
     return ExecuteMethod<CustomerProfileList>(requestData).Clients;
 }
 /// <summary>
 /// Gets the given GSM numbers's informations
 /// </summary>
 /// <param name="gsmNumbers"></param>
 /// <returns></returns>
 public NumberInfo[] ResolveMSISDNs(List<string> gsmNumbers)
 {
     RequestData requestData = new RequestData(NETWORKS_URL_BASE + "/resolve", Method.POST, gsmNumbers);
     requestData.ContentType = RequestData.JSON_CONTENT_TYPE;
     return ExecuteMethod<NumberInfo[]>(requestData);
 }
 /// <summary>
 /// Get logged user customer profile </summary>
 /// <returns> CustomerProfile </returns>
 public CustomerProfile GetCustomerProfile()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE, Method.GET);
     return ExecuteMethod<CustomerProfile>(requestData);
 }
 /// <summary>
 /// Get logged user customer profiles list </summary>
 /// </summary>
 /// <returns> CustomerProfile[] </returns>
 public CustomerProfile[] GetCustomerProfiles()
 {
     RequestData requestData = new RequestData(CUSTOMER_PROFILE_URL_BASE + "/list", Method.GET);
     return ExecuteMethod<CustomerProfile[]>(requestData);
 }
 /// <summary>
 /// Get delivery notifications subscriptions by for the current user </summary>
 /// <returns> DeliveryReportSubscription[] </returns>
 public DeliveryReportSubscription[] GetDeliveryNotificationsSubscriptions()
 {
     RequestData requestData = new RequestData(SMS_MESSAGING_OUTBOUND_URL_BASE + "/subscriptions", Method.GET, "deliveryReceiptSubscriptions");
     return ExecuteMethod<DeliveryReportSubscription[]>(requestData);
 }
        /// <summary>
        /// Start subscribing to delivery status notifications over OneAPI for all your sent SMS </summary>
        /// <param name="subscribeToDeliveryNotificationsRequest"> (mandatory) contains delivery notifications subscription data </param>
        /// <returns> string - Subscription Id  </returns>
        public string SubscribeToDeliveryStatusNotifications(SubscribeToDeliveryNotificationsRequest subscribeToDeliveryNotificationsRequest)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/");

            if (null != subscribeToDeliveryNotificationsRequest.SenderAddress)
            {
                urlBuilder.Append(HttpUtility.UrlEncode(subscribeToDeliveryNotificationsRequest.SenderAddress)).Append("/");
            }
            urlBuilder.Append("subscriptions");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.POST, "deliveryReceiptSubscription", subscribeToDeliveryNotificationsRequest);
            DeliveryReceiptSubscription reliveryReceiptSubscription = ExecuteMethod<DeliveryReceiptSubscription>(requestData);
            return GetIdFromResourceUrl(reliveryReceiptSubscription.ResourceURL);
        }
        //*************************SMSMessagingClientImpl public******************************************************************************************************************************************************
        /// <summary>
        /// Send an SMS over OneAPI to one or more mobile terminals using the customized 'SMS' object </summary>
        /// <param name="sms"> (mandatory) object containing data needed to be filled in order to send the SMS </param>
        /// <returns> SendMessageResult </returns>
        public SendMessageResult SendSMS(SMSRequest smsRequest)
        {
            StringBuilder urlBuilder = new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(smsRequest.SenderAddress));
            urlBuilder.Append("/requests");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.POST, null, smsRequest);
            requestData.ContentType = RequestData.JSON_CONTENT_TYPE;
            return ExecuteMethod<SendMessageResult>(requestData);
        }
        /// <summary>
        /// Get delivery reports by Request Id </summary>
        /// <param name="requestId"> </param>
        /// <param name="limit"> </param>
        /// <returns> DeliveryReportList </returns>
        public DeliveryReportList GetDeliveryReportsByRequestId(string requestId, int limit)
        {
            StringBuilder urlBuilder = (new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE)).Append("/requests/");
            urlBuilder.Append(HttpUtility.UrlEncode(requestId));
            urlBuilder.Append("/deliveryReports");
            urlBuilder.Append("?limit=");
            urlBuilder.Append(HttpUtility.UrlEncode(Convert.ToString(limit)));

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.GET);
            return ExecuteMethod<DeliveryReportList>(requestData);
        }
 /// <summary>
 /// Stop USSD session
 /// </summary>
 /// <param name="address"></param>
 /// <param name="message"></param>
 public void StopSession(String address, String message)
 {
     RequestData requestData = new RequestData(USSD_URL_BASE, Method.POST);
     requestData.FormParams = new USSDRequest(address, message, true);
     ExecuteMethod(requestData);
 }
        /// <summary>
        /// Send an SMS asynchronously over OneAPI to one or more mobile terminals using the customized 'SMS' object </summary>
        /// <param name="sms"> (mandatory) object containing data needed to be filled in order to send the SMS </param>
        /// <param name="callback"> (mandatory) method to call after receiving sent SMS response </param>
        public void SendSMSAsync(SMSRequest smsRequest, System.Action<SendMessageResult, RequestException> callback)
        {
            StringBuilder urlBuilder = new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE).Append("/");
            urlBuilder.Append(HttpUtility.UrlEncode(smsRequest.SenderAddress));
            urlBuilder.Append("/requests");

            RequestData requestData = new RequestData(urlBuilder.ToString(), Method.POST, null, smsRequest);
            requestData.ContentType = RequestData.JSON_CONTENT_TYPE;
            ExecuteMethodAsync<SendMessageResult>(requestData, callback);
        }