示例#1
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="array">Required parameter: TODO: type parameter description here</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> SendIntegerArrayAsync(
            List <int> array)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/form/number?array=true");


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

            //append form/field parameters
            var _fields = new Dictionary <string, object>();

            _fields.Add(APIHelper.PrepareFormFieldsFromObject("array", array));

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

            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);
            }
        }
示例#2
0
        /// <summary>
        /// Retrieves all accounts under the platform
        /// </summary>
        /// <return>Returns the List<Models.AccountModel> response from the API call</return>
        public async Task <List <Models.AccountModel> > GetAllAccountsAsync()
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/accounts");


            //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.AccountModel> >(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetDynamicAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/response/dynamic");


            //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 <dynamic>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Gets a plan
        /// </summary>
        /// <param name="planId">Required parameter: Plan id</param>
        /// <return>Returns the Models.GetPlanResponse response from the API call</return>
        public async Task <Models.GetPlanResponse> GetPlanAsync(string planId)
        {
            //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}");

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


            //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.13.40" },
                { "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.GetPlanResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Get Sender ID's
        /// </summary>
        /// <param name="format">Required parameter: Response format e.g. json or xml</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetSenderIdsAsync(string format)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/get-sender-ids.{format}");

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


            //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>
        /// This endpoint can be used to validate a *pre-configured* API description and see detailed error messages along with any warnings or useful information.
        /// </summary>
        /// <param name="apikey">Required parameter: The API Key of a pre-configured API description from APIMATIC</param>
        /// <return>Returns the Models.ValidateAnAPIDescriptionResponse response from the API call</return>
        public async Task <Models.ValidateAnAPIDescriptionResponse> UsingApikeyAsync(string apikey)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/validate");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "apikey", 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" }
            };

            //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.ValidateAnAPIDescriptionResponse>(_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="suites">Required parameter: TODO: type parameter description here</param>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> SendIntegerEnumArrayAsync(
            List <SuiteCode> suites)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/body/integerenum?array=true");


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

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

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

            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);
            }
        }
示例#8
0
        /// <summary>
        /// Delete a Pending Order
        /// </summary>
        /// <param name="orderUID">Required parameter: Order Uid to delete</param>
        /// <return>Returns the bool response from the API call</return>
        public async Task <bool> DeleteOrderAsync(int orderUID)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/Order/{OrderUID}");

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


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

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

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

            try
            {
                return(bool.Parse(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
示例#9
0
        /// <summary>
        /// This will list the entire contents of the Whitelist including both IP Addresses and Geo Locations.
        /// </summary>
        /// <return>Returns the Models.AllContentsResponse response from the API call</return>
        public async Task<Models.AllContentsResponse> AllContentsAsync()
        {
            //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/whitelists");


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

            //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.AllContentsResponse>(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Delete All Items
        /// </summary>
        /// <return>Returns the MessageResponse response from the API call</return>
        public async Task<MessageResponse> DeleteAllItemsAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);
            _queryBuilder.Append("/v1/items");


            //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.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 == 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<MessageResponse>(_response.Body);
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the DateTime? response from the API call</return>
        public async Task <DateTime?> GetDatetimeAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/response/datetime");


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

            //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(DateTime.ParseExact(_response.Body, APIHelper.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
示例#12
0
        /// <summary>
        /// Sends a single header params
        /// </summary>
        /// <param name="customHeader">Required parameter: TODO: type parameter description here</param>
        /// <param name="mvalue">Required parameter: Represents the value of the custom header</param>
        /// <return>Returns the string response from the API call</return>
        public async Task<string> SendHeadersAsync(
                string customHeader,
                string mvalue)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);
            _queryBuilder.Append("/header");


            //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" },
                { "custom-header", customHeader }
            };

            //append form/field parameters
            var _fields = new Dictionary<string,object>()
            {
                { "value", mvalue }
            };

            //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);
            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);
            }
        }
示例#13
0
        /// <summary>
        /// Onboard an account
        /// </summary>
        /// <param name="body">Required parameter: Account onboarding request</param>
        /// <return>Returns the Models.OnboardingResponse response from the API call</return>
        public async Task <OnboardingResponse> UpdateOnboardAsync(OnboardingRequest 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/onboarding");


            //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 <OnboardingResponse>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
示例#14
0
        /// <summary>
        /// Creates a new charge
        /// </summary>
        /// <param name="request">Required parameter: Request for creating a charge</param>
        /// <param name="idempotencyKey">Optional parameter: Example: </param>
        /// <return>Returns the Models.GetChargeResponse response from the API call</return>
        public async Task <Models.GetChargeResponse> CreateChargeAsync(Models.CreateChargeRequest request, 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("/Charges");


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

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

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.GetChargeResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// An access token will allow you to make requests for the system. We support only one type of token: client_credentials.
        /// You can try this API with configuring client parameters in Console Tab below. Test OAuthClientId is b30359c21700fd6f2b91154adcb7b37bab3e7e0a33e22682e5dd149d7a6ac4df and OAuthClientSecret is 4bc4335faad41d6a23cd059e495005f00496a64e34e6187b1d72695a8debd28c
        /// </summary>
        /// <param name="accept">Required parameter: It advertises which content type is able to understand.</param>
        /// <param name="contentType">Required parameter: It tells the client what the content type of the returned.</param>
        /// <param name="body">Required parameter: The body of the request.</param>
        /// <return>Returns the Models.OAuthResponse response from the API call</return>
        public async Task <Models.OAuthResponse> CreateAuthenticationAsync(string accept, string contentType, Models.OAuthRequest body)
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/oauth/token");


            //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" },
                { "Accept", accept },
                { "Content-Type", contentType }
            };

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.OAuthResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the SuiteCode response from the API call</return>
        public async Task <SuiteCode> GetIntEnumAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/response/enum");

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


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

            //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((SuiteCode)int.Parse(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
示例#17
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="feedItemUid">Required parameter: Feed item uid</param>
        /// <return>Returns the Models.MastercardFeedItem response from the API call</return>
        public async Task <MastercardFeedItem> GetMastercardFeedItemAsync(Guid accountUid, Guid categoryUid, Guid feedItemUid)
        {
            //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}/mastercard");

            //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.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 <MastercardFeedItem>(response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, context);
            }
        }
