/// <summary> /// Update an IP Address in the Whitelist /// </summary> /// <param name="entryId">Required parameter: a unique identifier for the IP Address; opaque but likely a GUID</param> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the Models.UpdateResponse response from the API call</return> public async Task <Models.UpdateResponse> UpdateAsync(string entryId, Models.IPAddress body) { //the base uri for api requests string _baseUri = Configuration.GetBaseURI(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1.1/whitelists/ipaddresses/{entry_id}/update"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "entry_id", entryId } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; //append body params var _body = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body); //Custom Authentication to be added for authorization AuthUtility.AppendCustomAuthParams(_request); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); //Error handling using HTTP status codes if (_response.StatusCode == 400) { throw new ReturnException(@"Unexpected error in API call. See HTTP response body for details.", _context); } //handle errors defined at the API level base.ValidateResponse(_response, _context); try { return(APIHelper.JsonDeserialize <Models.UpdateResponse>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Submit a receipt for a feed item /// </summary> /// <param name="accountUid">Required parameter: Account uid</param> /// <param name="categoryUid">Required parameter: Category uid</param> /// <param name="feedItemUid">Required parameter: Feed item uid</param> /// <param name="body">Required parameter: Receipt</param> /// <return>Returns the Models.ReceiptCreationResponse response from the API call</return> public async Task <ReceiptCreationResponse> CreateOrUpdateReceiptAsync( Guid accountUid, Guid categoryUid, Guid feedItemUid, Receipt body) { //validating required parameters if (null == body) { throw new ArgumentNullException(nameof(body), "The parameter \"body\" is a required parameter and cannot be null."); } //the base uri for api requests var baseUri = Configuration.GetBaseURI(); //prepare query string for API call var queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/api/v2/feed/account/{accountUid}/category/{categoryUid}/{feedItemUid}/receipt"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object> { { "accountUid", accountUid }, { "categoryUid", categoryUid }, { "feedItemUid", feedItemUid } }); //validate and preprocess url var queryUrl = APIHelper.CleanUrl(queryBuilder); //append request with appropriate headers and parameters var headers = APIHelper.GetContentRequestHeaders(true, true); //append body params var serializedBody = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response var request = ClientInstance.PutBody(queryUrl, headers, serializedBody); //invoke request and get response var response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(request).ConfigureAwait(false); var context = new HTTPContext(request, response); //handle errors ValidateResponse(response, context); try { return(APIHelper.JsonDeserialize <ReceiptCreationResponse>(response.Body)); } catch (Exception ex) { throw new APIException("Failed to parse the response: " + ex.Message, context); } }
/// <summary> /// Updates a plan item /// </summary> /// <param name="planId">Required parameter: Plan id</param> /// <param name="planItemId">Required parameter: Plan item id</param> /// <param name="body">Required parameter: Request for updating the plan item</param> /// <param name="idempotencyKey">Optional parameter: Example: </param> /// <return>Returns the Models.GetPlanItemResponse response from the API call</return> public async Task <Models.GetPlanItemResponse> UpdatePlanItemAsync( string planId, string planItemId, Models.UpdatePlanItemRequest body, string idempotencyKey = null) { //the base uri for api requests string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/plans/{plan_id}/items/{plan_item_id}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "plan_id", planId }, { "plan_item_id", planItemId } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "MundiSDK - DotNet 0.16.0-beta.0" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" }, { "idempotency-key", idempotencyKey } }; //append body params var _body = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); //handle errors defined at the API level base.ValidateResponse(_response, _context); try { return(APIHelper.JsonDeserialize <Models.GetPlanItemResponse>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Set the Account Level callback for all DLRs /// </summary> /// <param name="dlr_url">Required parameter: The callback url for all DLRs. /// <return>Returns the response from the API call</return> public async Task <dynamic> SetDLRCallbackAsync(string dlr_url) { //the base uri for api requests string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2.1/messages/dlr_callback"); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" }, { "accept", "application/json" } }; //append body params var _body = "{\"data\": {\"attributes\": {\"callback_url\": "; _body += dlr_url; _body += "\"}}}"; //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); //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.StatusCode); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Updates Booking status information.Newly created booking has status `reserved`. In this status BeMyGuest inventory is not yet deducted.Inventory is locked after changing status of the booking from `reserved` to `waiting` (`confirm` action).When the booking is first created, it is marked as `reserved`. Inventories aren't touched yet. Once the partner decides to confirm the said booking, this is the only time the inventory will be impacted. The booking status will be updated from `reserved` to `waiting`.5 days after the booking date all booking with status `waiting` will be marked `expired`.There's 3rd extra action you may invoke in this method : `resend`. If `confirmationEmailSentAt` value is not null then the confirmation email copy sent o partner will be sent again and the timestamp value of this field will be updated.In response Booking object is returned, for example { "data": { "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75", "totalAmount": "123.98", "currencyCode": "SGD", "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e", "totalAmountRequestCurrency": "369.46", "requestCurrencyCode": "MYR", "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7", "createdAt": "2015-12-21 19:53:23", "updatedAt": "2015-12-21 19:53:23", "arrivalDate": "2016-02-21", "salutation": "Mr.", "firstName": "test", "lastName": "test", "email": "*****@*****.**", "phone": "123456789", "guests": 2, "children": 0, "partnerReference": "test93828", "confirmationEmailSentAt": null, "confirmationEmailFiles": [], "status": "reserved", "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore", "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore", "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b" } }### Parameters+ uuid (required,string) - UUID of booking+ status (string) - Status "confirm" or "cancel" /// </summary> /// <param name="status">Required parameter: New status of the booking, one of [confirm, cancel, resend]</param> /// <param name="uuid">Required parameter: UUID of booking</param> /// <param name="data">Optional parameter: TODO: type parameter description here</param> /// <return>Returns the UpdateBookingStatusResponse response from the API call</return> public async Task <UpdateBookingStatusResponse> UpdateBookingStatusAsync( string status, string uuid, UpdateBookingRequest data = null) { //the base uri for api requestss string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/bookings/{uuid}/{status}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "status", status }, { "uuid", uuid } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "BeMyGuest.SDK.v1" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; _headers.Add("X-Authorization", Configuration.XAuthorization); //append body params var _body = APIHelper.JsonSerialize(data); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request); HttpContext _context = new HttpContext(_request, _response); //handle errors defined at the API level base.ValidateResponse(_response, _context); try { return(APIHelper.JsonDeserialize <UpdateBookingStatusResponse>(_response.Body)); } catch (Exception ex) { throw new APIException("Failed to parse the response: " + ex.Message, _context); } }
/// <summary> /// In order to finalize payment with miles use this endpoint. Use the OTP number which is send to user GSM on the Request body. /// You can try this endpoint with configuring client parameters in Console Tab below. Test OAuthClientId is b30359c21700fd6f2b91154adcb7b37bab3e7e0a33e22682e5dd149d7a6ac4df /// and OAuthClientSecret is 4bc4335faad41d6a23cd059e495005f00496a64e34e6187b1d72695a8debd28c /// </summary> /// <param name="milesPaymentProvisionId">Required parameter: Provision ID.</param> /// <param name="body">Required parameter: The body of the request.</param> /// <return>Returns the Models.CompleteMilePaymentResponse response from the API call</return> public async Task <Models.CompleteMilePaymentResponse> UpdateCompleteMilePaymentAsync(int milesPaymentProvisionId, Models.CompleteMilePaymentRequest body) { //Check if authentication token is set AuthManager.Instance.CheckAuthorization(); //the base uri for api requests string _baseUri = Configuration.GetBaseURI(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/pos/payments/{miles_payment_provision_id}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "miles_payment_provision_id", milesPaymentProvisionId } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; _headers.Add("Authorization", string.Format("Bearer {0}", Configuration.OAuthToken.AccessToken)); //append body params var _body = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_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.CompleteMilePaymentResponse>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Cancel a scheduled message that has not yet been delivered. /// A scheduled message can be cancelled by updating the status of a message from ```scheduled``` /// to ```cancelled```. This is done by submitting a PUT request to the messages endpoint using /// the message ID as a parameter (the same endpoint used above to retrieve the status of a message). /// The body of the request simply needs to contain a ```status``` property with the value set /// to ```cancelled```. /// ```json /// { /// "status": "cancelled" /// } /// ``` /// *Note: Only messages with a status of scheduled can be cancelled. If an invalid or non existent /// message ID parameter is specified in the request, then a HTTP 404 Not Found response will be /// returned* /// </summary> /// <param name="messageId">Required parameter: Example: </param> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> CancelScheduledMessageAsync(string messageId, Models.CancelScheduledMessageRequest body) { //the base uri for api requests string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/messages/{messageId}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "messageId", messageId } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "messagemedia-messages" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; //append body params var _body = APIHelper.JsonSerialize(body); //append authentication headers AuthManager.Instance.GetAuthHeaders(_queryUrl, _baseUri, _body).ToList().ForEach(x => _headers.Add(x.Key, x.Value)); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).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> /// Update a profile image if one already exists /// </summary> /// <param name="accountHolderUid">Required parameter: Unique identifier of an account holder</param> /// <param name="contentType">Required parameter: Example: </param> /// <param name="body">Required parameter: Attachment input stream</param> /// <return>Returns the void response from the API call</return> public async Task UpdateProfileImageAsync(Guid accountHolderUid, string contentType, object body) { //validating required parameters if (null == contentType) { throw new ArgumentNullException(nameof(contentType), "The parameter \"contentType\" is a required parameter and cannot be null."); } 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/account-holder/{accountHolderUid}/profile-image"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object> { { "accountHolderUid", accountHolderUid } }); //validate and preprocess url var queryUrl = APIHelper.CleanUrl(queryBuilder); //append request with appropriate headers and parameters var headers = new Dictionary <string, string> { { "user-agent", "StarlingBankClient" }, { "Content-Type", contentType }, { "Authorization", $"Bearer {Configuration.OAuthAccessToken}" } }; //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); }
/// <summary> /// Update 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 id</param> /// <param name="referralForm">Required parameter: The body of the request</param> /// <return>Returns the void response from the API call</return> public async Task PutReferralAsync( string accountSlug, string advocateToken, string referralId, ReferralForm referralForm) { //the base uri for api requestss string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/accounts/{account_slug}/advocates/{advocate_token}/referrals/{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" }, { "content-type", "application/json; charset=utf-8" } }; _headers.Add("Content-Type", Configuration.ContentType); _headers.Add("X-Auth-Token", Configuration.XAuthToken); //append body params var _body = APIHelper.JsonSerialize(referralForm); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_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); }
/// <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); } }
/// <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); }
/// <summary> /// Update an individual account holder's email address /// </summary> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the void response from the API call</return> public async Task UpdateEmailAsync(UpdateEmailRequest 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/account-holder/individual/email"); //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); }
/// <summary> /// Create a New Type /// </summary> /// <param name="type">Required parameter: The name of the type.</param> /// <param name="settings">Optional parameter: Optional settings for the rating parameter.</param> /// <return>Returns the MessageResponse response from the API call</return> public async Task <MessageResponse> CreateTypeAsync(string type, TypeRequestBody settings = 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/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" }, { "content-type", "application/json; charset=utf-8" } }; //append body params var _body = APIHelper.JsonSerialize(settings); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); //Error handling using HTTP status codes if (_response.StatusCode == 402) { throw new LimitExceededErrorResponseException(@"Type limit reached.", _context); } else if (_response.StatusCode == 409) { throw new ErrorResponseException(@"Type already exists.", _context); } else if (_response.StatusCode == 422) { throw new ErrorResponseException(@"Rating type is not `implicit` or `explicit`.", _context); } else 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> /// <param name="webhookId">Required parameter: Example: </param> /// <param name="webhook">Optional parameter: Example: </param> /// <return>Returns the Webhook response from the API call</return> public async Task <Webhook> UpdateAsync(int webhookId, Webhook webhook = null) { //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" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; _headers.Add("X-API-TOKEN", Configuration.XAPITOKEN); _headers.Add("X-API-EMAIL", Configuration.XAPIEMAIL); //append body params var _body = APIHelper.JsonSerialize(webhook); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body); //Custom Authentication to be added for authorization AuthUtility.AppendCustomAuthParams(_request); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request); 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 <Webhook>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Cancel a scheduled message that has not yet been delivered. /// A scheduled message can be cancelled by updating the status of a message from ```scheduled``` /// to ```cancelled```. This is done by submitting a PUT request to the messages endpoint using /// the message ID as a parameter (the same endpoint used above to retrieve the status of a message). /// The body of the request simply needs to contain a ```status``` property with the value set /// to ```cancelled```. /// ```json /// { /// "status": "cancelled" /// } /// ``` /// *Note: Only messages with a status of scheduled can be cancelled. If an invalid or non existent /// message ID parameter is specified in the request, then a HTTP 404 Not Found response will be /// returned* /// </summary> /// <param name="messageId">Required parameter: Example: </param> /// <param name="body">Required parameter: Example: </param> /// <param name="accountHeaderValue">Optional parameter: Sends the API an account value.</param> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> UpdateCancelScheduledMessageAsync(string messageId, Models.CancelScheduledMessageRequest body, string accountHeaderValue = null) { //the base uri for api requests string baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/v1/messages/{messageId}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>() { { "messageId", messageId } }); //validate and preprocess url string queryUrl = APIHelper.CleanUrl(queryBuilder); //append request with appropriate headers and parameters var headers = new Dictionary <string, string>() { { "user-agent", SdkVersion }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; AddAccountHeaderTo(headers, accountHeaderValue); //append body params var jsonBody = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest request = ClientInstance.PutBody(queryUrl, headers, jsonBody, 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 APIException(@"", _context); } if (response.StatusCode == 404) { throw new APIException(@"", _context); } //handle errors defined at the API level base.ValidateResponse(response, _context); try { return(APIHelper.JsonDeserialize <dynamic>(response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }