Esempio n. 1
0
        public void PerformActionsTest()
        {
            string invoiceNumber = "12343";
            string authorization = "Basic asdadsa";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(invoiceResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new InvoicesApi(configuration);
            InvoiceAction invoiceAction = new InvoiceAction(InvoiceAction.ActionEnum.Send, "2020-10-01");
            var           response      = instance.PerformActions(invoiceNumber, invoiceAction, authorization);

            Assert.IsInstanceOf <Invoice>(response, "response is Invoice");
        }
        static async Task Main(string[] args)
        {
            var companyId   = 0;
            var accessToken = "";

            // アクセストークンを指定して、クライアントを作成する
            var config = new Configuration
            {
                AccessToken = accessToken
            };

            // 事業所の詳細情報を取得する
            var companyApi = new CompaniesApi(config);
            var company    = await companyApi.GetCompanyAsync(companyId);

            Console.WriteLine($"事業所名 : {company.Company.DisplayName}");

            // 登録されている口座の一覧を取得する
            var walletablesApi   = new WalletablesApi(config);
            var walletablesIndex = await walletablesApi.GetWalletablesAsync(companyId, true);

            foreach (var walletable in walletablesIndex.Walletables)
            {
                Console.WriteLine($"口座名 : {walletable.Name} / 登録残高 : \\{walletable.WalletableBalance:#,0}");
            }

            // 請求書の一覧を取得する
            var invoicesApi   = new InvoicesApi(config);
            var invoicesIndex = await invoicesApi.GetInvoicesAsync(companyId);

            foreach (var invoice in invoicesIndex.Invoices)
            {
                Console.WriteLine($"売上計上日 : {invoice.BookingDate ?? "未設定"} / 合計金額 : \\{invoice.TotalAmount:#,0}");
            }
        }
Esempio n. 3
0
        public void GetAllInvoicesTest()
        {
            int?   offset        = 0;
            int?   limit         = 5;
            string authorization = "Basic asdadsa";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(invoiceResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new InvoicesApi(configuration);
            var response = instance.GetAllInvoices(offset, limit, authorization);

            Assert.IsInstanceOf <InvoicesCollection>(response, "response is InvoicesCollection");
        }
        public void CanReadInvoices()
        {
            InvoicesApi api = new InvoicesApi(GetSettings());
              var invoiceTask = api.GetInvoices();
              using(var req = HttpServer.HandleRequest())
              {
            req.ResponseBodyText = Encoding.UTF8.GetString(Properties.Resources.AllInvoices);
              }

              var invoices = invoiceTask.Result;
              Assert.AreEqual(5, invoices.Count, "expecting the 5 invoices");
              Assert.True(invoices.All(x => !string.IsNullOrEmpty(x.Invoice.InvoiceNumber)));
              Assert.True(invoices.All(x => x.Invoice.DateCreated > new DateTime(2000, 1, 1)));
        }
Esempio n. 5
0
        public void UpdateInvoiceTest()
        {
            string invoiceNumber = "1236545";

            Identifier identifier = new Identifier
            {
                Email     = "*****@*****.**",
                Reference = "Refernce"
            };
            Link linkSelf       = new Link("Href1", "title", "Method");
            Link paymentMethods = new Link("Href2", "paymethodstitle", "paymethods");
            Link address        = new Link("Href3", "addresstitle", "address");

            CustomerLinks customerLinks = new CustomerLinks(linkSelf, paymentMethods, address);
            Customer      customer      = new Customer("1813221695", "customer description", identifier, customerLinks);

            LineItem        lineItem  = new LineItem("1", "Name", "Desc", 2, "4", true);
            List <LineItem> lineITems = new List <LineItem>();

            lineITems.Add(lineItem);

            Tax    tax           = new Tax(1, "tax", 2, "taxt");
            string authorization = "Basic asdadsa";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(invoiceResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new InvoicesApi(configuration);
            UpdateInvoice updateInvoice = new UpdateInvoice("update invoice ", customer, "Test", "50", 10, 2, 12, 75, lineITems, tax);
            var           response      = instance.UpdateInvoice(invoiceNumber, updateInvoice, authorization);

            Assert.IsInstanceOf <Invoice>(response, "response is Invoice");
        }
Esempio n. 6
0
        public virtual string Post([FromBody]  List <ObjectType> orderList)
        {
            bool   response = true;
            string responseText;

            // validate orderlist provided.
            (response, responseText) = Order.ValidateOrderList(orderList);
            if (!response)
            {
                return(responseText);
            }

            // Send a post request to Invoices api to insert ordelist to database.
            responseText = InvoicesApi.CreateOrder(orderList);
            return(responseText);
        }
Esempio n. 7
0
        private InvoicesApi GetApi(bool useImpersonation)
        {
            var invoicesApi    = new InvoicesApi(TestApiSettings.Uri);
            var plainTextBytes = new byte[0];

            if (useImpersonation)
            {
                plainTextBytes = System.Text.Encoding.UTF8.GetBytes(TestApiSettings.Key + ":" + TestApiSettings.Secret);
                invoicesApi.Configuration.AddDefaultHeader("Authorization", "Basic " + System.Convert.ToBase64String(plainTextBytes));
                return(invoicesApi);
            }

            plainTextBytes = System.Text.Encoding.UTF8.GetBytes(TestApiSettings.InvoiceKey + ":" + TestApiSettings.InvoiceSecret);
            invoicesApi.Configuration.AddDefaultHeader("Authorization", "Basic " + System.Convert.ToBase64String(plainTextBytes));
            return(invoicesApi);
        }
        public void CanSpecifyInvoiceFilters()
        {
            InvoicesApi api = new InvoicesApi(GetSettings());
            var invoiceTask = api.GetInvoices(new InvoiceFilter()
            {
            InvoiceStatus = InvoiceStatus.Open,
            });

            using (var req = HttpServer.HandleRequest())
            {
            Assert.IsNotNullOrEmpty(req.RawRequest.Url.Query);
            req.ResponseBodyText = Encoding.UTF8.GetString(Properties.Resources.AllInvoices);
            }

            var invoices = invoiceTask.Result;
        }
Esempio n. 9
0
        public static InvoicingV2InvoicesGet200Response Run()
        {
            string id = CreateDraftInvoice.Run().Id;

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new InvoicesApi(clientConfig);
                InvoicingV2InvoicesGet200Response result = apiInstance.GetInvoice(id);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
Esempio n. 10
0
 public void Init()
 {
     instance = new InvoicesApi();
 }
Esempio n. 11
0
        public static InvoicingV2InvoicesPost201Response Run()
        {
            string customerInformationName  = "Tanya Lee";
            string customerInformationEmail = "*****@*****.**";
            Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation(
                Name: customerInformationName,
                Email: customerInformationEmail
                );

            string   invoiceInformationDescription                   = "This is a test invoice";
            DateTime invoiceInformationDueDate                       = DateTime.Parse("2019-07-11");
            bool     invoiceInformationSendImmediately               = false;
            bool     invoiceInformationAllowPartialPayments          = true;
            string   invoiceInformationDeliveryMode                  = "none";
            Invoicingv2invoicesInvoiceInformation invoiceInformation = new Invoicingv2invoicesInvoiceInformation(
                Description: invoiceInformationDescription,
                DueDate: invoiceInformationDueDate,
                SendImmediately: invoiceInformationSendImmediately,
                AllowPartialPayments: invoiceInformationAllowPartialPayments,
                DeliveryMode: invoiceInformationDeliveryMode
                );

            string  orderInformationAmountDetailsTotalAmount          = "2623.64";
            string  orderInformationAmountDetailsCurrency             = "USD";
            string  orderInformationAmountDetailsDiscountAmount       = "126.08";
            decimal orderInformationAmountDetailsDiscountPercent      = 5.00M;
            decimal orderInformationAmountDetailsSubAmount            = 2749.72M;
            decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M;
            string  orderInformationAmountDetailsTaxDetailsType       = "State Tax";
            string  orderInformationAmountDetailsTaxDetailsAmount     = "208.00";
            string  orderInformationAmountDetailsTaxDetailsRate       = "8.25";
            Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails(
                Type: orderInformationAmountDetailsTaxDetailsType,
                Amount: orderInformationAmountDetailsTaxDetailsAmount,
                Rate: orderInformationAmountDetailsTaxDetailsRate
                );

            string orderInformationAmountDetailsFreightAmount  = "20.00";
            bool   orderInformationAmountDetailsFreightTaxable = true;
            Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight(
                Amount: orderInformationAmountDetailsFreightAmount,
                Taxable: orderInformationAmountDetailsFreightTaxable
                );

            Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency,
                DiscountAmount: orderInformationAmountDetailsDiscountAmount,
                DiscountPercent: orderInformationAmountDetailsDiscountPercent,
                SubAmount: orderInformationAmountDetailsSubAmount,
                MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount,
                TaxDetails: orderInformationAmountDetailsTaxDetails,
                Freight: orderInformationAmountDetailsFreight
                );


            List <Invoicingv2invoicesOrderInformationLineItems> orderInformationLineItems = new List <Invoicingv2invoicesOrderInformationLineItems>();
            string orderInformationLineItemsProductSku1  = "P653727383";
            string orderInformationLineItemsProductName1 = "First line item's name";
            int    orderInformationLineItemsQuantity1    = 21;
            string orderInformationLineItemsUnitPrice1   = "120.08";

            orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems(
                                              ProductSku: orderInformationLineItemsProductSku1,
                                              ProductName: orderInformationLineItemsProductName1,
                                              Quantity: orderInformationLineItemsQuantity1,
                                              UnitPrice: orderInformationLineItemsUnitPrice1
                                              ));

            Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation(
                AmountDetails: orderInformationAmountDetails,
                LineItems: orderInformationLineItems
                );

            var requestObj = new CreateInvoiceRequest(
                CustomerInformation: customerInformation,
                InvoiceInformation: invoiceInformation,
                OrderInformation: orderInformation
                );

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new InvoicesApi(clientConfig);
                InvoicingV2InvoicesPost201Response result = apiInstance.CreateInvoice(requestObj);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
Esempio n. 12
0
 public InvoicesApiTests()
 {
     instance = new InvoicesApi();
 }
Esempio n. 13
0
        /// <summary>
        /// Gets an instance of invoices API.
        /// </summary>
        /// <returns>InvoicesApi object.</returns>
        public InvoicesApi GetInvoicesApi()
        {
            var invoicesApi = new InvoicesApi(refresh_token, organisationId);

            return(invoicesApi);
        }
Esempio n. 14
0
        /// <summary>
        ///     Gets an instance of invoices API.
        /// </summary>
        /// <returns>InvoicesApi object.</returns>
        public InvoicesApi GetInvoicesApi()
        {
            var invoicesApi = new InvoicesApi(authToken, organisationId);

            return(invoicesApi);
        }