/// <summary> /// User Profile /// </summary> /// <return>Returns the Models.ProfileModel response from the API call</return> public async Task <Models.ProfileModel> GetMeAsync() { //the base uri for api requestss string _baseUri = Configuration.GetBaseURI(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/me"); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" }, { "accept", "application/json" } }; //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.Get(_queryUrl, _headers); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).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 ErrorErrorException(@"Unexpected error", _context); } //handle errors defined at the API level base.ValidateResponse(_response, _context); try { return(APIHelper.JsonDeserialize <Models.ProfileModel>(_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="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); } }
/// <summary> /// Get a Single Accessorial By Id /// </summary> /// <param name="aCCCHARGEID">Required parameter: Example: </param> /// <return>Returns the AccItem response from the API call</return> public async Task <AccItem> GetAccessorialByIDAsync(int aCCCHARGEID) { //the base uri for api requestss string _baseUri = Configuration.GetBaseURI(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/Accessorial/{ACC_CHARGE_ID}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "ACC_CHARGE_ID", aCCCHARGEID } }); //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 <AccItem>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Cancels an invoice /// </summary> /// <param name="invoiceId">Required parameter: Invoice id</param> /// <return>Returns the Models.GetInvoiceResponse response from the API call</return> public async Task <Models.GetInvoiceResponse> CancelInvoiceAsync(string invoiceId) { //the base uri for api requests string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/invoices/{invoice_id}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "invoice_id", invoiceId } }); //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.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.GetInvoiceResponse>(_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); //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> /// tets /// </summary> /// <param name="t">Required parameter: Example: </param> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> GetTestAsync(string t) { //the base uri for api requestss string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/hello"); //process optional query parameters APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>() { { "T", t } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" }, { "accept", "application/json" } }; //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.Get(_queryUrl, _headers); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).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> /// 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); } }
public async Task <List <Models.V1Merchant> > ListLocationsAsync(CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/me/locations"); //validate and preprocess url string _queryUrl = ApiHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", "2020-01-22" } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryUrl, _headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["default"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); return(ApiHelper.JsonDeserialize <List <Models.V1Merchant> >(_response.Body)); }
/// <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); } }
public async Task <HttpResponse> ExecuteAsStringAsync(HttpRequest request) { RaiseOnBeforeHttpRequestEvent(request); HttpResponseMessage responseMessage = await HttpResponseMessage(request).ConfigureAwait(false); HttpResponse response = new HttpStringResponse { Headers = responseMessage.Headers.ToDictionary(l => l.Key, k => k.Value.First()), RawBody = await responseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false), Body = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false), StatusCode = (int)responseMessage.StatusCode }; RaiseOnAfterHttpResponseEvent(response); return(response); }
/// <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); } }
/// <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> /// Retrieves a seller's booking profile. /// </summary> /// <return>Returns the Models.RetrieveBusinessBookingProfileResponse response from the API call</return> public async Task <Models.RetrieveBusinessBookingProfileResponse> RetrieveBusinessBookingProfileAsync(CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/bookings/business-booking-profile"); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", config.SquareVersion } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryBuilder.ToString(), _headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.RetrieveBusinessBookingProfileResponse>(_response.Body); _responseModel.Context = _context; return(_responseModel); }
/// <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); } }
/// <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> /// <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); } }
/// <summary> /// Provides information of all locations of a business.. /// Many Square API endpoints require a `location_id` parameter.. /// The `id` field of the [`Location`]($m/Location) objects returned by this. /// endpoint correspond to that `location_id` parameter.. /// </summary> /// <param name="cancellationToken"> cancellationToken. </param> /// <returns>Returns the Models.ListLocationsResponse response from the API call.</returns> public async Task <Models.ListLocationsResponse> ListLocationsAsync(CancellationToken cancellationToken = default) { // the base uri for api requests. string baseUri = this.Config.GetBaseUri(); // prepare query string for API call. StringBuilder queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/v2/locations"); // append request with appropriate headers and parameters var headers = new Dictionary <string, string>() { { "user-agent", this.UserAgent }, { "accept", "application/json" }, { "Square-Version", this.Config.SquareVersion }, }; // prepare the API call request to fetch the response. HttpRequest httpRequest = this.GetClientInstance().Get(queryBuilder.ToString(), headers); if (this.HttpCallBack != null) { this.HttpCallBack.OnBeforeHttpRequestEventHandler(this.GetClientInstance(), httpRequest); } httpRequest = await this.AuthManagers["global"].ApplyAsync(httpRequest).ConfigureAwait(false); // invoke request and get response. HttpStringResponse response = await this.GetClientInstance().ExecuteAsStringAsync(httpRequest, cancellationToken).ConfigureAwait(false); HttpContext context = new HttpContext(httpRequest, response); if (this.HttpCallBack != null) { this.HttpCallBack.OnAfterHttpResponseEventHandler(this.GetClientInstance(), response); } // handle errors defined at the API level. this.ValidateResponse(response, context); var responseModel = ApiHelper.JsonDeserialize <Models.ListLocationsResponse>(response.Body); responseModel.Context = context; return(responseModel); }
/// <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); } }
/// <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> /// 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); } }
/// <summary> /// Get redemption request statuses. /// </summary> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> GetRedemptionRequestStatusesAsync() { //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-statuses"); //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> /// <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); } }
/// <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); } }
public async Task <HttpResponse> ExecuteAsStringAsync(HttpRequest request) { //raise the on before request event RaiseOnBeforeHttpRequestEvent(request); HttpResponseMessage responseMessage = await HttpResponseMessage(request).ConfigureAwait(false); HttpResponse response = new HttpStringResponse { Headers = GetCombinedResponseHeaders(responseMessage), RawBody = await responseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false), Body = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false), StatusCode = (int)responseMessage.StatusCode }; //raise the on after response event RaiseOnAfterHttpResponseEvent(response); return(response); }
/// <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); }
/// <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> /// 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); }