示例#18
0
        /// <summary>
        /// Update Existing Shipment
        /// </summary>
        /// <param name="shipment">Required parameter: Example: </param>
        /// <return>Returns the Shipment response from the API call</return>
        public async Task <Shipment> UpdateShipmentAsync(Shipment shipment)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/Shipment/");


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

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Shipment>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Get redemption request actions.
        /// </summary>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> GetRedemptionRequestActionsAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/utilities/redemption-request-actions");


            //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("Content-Type", Configuration.ContentType);
            _headers.Add("X-Auth-Token", Configuration.XAuthToken);

            //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(APIHelper.JsonDeserialize <dynamic>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Check for any delivery reports that have been received.
        /// Delivery reports are a notification of the change in status of a message as it is being processed.
        /// Each request to the check delivery reports endpoint will return any delivery reports received that
        /// have not yet been confirmed using the confirm delivery reports endpoint. A response from the check
        /// delivery reports endpoint will have the following structure:
        /// ```json
        /// {
        ///     "delivery_reports": [
        ///         {
        ///             "callback_url": "https://my.callback.url.com",
        ///             "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043",
        ///             "source_number": "+61491570157",
        ///             "date_received": "2017-05-20T06:30:37.642Z",
        ///             "status": "enroute",
        ///             "delay": 0,
        ///             "submitted_date": "2017-05-20T06:30:37.639Z",
        ///             "original_text": "My first message!",
        ///             "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba",
        ///             "vendor_account_id": {
        ///                 "vendor_id": "MessageMedia",
        ///                 "account_id": "MyAccount"
        ///             },
        ///             "metadata": {
        ///                 "key1": "value1",
        ///                 "key2": "value2"
        ///             }
        ///         },
        ///         {
        ///             "callback_url": "https://my.callback.url.com",
        ///             "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b",
        ///             "source_number": "+61491570158",
        ///             "date_received": "2017-05-21T01:46:42.579Z",
        ///             "status": "enroute",
        ///             "delay": 0,
        ///             "submitted_date": "2017-05-21T01:46:42.574Z",
        ///             "original_text": "My second message!",
        ///             "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281",
        ///             "vendor_account_id": {
        ///                 "vendor_id": "MessageMedia",
        ///                 "account_id": "MyAccount"
        ///             },
        ///             "metadata": {
        ///                 "key1": "value1",
        ///                 "key2": "value2"
        ///             }
        ///         }
        ///     ]
        /// }
        /// ```
        /// Each delivery report will contain details about the message, including any metadata specified
        /// and the new status of the message (as each delivery report indicates a change in status of a
        /// message) and the timestamp at which the status changed. Every delivery report will have a
        /// unique delivery report ID for use with the confirm delivery reports endpoint.
        /// *Note: The source number and destination number properties in a delivery report are the inverse of
        /// those specified in the message that the delivery report relates to. The source number of the
        /// delivery report is the destination number of the original message.*
        /// Subsequent requests to the check delivery reports endpoint will return the same delivery reports
        /// and a maximum of 100 delivery reports will be returned in each request. Applications should use the
        /// confirm delivery reports endpoint in the following pattern so that delivery reports that have been
        /// processed are no longer returned in subsequent check delivery reports requests.
        /// 1. Call check delivery reports endpoint
        /// 2. Process each delivery report
        /// 3. Confirm all processed delivery reports using the confirm delivery reports endpoint
        /// *Note: It is recommended to use the Webhooks feature to receive reply messages rather than
        /// polling the check delivery reports endpoint.*
        /// </summary>
        /// <return>Returns the Models.CheckDeliveryReportsResponse response from the API call</return>
        public async Task <Models.CheckDeliveryReportsResponse> CheckDeliveryReportsAsync()
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v1/delivery_reports");


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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.CheckDeliveryReportsResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> Get400Async()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/error/400");


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

            //Error handling using HTTP status codes
            if ((_response.StatusCode < 200) || (_response.StatusCode > 206)) //[200,206] = HTTP OK
            {
                throw new APIException(@"HTTP Response Not OK", _context);
            }

            try
            {
                return(APIHelper.JsonDeserialize <dynamic>(_response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, _context);
            }
        }
示例#22
0
        /// <summary>
        /// Activates transaction round-up and adds remainder to savings goal
        /// </summary>
        /// <param name="accountUid">Required parameter: Account uid</param>
        /// <param name="body">Required parameter: Round-up goal</param>
        /// <return>Returns the void response from the API call</return>
        public async Task UpdateActivateRoundUpGoalAsync(Guid accountUid, RoundUpGoalPayload 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}/round-up");

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


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

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

            //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);
        }
示例#23
0
        /// <summary>
        /// A Config object has the following attributes:+ `timezone` - Our sever timezone+ `now` - Our server timestamp+ `version` - Current version is "1.0"+ `serverUrl` - Main API URL+ `photosUrl` - Base Path to server where we store our images+ `productsSorting` - Available Products lists sorting options (can be combined with commas, for example &sort=date,-price )    + `date` - Date ascending    + `-date` - Date descending    + `price` - Price ascending    + `-price` - Price descending    + `distance` - Distance ascending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise)     + `-distance` - Distance descending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise)+ user - All important userdata for provided API key    + `name` - Name / Company / Organization    + `email` - E-Mail Address    + `uuid` - Unique ID    + `continueUrl` - Continue URL (not in use now)    + `notifyUrl` - Notify URL (not in use now)    + `suggestedMarkup` - Suggested markup, % decimal value, for example 7.5    + `defaultPagination` - Default Pagination value (per page), between 1-100    + `defaultSortBy` - Default sort by for /products (if not specified)    + `defaultCurrencyUuid` - Default currency UUID for /products (if not specified)    + `defaultCurrencyCode` - Default currency code for /products (if not specified)    + `defaultLanguageUuid` - Default language UUID  /products (if not specified)    + `defaultLanguageCode` - Default language code  /products (if not specified)    + `walletBalance` - Partner's available wallet balance, based on his deposits    + `walletAvailableBalance` - Wallet balance which is a combination of partner's deposit and assigned credit amount    + `wallet_alert_value` - Threshold value in SGD, when `walletBallance` reach this value then BMG and partner will be notified on this event+ `languages` - A list of supported languages.+ `currencies` - An array of supported currencies.+ `types` - An array of supported products types.+ `categories` - A tree of supported product categories.+ `locations` - A tree of supported locations. (Continent -> Country -> State -> City)
        /// </summary>
        /// <return>Returns the RetrieveConfigResponse response from the API call</return>
        public async Task <RetrieveConfigResponse> RetrieveConfigAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/v1/config");


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

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

            //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 <RetrieveConfigResponse>(_response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, _context);
            }
        }
        /// <summary>
        /// Delete a webhook that was previously created for the connected account.
        /// A webhook can be cancelled by appending the UUID of the webhook to the endpoint and submitting a DELETE request to the /webhooks/messages endpoint.
        /// *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>
        /// <return>Returns the void response from the API call</return>
        public async Task DeleteWebhookAsync(String webhookId)
        {
            //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" }
            };

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

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);
        }
        /// <summary>
        /// Check for any delivery reports that have been received.
        /// Delivery reports are a notification of the change in status of a message as it is being processed.
        /// Each request to the check delivery reports endpoint will return any delivery reports received that
        /// have not yet been confirmed using the confirm delivery reports endpoint. A response from the check
        /// delivery reports endpoint will have the following structure:
        /// ```json
        /// {
        ///     "delivery_reports": [
        ///         {
        ///             "callback_url": "https://my.callback.url.com",
        ///             "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043",
        ///             "source_number": "+61491570157",
        ///             "date_received": "2017-05-20T06:30:37.642Z",
        ///             "status": "enroute",
        ///             "delay": 0,
        ///             "submitted_date": "2017-05-20T06:30:37.639Z",
        ///             "original_text": "My first message!",
        ///             "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba",
        ///             "vendor_account_id": {
        ///                 "vendor_id": "MessageMedia",
        ///                 "account_id": "MyAccount"
        ///             },
        ///             "metadata": {
        ///                 "key1": "value1",
        ///                 "key2": "value2"
        ///             }
        ///         },
        ///         {
        ///             "callback_url": "https://my.callback.url.com",
        ///             "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b",
        ///             "source_number": "+61491570158",
        ///             "date_received": "2017-05-21T01:46:42.579Z",
        ///             "status": "enroute",
        ///             "delay": 0,
        ///             "submitted_date": "2017-05-21T01:46:42.574Z",
        ///             "original_text": "My second message!",
        ///             "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281",
        ///             "vendor_account_id": {
        ///                 "vendor_id": "MessageMedia",
        ///                 "account_id": "MyAccount"
        ///             },
        ///             "metadata": {
        ///                 "key1": "value1",
        ///                 "key2": "value2"
        ///             }
        ///         }
        ///     ]
        /// }
        /// ```
        /// Each delivery report will contain details about the message, including any metadata specified
        /// and the new status of the message (as each delivery report indicates a change in status of a
        /// message) and the timestamp at which the status changed. Every delivery report will have a
        /// unique delivery report ID for use with the confirm delivery reports endpoint.
        /// *Note: The source number and destination number properties in a delivery report are the inverse of
        /// those specified in the message that the delivery report relates to. The source number of the
        /// delivery report is the destination number of the original message.*
        /// Subsequent requests to the check delivery reports endpoint will return the same delivery reports
        /// and a maximum of 100 delivery reports will be returned in each request. Applications should use the
        /// confirm delivery reports endpoint in the following pattern so that delivery reports that have been
        /// processed are no longer returned in subsequent check delivery reports requests.
        /// 1. Call check delivery reports endpoint
        /// 2. Process each delivery report
        /// 3. Confirm all processed delivery reports using the confirm delivery reports endpoint
        /// *Note: It is recommended to use the Webhooks feature to receive reply messages rather than
        /// polling the check delivery reports endpoint.*
        /// </summary>
        /// <param name="accountHeaderValue">Optional parameter: Sends the API an account value.</param>
        /// <return>Returns the Models.CheckDeliveryReportsResponse response from the API call</return>
        public async Task <Models.CheckDeliveryReportsResponse> GetCheckDeliveryReportsAsync(string accountHeaderValue = null)
        {
            //the base uri for api requests
            string baseUri   = Configuration.BaseUri;
            string methodUri = "/v1/delivery_reports";

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

            queryBuilder.Append(methodUri);

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.CheckDeliveryReportsResponse>(response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, context);
            }
        }
示例#26
0
        /// <summary>
        /// Health Probe
        /// </summary>
        /// <return>Returns the ModelsStatusModel response from the API call</return>
        public async Task <StatusModel> GetHealthProbeAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/health/probe");


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

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

            _headers.Add("X-Moesif-Application-Id", Configuration.ApplicationId);

            //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 <StatusModel>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Send SMS  to recipients using D7 SMS Gateway
        /// </summary>
        /// <param name="Models.CreateSendSMSInput">Object containing request parameters</param>
        /// <return>Returns the void response from the API call</return>
        public async Task CreateSendSMSAsync(Models.CreateSendSMSInput input)
        {
            //the base uri for api requests
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/send");


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

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "D7SDK 1.0" },
                { "Content-Type", input.ContentType },
                { "Accept", input.Accept }
            };

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

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

            //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 == 500)
            {
                throw new APIException(@"Internal Server Error", _context);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);
        }
        /// <summary>
        /// Delete a referral.
        /// </summary>
        /// <param name="accountSlug">Required parameter: The account identifier</param>
        /// <param name="advocateToken">Required parameter: The advocate's token</param>
        /// <param name="referralId">Required parameter: The referral identifier</param>
        /// <return>Returns the void response from the API call</return>
        public async Task DeleteReferralAsync(string accountSlug, string advocateToken, string referralId)
        {
            //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/{referral_id}");

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


            //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("Content-Type", Configuration.ContentType);
            _headers.Add("X-Auth-Token", Configuration.XAuthToken);

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

            //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);
        }
示例#29
0
        /// <summary>
        /// دریافت اطلاعات درباره ی ما
        /// </summary>
        /// <param name="xApiKey">Required parameter: Example: </param>
        /// <return>Returns the Models.BaseModelPortalLandingContactAbout response from the API call</return>
        public async Task <Models.BaseModelPortalLandingContactAbout> GetPortalLandingContactAboutAsync(string xApiKey)
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/InsuranceCentre/PortalLandingContactAbout/hfz1");


            //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" },
                { "x-api-key", xApiKey }
            };

            //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(APIHelper.JsonDeserialize <Models.BaseModelPortalLandingContactAbout>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// Get Catalog
        /// </summary>
        /// <return>Returns the Models.CatalogModel response from the API call</return>
        public async Task <Models.CatalogModel> GetCatalogAsync()
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/catalogs");


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

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

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

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