Beispiel #1
0
        public void Should_Update_Successfully_With_Impersonation_Key()
        {
            var updateInvoicesRequestModel = new UpdateInvoicesRequestModel()
            {
                AttributeValues = new Dictionary <string, string>()
                {
                    ["accountCode"] = "123",
                    ["postalCode"]  = "78701"
                },
                PaidInvoices = new List <PaidInvoiceModel>()
                {
                    new PaidInvoiceModel()
                    {
                        Id         = "112120",
                        PaidAmount = 4874.91d
                    }
                }
            };

            var  invoicesApi = GetApi(true);
            bool success     = invoicesApi.InvoicesUpdate(updateInvoicesRequestModel, TestApiSettings.InvoicesImpersonationAccountKey);

            // Should post successfully.
            Assert.IsTrue(success);
        }
Beispiel #2
0
        public void Should_Create_Transaction_Then_Update_Existing_Transaction_Successfully_With_Impersonation_Key()
        {
            var amount = new System.Random().Next(10, 1000);
            var postTransactionRequestModel = new PostTransactionRequestModel
            {
                Payer                  = "John Smith",
                EmailAddress           = "*****@*****.**",
                Amount                 = amount,
                BankAccountInformation = new BankAccountInformationModel
                {
                    AccountHolder = "John Smith",
                    FirstName     = "John",
                    LastName      = "Smith",
                    AccountNumber = "4545454",
                    RoutingNumber = "111000025",
                    AccountType   = AccountType.Personalsavings
                },
                Comments = "Sample comments"
            };

            var response = _transactionsApi.TransactionsPost(postTransactionRequestModel, TestApiSettings.InvoicesImpersonationAccountKey);

            // Should return a valid Id.
            Assert.IsTrue(response.Id > 0);

            var updateInvoicesRequestModel = new UpdateInvoicesRequestModel()
            {
                Id = response.Id.Value,
                AttributeValues = new Dictionary <string, string>()
                {
                    ["accountCode"] = "123",
                    ["postalCode"]  = "78701"
                },
                PaidInvoices = new List <PaidInvoiceModel>()
                {
                    new PaidInvoiceModel()
                    {
                        Id         = "112121",
                        PaidAmount = postTransactionRequestModel.Amount.Value / 2
                    },
                    new PaidInvoiceModel()
                    {
                        Id         = "112122",
                        PaidAmount = postTransactionRequestModel.Amount - (postTransactionRequestModel.Amount.Value / 2)
                    }
                }
            };

            bool success = GetApi(true).InvoicesUpdate(updateInvoicesRequestModel, TestApiSettings.InvoicesImpersonationAccountKey);

            // Should post successfully.
            Assert.IsTrue(success);
        }
Beispiel #3
0
        /// <summary>
        /// Updates a collection of invoices in the management system.
        /// </summary>
        /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="updateInvoicesRequestModel">The paid invoices and lookup attributes.</param>
        /// <param name="impersonationAccountKey"> (optional, default to )</param>
        /// <returns></returns>
        public bool InvoicesUpdate(UpdateInvoicesRequestModel updateInvoicesRequestModel, string impersonationAccountKey)
        {
            // verify the required parameter 'updateInvoicesRequestModel' is set
            if (updateInvoicesRequestModel == null)
            {
                throw new ApiException(400, "Missing required parameter 'updateInvoicesRequestModel' when calling InvoicesApi->InvoicesUpdate");
            }


            var localVarPath = "/api/v1/Invoices";

            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json", "text/json", "application/xml", "text/xml"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");


            if (impersonationAccountKey != null)
            {
                localVarHeaderParams.Add("impersonationAccountKey", Configuration.ApiClient.ParameterToString(impersonationAccountKey));                                  // header parameter
            }
            if (updateInvoicesRequestModel.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(updateInvoicesRequestModel); // http body (model) parameter
            }
            else
            {
                localVarPostBody = updateInvoicesRequestModel; // byte array
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (localVarStatusCode >= 400)
            {
                if (localVarStatusCode == 401)
                {
                    throw new ApiException(localVarStatusCode, "Error calling InvoicesGet: " + localVarResponse.StatusDescription);
                }
                else
                {
                    throw new ApiException(localVarStatusCode, "Error calling InvoicesGet: " + localVarResponse.Content, localVarResponse.Content);
                }
            }
            else if (localVarStatusCode == 0)
            {
                throw new ApiException(localVarStatusCode, "Error calling InvoicesUpdate: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
            }


            return(localVarStatusCode == 200);
        }