/// <summary> /// Create a payee /// </summary> /// <param name="body">Required parameter: Payee creation object</param> /// <return>Returns the Models.PayeeCreationResponse response from the API call</return> public PayeeCreationResponse CreatePayee(PayeeCreationRequest body) { var t = CreatePayeeAsync(body); APIHelper.RunTaskSynchronously(t); return(t.GetAwaiter().GetResult()); }
/// <summary> /// Create a payee /// </summary> /// <param name="body">Required parameter: Payee creation object</param> /// <return>Returns the Models.PayeeCreationResponse response from the API call</return> public async Task <PayeeCreationResponse> CreatePayeeAsync(PayeeCreationRequest 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/payees"); //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 <PayeeCreationResponse>(response.Body)); } catch (Exception ex) { throw new APIException("Failed to parse the response: " + ex.Message, context); } }