/// <summary>
        /// Here you can experiment with initiating a conference call through Ytel and view the request response generated when doing so.
        /// </summary>
        /// <param name="url">Required parameter: URL requested once the conference connects</param>
        /// <param name="mfrom">Required parameter: A valid 10-digit number (E.164 format) that will be initiating the conference call.</param>
        /// <param name="to">Required parameter: A valid 10-digit number (E.164 format) that is to receive the conference call.</param>
        /// <param name="method">Optional parameter: Specifies the HTTP method used to request the required URL once call connects.</param>
        /// <param name="statusCallBackUrl">Optional parameter: URL that can be requested to receive notification when call has ended. A set of default parameters will be sent here once the conference is finished.</param>
        /// <param name="statusCallBackMethod">Optional parameter: Specifies the HTTP methodlinkclass used to request StatusCallbackUrl.</param>
        /// <param name="fallbackUrl">Optional parameter: URL requested if the initial Url parameter fails or encounters an error</param>
        /// <param name="fallbackMethod">Optional parameter: Specifies the HTTP method used to request the required FallbackUrl once call connects.</param>
        /// <param name="record">Optional parameter: Specifies if the conference should be recorded.</param>
        /// <param name="recordCallBackUrl">Optional parameter: Recording parameters will be sent here upon completion.</param>
        /// <param name="recordCallBackMethod">Optional parameter: Specifies the HTTP method used to request the required URL once conference connects.</param>
        /// <param name="scheduleTime">Optional parameter: Schedule conference in future. Schedule time must be greater than current time</param>
        /// <param name="timeout">Optional parameter: The number of seconds the call stays on the line while waiting for an answer. The max time limit is 999 and the default limit is 60 seconds but lower times can be set.</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> CreateConferenceAsync(
            string url,
            string mfrom,
            string to,
            string method               = null,
            string statusCallBackUrl    = null,
            string statusCallBackMethod = null,
            string fallbackUrl          = null,
            string fallbackMethod       = null,
            bool?record = null,
            string recordCallBackUrl    = null,
            string recordCallBackMethod = null,
            string scheduleTime         = null,
            int?timeout = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/conferences/createConference.json");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "Url", url }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" }
            };

            //append form/field parameters
            var _fields = new List <KeyValuePair <string, Object> >()
            {
                new KeyValuePair <string, object>("From", mfrom),
                new KeyValuePair <string, object>("To", to),
                new KeyValuePair <string, object>("Method", method),
                new KeyValuePair <string, object>("StatusCallBackUrl", statusCallBackUrl),
                new KeyValuePair <string, object>("StatusCallBackMethod", statusCallBackMethod),
                new KeyValuePair <string, object>("FallbackUrl", fallbackUrl),
                new KeyValuePair <string, object>("FallbackMethod", fallbackMethod),
                new KeyValuePair <string, object>("Record", record),
                new KeyValuePair <string, object>("RecordCallBackUrl", recordCallBackUrl),
                new KeyValuePair <string, object>("RecordCallBackMethod", recordCallBackMethod),
                new KeyValuePair <string, object>("ScheduleTime", scheduleTime),
                new KeyValuePair <string, object>("Timeout", timeout)
            };

            //remove null parameters
            _fields = _fields.Where(kvp => kvp.Value != null).ToList();

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Post(_queryUrl, _headers, _fields, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Beispiel #2
0
        /// <summary>
        /// WAF Log Info
        /// </summary>
        /// <param name="Models.LoggingInfoInput">Object containing request parameters</param>
        /// <return>Returns the Models.LoggingLogsModelResponse response from the API call</return>
        public async Task <Models.LoggingLogsModelResponse> LoggingInfoAsync(Models.LoggingInfoInput input)
        {
            //validating required parameters
            if (null == input.Name)
            {
                throw new ArgumentNullException("name", "The property \"Name\" in the input object cannot be null.");
            }

            if (null == input.Origin)
            {
                throw new ArgumentNullException("origin", "The property \"Origin\" in the input object cannot be null.");
            }

            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI(Configuration.Servers.PATH);

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/s/l/i");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "name", input.Name },
                { "origin", input.Origin },
                { "time", input.Time }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "SMASH" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //Custom Authentication to be added for authorization
            AuthUtility.AppendCustomAuthParams(_request);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.LoggingLogsModelResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Gets Similar Users
        /// </summary>
        /// <param name="query">Required parameter: Query for similar users.</param>
        /// <return>Returns the Models.UsersResponse response from the API call</return>
        public async Task <Models.UsersResponse> GetSimilarUsersAsync(Models.GetSimilarUsersBody query)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/v1/similar/users");


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "SUGGESTGRID" },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" }
            };

            //append body params
            var _body = APIHelper.JsonSerialize(query);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.PostBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 400)
            {
                throw new ErrorResponseException(@"Request body is invalid.", _context);
            }

            if (_response.StatusCode == 404)
            {
                throw new ErrorResponseException(@"At least one type in the request does not exist.", _context);
            }

            if (_response.StatusCode == 422)
            {
                throw new ErrorResponseException(@"Required parameters are missing.", _context);
            }

            if ((_response.StatusCode < 200) || (_response.StatusCode > 208)) //[200,208] = HTTP OK
            {
                throw new ErrorResponseException(@"Unexpected internal error.", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.UsersResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Update properties for a Ytel number that has been purchased for your account. Refer to the parameters list for the list of properties that can be updated.
        /// </summary>
        /// <param name="phoneNumber">Required parameter: A valid Ytel number (E.164 format).</param>
        /// <param name="voiceUrl">Required parameter: URL requested once the call connects</param>
        /// <param name="friendlyName">Optional parameter: Phone number friendly name description</param>
        /// <param name="voiceMethod">Optional parameter: Post or Get</param>
        /// <param name="voiceFallbackUrl">Optional parameter: URL requested if the voice URL is not available</param>
        /// <param name="voiceFallbackMethod">Optional parameter: Post or Get</param>
        /// <param name="hangupCallback">Optional parameter: callback url after a hangup occurs</param>
        /// <param name="hangupCallbackMethod">Optional parameter: Post or Get</param>
        /// <param name="heartbeatUrl">Optional parameter: URL requested once the call connects</param>
        /// <param name="heartbeatMethod">Optional parameter: URL that can be requested every 60 seconds during the call to notify of elapsed time</param>
        /// <param name="smsUrl">Optional parameter: URL requested when an SMS is received</param>
        /// <param name="smsMethod">Optional parameter: Post or Get</param>
        /// <param name="smsFallbackUrl">Optional parameter: URL used if any errors occur during execution of InboundXML from an SMS or at initial request of the SmsUrl.</param>
        /// <param name="smsFallbackMethod">Optional parameter: The HTTP method Ytel will use when URL requested if the SmsUrl is not available.</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> UpdateNumberAsync(
            string phoneNumber,
            string voiceUrl,
            string friendlyName         = null,
            string voiceMethod          = null,
            string voiceFallbackUrl     = null,
            string voiceFallbackMethod  = null,
            string hangupCallback       = null,
            string hangupCallbackMethod = null,
            string heartbeatUrl         = null,
            string heartbeatMethod      = null,
            string smsUrl            = null,
            string smsMethod         = null,
            string smsFallbackUrl    = null,
            string smsFallbackMethod = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/incomingphone/updatenumber.json");


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" }
            };

            //append form/field parameters
            var _fields = new List <KeyValuePair <string, Object> >()
            {
                new KeyValuePair <string, object>("PhoneNumber", phoneNumber),
                new KeyValuePair <string, object>("VoiceUrl", voiceUrl),
                new KeyValuePair <string, object>("FriendlyName", friendlyName),
                new KeyValuePair <string, object>("VoiceMethod", voiceMethod),
                new KeyValuePair <string, object>("VoiceFallbackUrl", voiceFallbackUrl),
                new KeyValuePair <string, object>("VoiceFallbackMethod", voiceFallbackMethod),
                new KeyValuePair <string, object>("HangupCallback", hangupCallback),
                new KeyValuePair <string, object>("HangupCallbackMethod", hangupCallbackMethod),
                new KeyValuePair <string, object>("HeartbeatUrl", heartbeatUrl),
                new KeyValuePair <string, object>("HeartbeatMethod", heartbeatMethod),
                new KeyValuePair <string, object>("SmsUrl", smsUrl),
                new KeyValuePair <string, object>("SmsMethod", smsMethod),
                new KeyValuePair <string, object>("SmsFallbackUrl", smsFallbackUrl),
                new KeyValuePair <string, object>("SmsFallbackMethod", smsFallbackMethod)
            };

            //remove null parameters
            _fields = _fields.Where(kvp => kvp.Value != null).ToList();

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Post(_queryUrl, _headers, _fields, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Create a new OAuth 2 token.
        /// </summary>
        /// <param name="Models.CreateRequestTokenInput">Object containing request parameters</param>
        /// <param name="fieldParameters">Additional optional form parameters are supported by this endpoint</param>
        /// <return>Returns the Models.OAuthToken response from the API call</return>
        public async Task <Models.OAuthToken> CreateRequestTokenAsync(Models.CreateRequestTokenInput input, Dictionary <string, object> fieldParameters = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/iisadasdjadasodisd0-2394-023jalskasdasd");


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" },
                { "accept", "application/json" },
                { "Authorization", input.Authorization }
            };

            _headers.Add("gfdsfkl", Configuration.Gfdsfkl);
            _headers.Add("dsfsdf", Configuration.Dsfsdf);

            //append form/field parameters
            var _fields = new List <KeyValuePair <string, Object> >()
            {
                new KeyValuePair <string, object>("grant_type", "password"),
                new KeyValuePair <string, object>("username", input.Username),
                new KeyValuePair <string, object>("password", input.Password),
                new KeyValuePair <string, object>("scope", input.Scope)
            };

            //optional form parameters
            _fields.AddRange(APIHelper.PrepareFormFieldsFromObject("", fieldParameters, arrayDeserializationFormat: ArrayDeserializationFormat));
            //remove null parameters
            _fields = _fields.Where(kvp => kvp.Value != null).ToList();

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Post(_queryUrl, _headers, _fields);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 400)
            {
                throw new OAuthProviderException(@"OAuth 2 provider returned an error.", _context);
            }

            if (_response.StatusCode == 401)
            {
                throw new OAuthProviderException(@"OAuth 2 provider says client authentication failed.", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.OAuthToken>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Lists all charges
        /// </summary>
        /// <param name="page">Optional parameter: Page number</param>
        /// <param name="size">Optional parameter: Page size</param>
        /// <param name="code">Optional parameter: Filter for charge's code</param>
        /// <param name="status">Optional parameter: Filter for charge's status</param>
        /// <param name="paymentMethod">Optional parameter: Filter for charge's payment method</param>
        /// <param name="customerId">Optional parameter: Filter for charge's customer id</param>
        /// <param name="orderId">Optional parameter: Filter for charge's order id</param>
        /// <param name="createdSince">Optional parameter: Filter for the beginning of the range for charge's creation</param>
        /// <param name="createdUntil">Optional parameter: Filter for the end of the range for charge's creation</param>
        /// <return>Returns the Models.ListChargesResponse response from the API call</return>
        public async Task <Models.ListChargesResponse> GetChargesAsync(
            int?page              = null,
            int?size              = null,
            string code           = null,
            string status         = null,
            string paymentMethod  = null,
            string customerId     = null,
            string orderId        = null,
            DateTime?createdSince = null,
            DateTime?createdUntil = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/charges");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "page", page },
                { "size", size },
                { "code", code },
                { "status", status },
                { "payment_method", paymentMethod },
                { "customer_id", customerId },
                { "order_id", orderId },
                { "created_since", (createdSince.HasValue) ? createdSince.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") : null },
                { "created_until", (createdUntil.HasValue) ? createdUntil.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") : null }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "MundiSDK - DotNet 2.3.0" },
                { "accept", "application/json" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.ListChargesResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Edit your dedicated virtual number options.
        /// </summary>
        /// <param name="number">Required parameter: The dedicated virtual number.</param>
        /// <param name="format">Required parameter: Response format e.g. json or xml</param>
        /// <param name="forwardEmail">Optional parameter: Forward incoming messages to a set of email addresses.</param>
        /// <param name="forwardSms">Optional parameter: Forward incoming messages to a set of mobile numbers.</param>
        /// <param name="forwardUrl">Optional parameter: Forward incoming messages to a URL.</param>
        /// <param name="listId">Optional parameter: Add new numbers that message in to this list.</param>
        /// <param name="welcomeMessage">Optional parameter: Auto-response for all messages received.</param>
        /// <param name="membersMessage">Optional parameter: Auto-response if the number is already on the list. (must be adding the number to a list)</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> EditNumberOptionsAsync(
            string number,
            string format,
            string forwardEmail   = null,
            string forwardSms     = null,
            string forwardUrl     = null,
            string listId         = null,
            string welcomeMessage = null,
            string membersMessage = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/edit-number-options.{format}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "format", format }
            });

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "number", number },
                { "forward_email", forwardEmail },
                { "forward_sms", forwardSms },
                { "forward_url", forwardUrl },
                { "list_id", listId },
                { "welcome_message", welcomeMessage },
                { "members_message", membersMessage }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" },
                { "accept", "application/json" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers, Configuration.Apikey, Configuration.Apisecret);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <dynamic>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// lets you update credentials and credit type of a subaccount.
        /// </summary>
        /// <param name="body">Required parameter: Update sub account</param>
        /// <return>Returns the object response from the API call</return>
        public async Task <object> CreateSubaccountsUpdateSubaccountPOSTAsync(Models.UpdateSubaccount body)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/subaccounts/updateSubaccount");


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" },
                { "content-type", "application/json; charset=utf-8" }
            };

            _headers.Add("api_key", Configuration.ApiKey);

            //append body params
            var _body = APIHelper.JsonSerialize(body);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.PostBody(_queryUrl, _headers, _body);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 400)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 401)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 403)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 405)
            {
                throw new APIException(@"Invalid input", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Get the documents of a ticket related to the intervention (No invoice, no quote)
        /// </summary>
        /// <param name="ticketId">Required parameter: Example: </param>
        /// <return>Returns the List<Document> response from the API call</return>
        public async Task <List <Document> > DocumentsAsync(string ticketId)
        {
            //validating required parameters
            if (null == ticketId)
            {
                throw new ArgumentNullException("ticketId", "The parameter \"ticketId\" is a required parameter and cannot be null.");
            }

            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/tickets/{ticket_id}/documents");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "ticket_id", ticketId }
            });


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" },
                { "accept", "application/json" }
            };

            _headers.Add("X-API-TOKEN", Configuration.XAPITOKEN);
            _headers.Add("X-API-EMAIL", Configuration.XAPIEMAIL);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //Custom Authentication to be added for authorization
            AuthUtility.AppendCustomAuthParams(_request);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <List <Document> >(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Return the details of the sender name.
        /// </summary>
        /// <param name="id">Required parameter: The sender id you want its details</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetSenderNameDetailsAsync(string id)
        {
            //validating required parameters
            if (null == id)
            {
                throw new ArgumentNullException("id", "The parameter \"id\" is a required parameter and cannot be null.");
            }

            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/sender/view/");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "id", id }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "Releans" },
                { "accept", "application/json" }
            };

            _headers.Add("Authorization", string.Format("Bearer {0}", Configuration.OAuthAccessToken));

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <dynamic>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Browser bot can extract content, interact with keyboard and mouse events, and execute JavaScript on a website. See: https://www.neutrinoapi.com/api/browser-bot/
        /// </summary>
        /// <param name="url">Required parameter: The URL to load</param>
        /// <param name="timeout">Optional parameter: Timeout in seconds. Give up if still trying to load the page after this number of seconds</param>
        /// <param name="delay">Optional parameter: Delay in seconds to wait before executing any selectors or JavaScript</param>
        /// <param name="selector">Optional parameter: Extract content from the page DOM using this selector. Commonly known as a CSS selector, you can find a good reference <a href="https://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a></param>
        /// <param name="exec">Optional parameter: Execute JavaScript on the page. Each array element should contain a valid JavaScript statement in string form. If a statement returns any kind of value it will be returned in the 'exec-results' response.<br/><br/>For your convenience you can also use the following special shortcut functions:<br/><div style='padding-left:32px; font-family:inherit; font-size:inherit;'>sleep(seconds); Just wait/sleep for the specified number of seconds.<br/>click('selector'); Click on the first element matching the given selector.<br/>focus('selector'); Focus on the first element matching the given selector.<br/>keys('characters'); Send the specified keyboard characters. Use click() or focus() first to send keys to a specific element.<br/>enter(); Send the Enter key.<br/>tab(); Send the Tab key.<br/></div><br/>Example:<br/><div style='padding-left:32px; font-family:inherit; font-size:inherit;'>[ "click('#button-id')", "sleep(1)", "click('.field-class')", "keys('1234')", "enter()" ]</div></param>
        /// <param name="userAgent">Optional parameter: Override the browsers default user-agent string with this one</param>
        /// <param name="ignoreCertificateErrors">Optional parameter: Ignore any TLS/SSL certificate errors and load the page anyway</param>
        /// <return>Returns the Models.BrowserBotResponse response from the API call</return>
        public async Task <Models.BrowserBotResponse> BrowserBotAsync(
            string url,
            int?timeout     = 30,
            int?delay       = 2,
            string selector = null,
            List <string> exec,
            string userAgent             = null,
            bool?ignoreCertificateErrors = false)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/browser-bot");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "user-id", Configuration.UserId },
                { "api-key", Configuration.ApiKey }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" },
                { "accept", "application/json" }
            };

            //append form/field parameters
            var _fields = new List <KeyValuePair <string, Object> >()
            {
                new KeyValuePair <string, object>("output-case", "camel"),
                new KeyValuePair <string, object>("url", url),
                new KeyValuePair <string, object>("timeout", (null != timeout) ? timeout : 30),
                new KeyValuePair <string, object>("delay", (null != delay) ? delay : 2),
                new KeyValuePair <string, object>("selector", selector),
                new KeyValuePair <string, object>("user-agent", userAgent),
                new KeyValuePair <string, object>("ignore-certificate-errors", (null != ignoreCertificateErrors) ? ignoreCertificateErrors : false)
            };

            _fields.AddRange(APIHelper.PrepareFormFieldsFromObject("exec", exec, arrayDeserializationFormat: ArrayDeserializationFormat));
            //remove null parameters
            _fields = _fields.Where(kvp => kvp.Value != null).ToList();

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Post(_queryUrl, _headers, _fields);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.BrowserBotResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Update a webhook. You can update individual attributes or all of them by submitting a PATCH request to the /webhooks/messages endpoint (the same endpoint used above to delete a webhook)
        /// A successful request to the retrieve webhook endpoint will return a response body as follows:
        /// ```
        /// {
        ///     "url": "https://webhook.com",
        ///     "method": "POST",
        ///     "id": "04442623-0961-464e-9cbc-ec50804e0413",
        ///     "encoding": "JSON",
        ///     "events": [
        ///         "RECEIVED_SMS"
        ///     ],
        ///     "headers": {},
        ///     "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}"
        /// }
        /// ```
        /// *Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.*
        /// </summary>
        /// <param name="webhookId">Required parameter: Example: </param>
        /// <param name="body">Required parameter: Example: </param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> UpdateWebhookAsync(Guid webhookId, Models.UpdateWebhookRequest body)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/v1/webhooks/messages/{webhookId}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "webhookId", webhookId }
            });


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "messagesmedia-webhooks" },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" }
            };

            //append body params
            var _body = APIHelper.JsonSerialize(body);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.PatchBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 400)
            {
                throw new UpdateWebhook400ResponseException(@"Unexpected error in API call. See HTTP response body for details.", _context);
            }

            if (_response.StatusCode == 404)
            {
                throw new APIException(@"", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <dynamic>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// List All Inbound ShortCode
        /// </summary>
        /// <param name="datecreated">Optional parameter: Only list messages sent with the specified date</param>
        /// <param name="page">Optional parameter: The page count to retrieve from the total results in the collection. Page indexing starts at 1.</param>
        /// <param name="pagesize">Optional parameter: Number of individual resources listed in the response per page</param>
        /// <param name="mfrom">Optional parameter: From Number to Inbound ShortCode</param>
        /// <param name="shortcode">Optional parameter: Only list messages sent to this Short Code</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> CreateListInboundSMSAsync(
            string datecreated = null,
            int?page           = null,
            int?pagesize       = null,
            string mfrom       = null,
            string shortcode   = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/shortcode/getinboundsms.json");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "Datecreated", datecreated }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" }
            };

            //append form/field parameters
            var _fields = new List <KeyValuePair <string, Object> >()
            {
                new KeyValuePair <string, object>("page", page),
                new KeyValuePair <string, object>("pagesize", pagesize),
                new KeyValuePair <string, object>("from", mfrom),
                new KeyValuePair <string, object>("Shortcode", shortcode)
            };

            //remove null parameters
            _fields = _fields.Where(kvp => kvp.Value != null).ToList();

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Post(_queryUrl, _headers, _fields, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Beispiel #14
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="boolean">Required parameter: Example: </param>
        /// <param name="number">Required parameter: Example: </param>
        /// <param name="mstring">Required parameter: Example: </param>
        /// <param name="queryParameters">Additional optional query parameters are supported by this endpoint</param>
        /// <return>Returns the ServerResponse response from the API call</return>
        public async Task <ServerResponse> SimpleQueryAsync(
            bool boolean,
            int number,
            string mstring,
            Dictionary <string, object> queryParameters = null)
        {
            //validating required parameters
            if (null == mstring)
            {
                throw new ArgumentNullException("mstring", "The parameter \"mstring\" is a required parameter and cannot be null.");
            }

            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/query");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "boolean", boolean },
                { "number", number },
                { "string", mstring }
            });

            //append optional parameters to the query
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, queryParameters);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "Stamplay SDK" },
                { "accept", "application/json" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <ServerResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Lets you to retrieve the email transaction logs.
        /// </summary>
        /// <param name="startdate">Required parameter: The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.</param>
        /// <param name="events">Optional parameter: Filter based on different email events. If not passed, all events will be fetched. Multiple comma separated events are allowed</param>
        /// <param name="sort">Optional parameter: Sort based on email sent time</param>
        /// <param name="enddate">Optional parameter: The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD</param>
        /// <param name="offset">Optional parameter: The point in the list to begin retrieving results.</param>
        /// <param name="limit">Optional parameter: The number of results to return.</param>
        /// <param name="subject">Optional parameter: Filter logs based on subject</param>
        /// <param name="xapiheader">Optional parameter: Filter logs based on recipient's email</param>
        /// <param name="fromaddress">Optional parameter: Filter logs based on fromaddress</param>
        /// <param name="email">Optional parameter: Filter logs based on recipient's email</param>
        /// <return>Returns the object response from the API call</return>
        public async Task <object> GetEventsGETAsync(
            DateTime startdate,
            Models.EventsEnum?events = null,
            Models.SortEnum?sort     = null,
            DateTime?enddate         = null,
            int?offset         = 0,
            int?limit          = 10,
            string subject     = null,
            string xapiheader  = null,
            string fromaddress = null,
            string email       = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/events");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "startdate", startdate.ToString("yyyy'-'MM'-'dd") },
                { "events", (events.HasValue) ? Models.EventsEnumHelper.ToValue(events.Value) : null },
                { "sort", (sort.HasValue) ? Models.SortEnumHelper.ToValue(sort.Value) : null },
                { "enddate", (enddate.HasValue) ? enddate.Value.ToString("yyyy'-'MM'-'dd") : null },
                { "offset", (null != offset) ? offset : 0 },
                { "limit", (null != limit) ? limit : 10 },
                { "subject", subject },
                { "xapiheader", xapiheader },
                { "fromaddress", fromaddress },
                { "email", email }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "APIMATIC 2.0" }
            };

            _headers.Add("api_key", Configuration.ApiKey);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 400)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 401)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 403)
            {
                throw new APIException(@"API Response", _context);
            }

            if (_response.StatusCode == 405)
            {
                throw new APIException(@"Invalid input", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }