/// <summary>
        /// Delete the recurring transfer of a savings goal
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="savingsGoalUid">Required parameter: Savings goal uid</param>
        /// <return>Returns the void response from the API call</return>
        public async Task DeleteRecurringTransferAsync(Guid accountUid, Guid savingsGoalUid)
        {
            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/account/{accountUid}/savings-goals/{savingsGoalUid}/recurring-transfer");

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


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetRequestHeaders(true, true);

            //prepare the API call request to fetch the response
            var request = ClientInstance.Delete(queryUrl, headers, null);

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

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);
        }
Exemple #2
0
        /// <summary>
        /// Update an IP Address in the Blacklist
        /// </summary>
        /// <param name="entryId">Required parameter: a unique identifier for the IP Address; opaque but likely a GUID</param>
        /// <param name="body">Required parameter: Example: </param>
        /// <return>Returns the Models.UpdateResponse response from the API call</return>
        public async Task <Models.UpdateResponse> UpdateAsync(string entryId, Models.IPAddress body)
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/v1.1/blacklists/ipaddresses/{entry_id}/update");

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


            //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" },
                { "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.PutBody(_queryUrl, _headers, _body);

            //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);

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.UpdateResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Gets the URL for a particular alias in the current environment and appends it with template parameters
        /// </summary>
        /// <param name="alias">Default value:DEFAULT</param>
        /// <return>Returns the baseurl</return>
        internal static string GetBaseURI(Servers alias = Servers.DEFAULT)
        {
            StringBuilder Url = new StringBuilder(EnvironmentsMap[Environment][alias]);

            APIHelper.AppendUrlWithTemplateParameters(Url, GetBaseURIParameters());
            return(Url.ToString());
        }
Exemple #4
0
        /// <summary>
        /// Gets the URL for a particular alias in the current environment and appends it with template parameters
        /// </summary>
        /// <return>Returns the baseurl</return>
        internal static string GetBaseURI()
        {
            var url = new StringBuilder("https://gateway.trulioo.com");

            APIHelper.AppendUrlWithTemplateParameters(url, GetBaseURIParameters());
            return(url.ToString());
        }
        /// <summary>
        /// Get list of options and their details for a specific style ID
        /// </summary>
        /// <param name="callback">Required parameter: The callback function that the JSON response will be wrapped in if desired</param>
        /// <param name="category">Required parameter: Option category (Acceptable values are: "", "Interior", "Exterior", "Roof", "Interior Trim", "Mechanical", "Package", "Additional Fees", "Other")</param>
        /// <param name="fmt">Required parameter: Response format (json only) (Acceptable values are: "json")</param>
        /// <param name="id">Required parameter: Edmunds vehicle style ID</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetOptionsAsync(
            string callback,
            string category,
            string fmt,
            string id)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/api/vehicle/v2/styles/{id}/options");

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

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "callback", callback },
                { "category", category },
                { "fmt", fmt },
                { "api_key", Configuration.ApiKey }
            });

            //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);

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

            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>
        /// Use this endpoint to remove an E911 record.
        /// </summary>
        /// <param name="e911Id">Required parameter: The id of the E911 record to remove.</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> DeleteE911Async(string e911Id)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v2/e911s/{e911_id}");

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


            //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", "text/plain; charset=utf-8" }
            };


            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Delete(_queryUrl, _headers, null, 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 == 401)
            {
                throw new ErrorException(@"Unauthorized – There was an issue with your API credentials.", _context);
            }

            if (_response.StatusCode == 404)
            {
                throw new ErrorException(@"The specified resource was not found", _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);
            }
        }
Exemple #7
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="strings">Required parameter: Example: </param>
        /// <return>Returns the EchoResponse response from the API call</return>
        public async Task <EchoResponse> SendStringArrayAsync(List <string> strings)
        {
            //validating required parameters
            if (null == strings)
            {
                throw new ArgumentNullException("strings", "The parameter \"strings\" 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("/{strings}");

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


            //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 <EchoResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Retrieves a list of accounts for a given customer
        /// </summary>
        /// <param name="customerIdentifier">Required parameter: Customer Identifier</param>
        /// <return>Returns the List<Models.AccountSummaryModel> response from the API call</return>
        public async Task <List <Models.AccountSummaryModel> > GetAccountsByCustomerAsync(string customerIdentifier)
        {
            //validating required parameters
            if (null == customerIdentifier)
            {
                throw new ArgumentNullException("customerIdentifier", "The parameter \"customerIdentifier\" is a required parameter and cannot be null.");
            }

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

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

            _queryBuilder.Append("/customers/{customerIdentifier}/accounts");

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


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

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

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

            //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 < 200) || (_response.StatusCode > 208)) //[200,208] = HTTP OK
            {
                throw new RaasGenericException(@"API Error", _context);
            }

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

            try
            {
                return(APIHelper.JsonDeserialize <List <Models.AccountSummaryModel> >(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Exemple #9
0
        /// <summary>
        /// Get a list of existing keywords.
        /// </summary>
        /// <param name="format">Required parameter: Response format e.g. json or xml</param>
        /// <param name="number">Optional parameter: Filter the list by virtual number</param>
        /// <param name="page">Optional parameter: Page number, for pagination</param>
        /// <param name="max">Optional parameter: Maximum results returned per page</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetKeywordsAsync(
            string format,
            string number = null,
            string page   = null,
            string max    = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/get-keywords.{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 },
                { "page", page },
                { "max", max }
            }, 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);
            }
        }
Exemple #10
0
        /// <summary>
        /// Delete or Merge Sub account
        /// </summary>
        /// <param name="CreateDeleteMergeSubAccountInput">Object containing request parameters</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> CreateDeleteMergeSubAccountAsync(CreateDeleteMergeSubAccountInput input)
        {
            //validating required parameters
            if (null == input.Subaccountsid)
            {
                throw new ArgumentNullException("subaccountsid", "The property \"Subaccountsid\" in the input object cannot be null.");
            }

            //the base uri for api requestss
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/user/deletesubaccount.{ResponseType}");

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


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

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

            //append form/field parameters
            var _fields = new Dictionary <string, object>()
            {
                { "subaccountsid", input.Subaccountsid },
                { "mergenumber", (int)(input.Mergenumber) }
            };

            //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>
        /// Calling this method will perform a verification. If your account includes address cleansing set the CleansedAddress flag to get
        /// additional address information in the result.  You can query configuration to get what fields are available to you in each country.
        /// It is also possible to get sample requests from the customer portal. If you are configured for a sandbox account make sure to call Get Test Entities to get test data for a country you want to try. Sandbox accounts only use these test entities and so trying to verify with any other data will result in no matches being found.
        /// </summary>
        /// <param name="body">Required parameter: Example: </param>
        /// <return>Returns the Models.VerifyResult response from the API call</return>
        public async Task <VerifyResult> CreateVerifyAsync(VerifyRequest body)
        {
            //validating required parameters
            if (null == body)
            {
                throw new ArgumentNullException(nameof(body), "The parameter \"body\" is a required parameter and cannot be null.");
            }

            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/{mode}/verifications/v1/verify");

            var parameters = new Dictionary <string, object> {
                { "mode", Configuration.Mode.ToFriendlyString() }
            };

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(queryBuilder, parameters);


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = new Dictionary <string, string>
            {
                { "user-agent", "Trulioo C# SDK" },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" },
                { "x-trulioo-api-key", Configuration.XTruliooApiKey }
            };

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

            //prepare the API call request to fetch the response
            HttpRequest request = ClientInstance.PostBody(queryUrl, headers, json);

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

            var context = new HttpContext(request, response);

            //handle errors defined at the API level
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <VerifyResult>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
        /// <summary>
        /// Calculates the expression using the specified operation.
        /// </summary>
        /// <param name="Models.GetCalculateInput">Object containing request parameters</param>
        /// <return>Returns the double response from the API call</return>
        public async Task <double> GetCalculateAsync(Models.GetCalculateInput input)
        {
            //Check if authentication token is set
            AuthManager.Instance.CheckAuthorization();
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/{operation}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "operation", Models.OperationTypeEnumHelper.ToValue(input.Operation) }
            });

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "x", input.X },
                { "y", input.Y }
            }, 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("gfdsfkl", Configuration.Gfdsfkl);
            _headers.Add("dsfsdf", Configuration.Dsfsdf);
            _headers.Add("Authorization", string.Format("Bearer {0}", Configuration.OAuthToken.AccessToken));

            //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);

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

            try
            {
                return(double.Parse(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="webhookId">Required parameter: Example: </param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> DestroyAsync(int webhookId)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/webhooks/{webhook_id}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "webhook_id", 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", "APIMATIC 2.0" }
            };

            _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.Delete(_queryUrl, _headers, null);

            //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(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Get Properties of a Type
        /// </summary>
        /// <param name="type">Required parameter: The name of the type to get properties.</param>
        /// <return>Returns the GetTypeResponse response from the API call</return>
        public async Task <GetTypeResponse> GetTypeAsync(string type)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v1/types/{type}");

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


            //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" }
            };

            //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);

            HttpContext _context = new HttpContext(_request, _response);

            //Error handling using HTTP status codes
            if (_response.StatusCode == 429)
            {
                throw new ErrorResponseException(@"Too many requests.", _context);
            }

            else if (_response.StatusCode == 500)
            {
                throw new APIException(@"Unexpected internal error.", _context);
            }

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

            try
            {
                return(APIHelper.JsonDeserialize <GetTypeResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Exemple #15
0
        /// <summary>
        /// Submit a receipt for a feed item
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="categoryUid">Required parameter: Category uid</param>
        /// <param name="feedItemUid">Required parameter: Feed item uid</param>
        /// <param name="body">Required parameter: Receipt</param>
        /// <return>Returns the Models.ReceiptCreationResponse response from the API call</return>
        public async Task <ReceiptCreationResponse> CreateOrUpdateReceiptAsync(
            Guid accountUid,
            Guid categoryUid,
            Guid feedItemUid,
            Receipt body)
        {
            //validating required parameters
            if (null == body)
            {
                throw new ArgumentNullException(nameof(body), "The parameter \"body\" is a required parameter and cannot be null.");
            }

            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/feed/account/{accountUid}/category/{categoryUid}/{feedItemUid}/receipt");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>
            {
                { "accountUid", accountUid },
                { "categoryUid", categoryUid },
                { "feedItemUid", feedItemUid }
            });


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetContentRequestHeaders(true, true);

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

            //prepare the API call request to fetch the response
            var request = ClientInstance.PutBody(queryUrl, headers, serializedBody);

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

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <ReceiptCreationResponse>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
Exemple #16
0
        /// <summary>
        /// Lists all of the information associated with any of the CNAM Records in your account.
        /// </summary>
        /// <param name="id">Required parameter: CNAM Record to search for.</param>
        /// <return>Returns the response from the API call</return>
        public async Task <dynamic> GetCNAMDetailsAsync(string id)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v2/cnams/{id}");

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


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

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "Flowroute SDK v3.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);

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

            if (_response.StatusCode == 404)
            {
                throw new APIException(@"Not Found", _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 Conference
        /// </summary>
        /// <param name="CreateListConferenceInput">Object containing request parameters</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> CreateListConferenceAsync(CreateListConferenceInput input)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/conferences/listconference.{ResponseType}");

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


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

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

            //append form/field parameters
            var _fields = new Dictionary <string, object>()
            {
                { "Page", input.Page },
                { "PageSize", input.PageSize },
                { "FriendlyName", input.FriendlyName },
                { "Status", (input.Status.HasValue) ? InterruptedCallStatusHelper.ToValue(input.Status.Value) : null },
                { "DateCreated", input.DateCreated },
                { "DateUpdated", input.DateUpdated }
            };

            //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);
            }
        }
Exemple #18
0
        /// <summary>
        /// Categories are subdivisions within an account.
        /// The `defaultCategory` from [`/api/v2/accounts`](#operations-tag-Accounts) is where the main balance and transactions are held.
        /// Other categories are used for Savings Goals.
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="categoryUid">Required parameter: Category uid</param>
        /// <param name="minTransactionTimestamp">Required parameter: Minimum transaction timestamp</param>
        /// <param name="maxTransactionTimestamp">Required parameter: Maximum transaction timestamp</param>
        /// <return>Returns the Models.FeedItems response from the API call</return>
        public async Task <FeedItems> GetQueryFeedItemsWithTransactionTimesBetweenAsync(
            Guid accountUid,
            Guid categoryUid,
            DateTime minTransactionTimestamp,
            DateTime maxTransactionTimestamp)
        {
            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/feed/account/{accountUid}/category/{categoryUid}/transactions-between");

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

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(queryBuilder, new Dictionary <string, object>
            {
                // ReSharper disable StringLiteralTypo
                { "minTransactionTimestamp", minTransactionTimestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") },
                { "maxTransactionTimestamp", maxTransactionTimestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") }
                // ReSharper restore StringLiteralTypo
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetRequestHeaders();

            //prepare the API call request to fetch the response
            var request = ClientInstance.Get(queryUrl, headers);

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

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <FeedItems>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
Exemple #19
0
        /// <summary>
        /// Updates a plan item
        /// </summary>
        /// <param name="planId">Required parameter: Plan id</param>
        /// <param name="planItemId">Required parameter: Plan item id</param>
        /// <param name="body">Required parameter: Request for updating the plan item</param>
        /// <param name="idempotencyKey">Optional parameter: Example: </param>
        /// <return>Returns the Models.GetPlanItemResponse response from the API call</return>
        public async Task <Models.GetPlanItemResponse> UpdatePlanItemAsync(
            string planId,
            string planItemId,
            Models.UpdatePlanItemRequest body,
            string idempotencyKey = null)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/plans/{plan_id}/items/{plan_item_id}");

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


            //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 0.16.0-beta.0" },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" },
                { "idempotency-key", idempotencyKey }
            };

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

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.PutBody(_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);

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.GetPlanItemResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Exemple #20
0
        /// <summary>
        /// This method retrieves the consents required for the data sources currently configured in your account configuration.
        /// The response for this method contains a collection of string that Verify method's ConsentForDataSources field expects to perform a verification using those data sources.
        /// Failure to provide an element from the string collection will lead to a 1005 service error
        /// </summary>
        /// <param name="country">The country which serializes to the country alpha2 code</param>
        /// <param name="configurationName">Required parameter: The product configuration. Currently defaults to "Identity Verification" for all products.</param>
        /// <return> Returns the List{string} response from the API call</return>
        public async Task <List <string> > GetConsentsAsync(Country country, string configurationName = "Identity Verification")
        {
            //validating country parameter
            if (country == Country.NotSet)
            {
                throw new ArgumentException(nameof(country), "The parameter \"country\" is required and cannot have the value NotSet.");
            }

            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/{mode}/configuration/v1/consents/{configurationName}/{countryCode}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>()
            {
                { "mode", Configuration.Mode.ToFriendlyString() },
                { "countryCode", country.ToAlpha2CodeString() },
                { "configurationName", configurationName }
            });


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = new Dictionary <string, string>
            {
                { "user-agent", "Trulioo C# SDK" },
                { "accept", "application/json" },
                { "x-trulioo-api-key", Configuration.XTruliooApiKey }
            };

            //prepare the API call request to fetch the response
            HttpRequest request = ClientInstance.Get(queryUrl, headers);

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

            var context = new HttpContext(request, response);


            //handle errors defined at the API level
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <List <string> >(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
Exemple #21
0
        /// <summary>
        /// Updates Booking status information.Newly created booking has status `reserved`. In this status BeMyGuest inventory is not yet deducted.Inventory is locked after changing status of the booking from `reserved` to `waiting` (`confirm` action).When the booking is first created, it is marked as `reserved`. Inventories aren't touched yet. Once the partner decides to confirm the said booking, this is the only time the inventory will be impacted. The booking status will be updated from `reserved` to `waiting`.5 days after the booking date all booking with status `waiting` will be marked `expired`.There's 3rd extra action you may invoke in this method : `resend`. If `confirmationEmailSentAt` value is not null then the confirmation email copy sent o partner will be sent again and the timestamp value of this field will be updated.In response Booking object is returned, for example        {          "data": {              "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75",              "totalAmount": "123.98",              "currencyCode": "SGD",              "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e",              "totalAmountRequestCurrency": "369.46",              "requestCurrencyCode": "MYR",              "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7",              "createdAt": "2015-12-21 19:53:23",              "updatedAt": "2015-12-21 19:53:23",              "arrivalDate": "2016-02-21",              "salutation": "Mr.",              "firstName": "test",              "lastName": "test",              "email": "*****@*****.**",              "phone": "123456789",              "guests": 2,              "children": 0,              "partnerReference": "test93828",              "confirmationEmailSentAt": null,              "confirmationEmailFiles": [],              "status": "reserved",              "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore",              "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore",              "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b"            }        }### Parameters+ uuid (required,string) - UUID of booking+ status (string) - Status "confirm" or "cancel"
        /// </summary>
        /// <param name="status">Required parameter: New status of the booking, one of [confirm, cancel, resend]</param>
        /// <param name="uuid">Required parameter: UUID of booking</param>
        /// <param name="data">Optional parameter: TODO: type parameter description here</param>
        /// <return>Returns the UpdateBookingStatusResponse response from the API call</return>
        public async Task <UpdateBookingStatusResponse> UpdateBookingStatusAsync(
            string status,
            string uuid,
            UpdateBookingRequest data = null)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v1/bookings/{uuid}/{status}");

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

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

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

            _headers.Add("X-Authorization", Configuration.XAuthorization);

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

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

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

            HttpContext _context = new HttpContext(_request, _response);

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

            try
            {
                return(APIHelper.JsonDeserialize <UpdateBookingStatusResponse>(_response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, _context);
            }
        }
Exemple #22
0
        /// <summary>
        /// Get the spending insights grouped by counter party
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="year">Required parameter: Year</param>
        /// <param name="month">Required parameter: Month</param>
        /// <return>Returns the Models.SpendingCounterPartySummary response from the API call</return>
        public async Task <SpendingCounterPartySummary> GetQuerySpendingInsightsByCounterpartyAsync(Guid accountUid, string year, MonthEnum month)
        {
            //validating required parameters
            if (null == year)
            {
                throw new ArgumentNullException(nameof(year), "The parameter \"year\" is a required parameter and cannot be null.");
            }

            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/accounts/{accountUid}/spending-insights/counter-party");

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

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(queryBuilder, new Dictionary <string, object>
            {
                { "year", year },
                { "month", MonthEnumHelper.ToValue(month) }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetRequestHeaders();

            //prepare the API call request to fetch the response
            var request = ClientInstance.Get(queryUrl, headers);

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

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <SpendingCounterPartySummary>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
        /// <summary>
        /// Retrieve the current status of a message using the message ID returned in the send messages end point.
        /// A successful request to the get message status endpoint will return a response body as follows:
        /// ```json
        /// {
        ///     "format": "SMS",
        ///     "content": "My first message!",
        ///     "metadata": {
        ///         "key1": "value1",
        ///         "key2": "value2"
        ///     },
        ///     "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
        ///     "callback_url": "https://my.callback.url.com",
        ///     "delivery_report": true,
        ///     "destination_number": "+61401760575",
        ///     "scheduled": "2016-11-03T11:49:02.807Z",
        ///     "source_number": "+61491570157",
        ///     "source_number_type": "INTERNATIONAL",
        ///     "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
        ///     "status": "enroute"
        /// }
        /// ```
        /// The status property of the response indicates the current status of the message. See the Delivery
        /// Reports section of this documentation for more information on message statues.
        /// *Note: If an invalid or non existent message ID parameter is specified in the request, then
        /// a HTTP 404 Not Found response will be returned*
        /// </summary>
        /// <param name="messageId">Required parameter: Example: </param>
        /// <return>Returns the Models.GetMessageStatusResponse response from the API call</return>
        public async Task <Models.GetMessageStatusResponse> GetMessageStatusAsync(string messageId)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

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

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


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

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

            //append authentication headers
            AuthManager.Instance.GetAuthHeaders(_queryUrl, _baseUri).ToList().ForEach(x => _headers.Add(x.Key, x.Value));

            //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 == 404)
            {
                throw new APIException(@"Resource not found", _context);
            }

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.GetMessageStatusResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Create a new referral.
        /// </summary>
        /// <param name="accountSlug">Required parameter: The account identifier</param>
        /// <param name="advocateToken">Required parameter: The advocate's token</param>
        /// <param name="referralForm">Required parameter: The body of the request</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> PostReferralAsync(string accountSlug, string advocateToken, ReferralForm referralForm)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/accounts/{account_slug}/advocates/{advocate_token}/referrals");

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


            //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" },
                { "content-type", "application/json; charset=utf-8" }
            };

            _headers.Add("Content-Type", Configuration.ContentType);
            _headers.Add("X-Auth-Token", Configuration.XAuthToken);

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

            //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);

            //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);
            }
        }
Exemple #25
0
        /// <summary>
        /// Retrieve the current status of a message using the message ID returned in the send messages end point.
        /// A successful request to the get message status endpoint will return a response body as follows:
        /// ```json
        /// {
        ///     "format": "SMS",
        ///     "content": "My first message!",
        ///     "metadata": {
        ///         "key1": "value1",
        ///         "key2": "value2"
        ///     },
        ///     "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
        ///     "callback_url": "https://my.callback.url.com",
        ///     "delivery_report": true,
        ///     "destination_number": "+61401760575",
        ///     "scheduled": "2016-11-03T11:49:02.807Z",
        ///     "source_number": "+61491570157",
        ///     "source_number_type": "INTERNATIONAL"
        ///     "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
        ///     "status": "enroute"
        /// }
        /// ```
        /// The status property of the response indicates the current status of the message. See the Delivery
        /// Reports section of this documentation for more information on message statues.
        /// *Note: If an invalid or non existent message ID parameter is specified in the request, then
        /// a HTTP 404 Not Found response will be returned*
        /// </summary>
        /// <param name="messageId">Required parameter: Example: </param>
        /// <param name="accountHeaderValue">Optional parameter: Sends the API an account value.</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetMessageStatusAsync(string messageId, string accountHeaderValue = null)
        {
            //the base uri for api requests
            string baseUri   = Configuration.BaseUri;
            string methodUri = $@"/v1/messages/{messageId}";

            //prepare query string for API call
            StringBuilder queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/v1/messages/{messageId}");

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

            //validate and preprocess url
            string queryUrl = APIHelper.CleanUrl(queryBuilder);

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

            AddAccountHeaderTo(headers, accountHeaderValue);

            //prepare the API call request to fetch the response
            HttpRequest request = GetHttpRequest(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 == 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);
            }
        }
Exemple #26
0
        /// <summary>
        /// To choose a file format, set the Accept header to either 'application/pdf' or 'text/csv'
        /// </summary>
        /// <param name="accountUid">Required parameter: Example: </param>
        /// <param name="yearMonth">Required parameter: Example: </param>
        /// <return>Returns the Stream response from the API call</return>
        public async Task <Stream> GetDownloadCsvStatementAsync(Guid accountUid, string yearMonth)
        {
            //validating required parameters
            if (null == yearMonth)
            {
                throw new ArgumentNullException(nameof(yearMonth), "The parameter \"yearMonth\" is a required parameter and cannot be null.");
            }

            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/accounts/{accountUid}/statement/download");

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

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


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetRequestHeaders(true, true);

            //prepare the API call request to fetch the response
            var request = ClientInstance.Get(queryUrl, headers);

            //invoke request and get response
            var response = await ClientInstance.ExecuteAsBinaryAsync(request).ConfigureAwait(false);

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);

            try
            {
                return(response.RawBody);
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
Exemple #27
0
        /// <summary>
        /// N.B. if you're looking for only the next payment date, this is also returned when getting a standing order in the `StandingOrder` response from the field `nextDate`.
        /// Categories are subdivisions within an account.
        /// The `defaultCategory` from [`/api/v2/accounts`](#operations-tag-Accounts) is where the main balance and transactions are held.
        /// Other categories are used for Savings Goals.
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="categoryUid">Required parameter: Category uid</param>
        /// <param name="paymentOrderUid">Required parameter: Payment Order uid</param>
        /// <param name="count">Optional parameter: Number of next payment dates to retrieve, between 1 and 100. If count is greater than the number of future payments all future payments will be returned. Defaults to 10.</param>
        /// <return>Returns the Models.NextPaymentDatesResponse response from the API call</return>
        public async Task <NextPaymentDatesResponse> ListNextPaymentDatesAsync(
            Guid accountUid,
            Guid categoryUid,
            Guid paymentOrderUid,
            int?count = null)
        {
            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/api/v2/payments/local/account/{accountUid}/category/{categoryUid}/standing-orders/{paymentOrderUid}/upcoming-payments");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>
            {
                { "accountUid", accountUid },
                { "categoryUid", categoryUid },
                { "paymentOrderUid", paymentOrderUid }
            });

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


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetRequestHeaders();

            //prepare the API call request to fetch the response
            var request = ClientInstance.Get(queryUrl, headers);

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

            var context = new HTTPContext(request, response);

            //handle errors
            ValidateResponse(response, context);

            try
            {
                return(APIHelper.JsonDeserialize <NextPaymentDatesResponse>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
        /// <summary>
        /// Remove a purchased Ytel number from your account.
        /// </summary>
        /// <param name="responseType">Required parameter: Response type format xml or json</param>
        /// <param name="phoneNumber">Required parameter: A valid 10-digit Ytel number (E.164 format).</param>
        /// <return>Returns the string response from the API call</return>
        public async Task <string> CreateReleaseNumberAsync(string responseType, string phoneNumber)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/incomingphone/releasenumber.{ResponseType}");

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


            //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)
            };

            //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>
        /// In order to cancel payment with miles you can use this endpoint. It allows to cancel payment only related GSM and terminal ID numbers.
        /// You can try this endpoint with configuring client parameters in Console Tab below. Test OAuthClientId is b30359c21700fd6f2b91154adcb7b37bab3e7e0a33e22682e5dd149d7a6ac4df
        /// and OAuthClientSecret is 4bc4335faad41d6a23cd059e495005f00496a64e34e6187b1d72695a8debd28c
        /// </summary>
        /// <param name="milesPaymentProvisionId">Required parameter: Provision ID.</param>
        /// <param name="body">Required parameter: The body of the request.</param>
        /// <return>Returns the Models.CancelMilePaymentResponse response from the API call</return>
        public async Task <Models.CancelMilePaymentResponse> DeleteCancelMilePaymentAsync(int milesPaymentProvisionId, Models.CancelMilePaymentRequest body)
        {
            //Check if authentication token is set
            AuthManager.Instance.CheckAuthorization();
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/v2/pos/payments/{miles_payment_provision_id}");

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


            //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" },
                { "content-type", "application/json; charset=utf-8" }
            };

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

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

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

            //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.CancelMilePaymentResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Exemple #30
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="chargeId">Required parameter: Charge Id</param>
        /// <param name="page">Optional parameter: Page number</param>
        /// <param name="size">Optional parameter: Page size</param>
        /// <return>Returns the Models.ListChargeTransactionsResponse response from the API call</return>
        public async Task <Models.ListChargeTransactionsResponse> GetChargeTransactionsAsync(string chargeId, int?page = null, int?size = 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/{charge_id}/transactions");

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

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "page", page },
                { "size", size }
            }, 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 0.16.21" },
                { "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.ListChargeTransactionsResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }