Ejemplo n.º 1
0
        public async Task <bool> DeleteCreditCardAsync(string creditCardId)
        {
            string _baseUri = Configuration.GetBaseURI();

            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/fundinginstruments/{creditCard-id}");

            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "creditCard-id", creditCardId }
            });

            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            var _headers = Utilities.APIHelper.GetHeader();

            HttpRequest _request = ClientInstance.Delete(_queryUrl, _headers, null);

            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            if (_response.StatusCode == 404)
            {
                return(false);
            }
            else
            {
                base.ValidateResponse(_response, _context);
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes the round-up goal associated with an account if one exists
        /// </summary>
        /// <param name="accountUid">Required parameter: Example: </param>
        /// <return>Returns the void response from the API call</return>
        public async Task DeleteStopRoundUpGoalAsync(Guid accountUid)
        {
            //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.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);
        }
        /// <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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deletes a Type
        /// </summary>
        /// <param name="type">Required parameter: The name of the type to be deleted.</param>
        /// <return>Returns the Models.MessageResponse response from the API call</return>
        public async Task <Models.MessageResponse> DeleteTypeAsync(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.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 ErrorResponseException(@"Action type does not exists.", _context);
            }

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

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

            try
            {
                return(APIHelper.JsonDeserialize <Models.MessageResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Delete All Types
        /// </summary>
        /// <return>Returns the GetTypesResponse response from the API call</return>
        public async Task <GetTypesResponse> DeleteAllTypesAsync()
        {
            //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");


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

            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 <GetTypesResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Lets you purchase a phone number from available Flowroute inventory.
        /// </summary>
        /// <param name="id">Required parameter: Phone number to purchase. Must be in 11-digit E.164 format; e.g. 12061231234.</param>
        /// <return>Returns the Models.Number26 response from the API call</return>
        public async Task <Int32> ReleaseDIDAsync(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/numbers/{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.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);

            return(_response.StatusCode);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Removes an item from a plan
        /// </summary>
        /// <param name="planId">Required parameter: Plan id</param>
        /// <param name="planItemId">Required parameter: Plan item id</param>
        /// <param name="idempotencyKey">Optional parameter: Example: </param>
        /// <return>Returns the Models.GetPlanItemResponse response from the API call</return>
        public async Task <Models.GetPlanItemResponse> DeletePlanItemAsync(string planId, string planItemId, 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" },
                { "idempotency-key", idempotencyKey }
            };

            //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(APIHelper.JsonDeserialize <Models.GetPlanItemResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="shipmentId">Required parameter: Shipment Id to Cancel</param>
        /// <param name="userId">Required parameter: User requesting cancelation</param>
        /// <param name="reason">Optional parameter: Reason for canceling Shipment</param>
        /// <return>Returns the bool response from the API call</return>
        public async Task <bool> DeleteCancelShipmentAsync(string shipmentId, string userId, string reason = null)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.GetBaseURI();

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

            _queryBuilder.Append("/Shipment/");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "ShipmentId", shipmentId },
                { "UserId", userId },
                { "Reason", reason }
            });


            //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);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the dynamic response from the API call</return>
        public async Task <dynamic> DeleteAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

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

            _queryBuilder.Append("/echo");


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

            //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);
            }
        }
        /// <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>
        /// 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);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Delete Actions
        /// </summary>
        /// <param name="type">Required parameter: Delete actions of a type. This parameter and at least one other parameter is required.</param>
        /// <param name="userId">Optional parameter: Delete actions of a user id.</param>
        /// <param name="itemId">Optional parameter: Delete actions of an item id.</param>
        /// <param name="olderThan">Optional parameter: Delete actions older than the given duration, or the given time number. Could be a ISO 8601 duration, or a Unix time number. Specifications are available at https://en.wikipedia.org/wiki/ISO_8601#Durations, or https://en.wikipedia.org/wiki/Unix_time.</param>
        /// <return>Returns the Models.DeleteSuccessResponse response from the API call</return>
        public async Task <Models.DeleteSuccessResponse> DeleteActionsAsync(
            string type,
            string userId    = null,
            string itemId    = null,
            string olderThan = 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/actions");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "type", type },
                { "user_id", userId },
                { "item_id", itemId },
                { "older_than", olderThan }
            }, 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", "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 == 400)
            {
                throw new ErrorResponseException(@"Required user id or item id parameters are missing.", _context);
            }

            if (_response.StatusCode == 404)
            {
                throw new DeleteErrorResponseException(@"Delete actions not found.", _context);
            }

            if (_response.StatusCode == 422)
            {
                throw new ErrorResponseException(@"No query parameter (user id, item id, or older than) is given. qIn order to delete all actionsdelete the type.", _context);
            }

            if (_response.StatusCode == 505)
            {
                throw new ErrorResponseException(@"Request timed out.", _context);
            }

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

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

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