@epilot/pricing-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # `@epilot/pricing-client`
2
+
3
+ API Client for epilot Pricing APIs.
4
+
5
+ Uses [`openapi-client-axios`](https://github.com/anttiviljami/openapi-client-axios)
6
+
7
+ ## Getting Started
8
+
9
+ Install the package:
10
+
11
+ ```bash
12
+ npm install --save-dev @epilot/pricing-client
13
+ ```
14
+
15
+ Import the package:
16
+
17
+ ```typescript
18
+ import { getClient } from '@epilot/pricing-client';
19
+ ```
20
+
21
+ Use the client:
22
+ ```typescript
23
+ // get typed client
24
+ const client = await getClient();
25
+
26
+ // call an operation
27
+ const res = await client.<some-operation>();
28
+ ```
29
+
30
+ ## BaseURL & Authorization
31
+
32
+ To pass an authorization header and set up the API url, you can use axios
33
+ defaults:
34
+
35
+ ```typescript
36
+ const client = getClient();
37
+ client.defaults.baseURL = config.API_URL;
38
+ client.defaults.headers['authorization'] = `Bearer ${token}`;
39
+ ```
40
+
41
+ ## API Docs:
42
+
43
+ https://docs.api.epilot.io
@@ -0,0 +1 @@
1
+ export declare const getClient: () => import("openapi-client-axios").OpenAPIClient<import("./openapi").OperationMethods, import("./openapi").PathsDictionary>;
package/dist/client.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getClient = void 0;
7
+ var openapi_client_axios_1 = __importDefault(require("openapi-client-axios"));
8
+ var definition_1 = __importDefault(require("./definition"));
9
+ var getClient = function () {
10
+ var api = new openapi_client_axios_1.default({ definition: definition_1.default, quick: true });
11
+ return api.initSync();
12
+ };
13
+ exports.getClient = getClient;
14
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,3 @@
1
+ import type { Document } from 'openapi-client-axios';
2
+ declare const _default: Document;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ !function(e,t){for(var a in t)e[a]=t[a];t.__esModule&&Object.defineProperty(e,"__esModule",{value:!0})}(exports,(()=>{"use strict";var e={914:function(e,t,a){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=i(a(279));t.default=n.default},279:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"Pricing API","description":"This API hub sets the foundations for the following Pricing APIs:\\n\\n- Order API, provides a way to manage orders, keep track of inventory, with individual adjustments, tax calculation, and shipping, apply discounts, store tracking information, and handle returns. The responsibilities of this API contemplate the following set of features:\\n - Create or update a new Order from a Shopping Cart\\n - Marking a Shopping Cart as complete once the Order is set as open (immutable/closed for modification)\\n - Pricing features such as automatic calculation of totals and price breakdowns for taxes\\n\\n- Shopping Cart API, used to interact with a cart during a customer\'s checkout session, and is responsible for providing the following set of features:\\n - A unified data model to model a Shopping Cart\\n - Cart abandonment recovery\\n - Pricing features such as automatic calculation of totals and price breakdowns for taxes\\n - Product and pricing data validation\\n","contact":{"name":"Maintainers Channel","url":"https://epilot.slack.com/archives/C020B4URQNS"},"version":"1.0.0"},"externalDocs":{"description":"Read the full RFC here","url":"https://e-pilot.atlassian.net/wiki/spaces/~880810188/pages/5459705918/Shopping+Cart+Orders+API"},"tags":[{"name":"Public","description":"Customer-facing Endpoints (requiring a X-Ivy-Org-ID identification)"},{"name":"Cart","description":"The shopping cart management operations"},{"name":"Order","description":"The order management operations"}],"security":[{"EpilotAuth":[]},{"AsOrganization":[]}],"paths":{"/v1/public/cart":{"put":{"description":"Creates a new cart or updates an existing one.","operationId":"upsertCart","summary":"upsertCart","security":[],"tags":["Cart","Public"],"parameters":[{"in":"header","name":"X-Ivy-Org-ID","description":"The target Organization Id represented by the caller","schema":{"type":"string"},"required":true}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Cart with Line Items":{"$ref":"#/components/examples/cartCreationPayload"}}}}},"responses":{"200":{"description":"The updated Cart.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Cart with Totals and Tax Breakdown":{"$ref":"#/components/examples/cart"}}}}},"201":{"description":"The new Cart.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Cart with Totals and Tax Breakdown":{"$ref":"#/components/examples/cart"}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"Modifying a cart marked as complete":{"value":{"message":"The cart is marked as complete and can no longer be modified."}},"Modifying a cart with an invalid price":{"value":{"message":"The cart update failed due to an invalid price provided."}},"Modifying a cart with an invalid product":{"value":{"message":"The cart update failed due to an invalid provided provided."}}}}}}}}},"/v1/public/cart:finalize":{"post":{"description":"Finalizes the cart by changing its status to \'complete\'.\\nThe cart can no longer be modified after this operation.\\n","operationId":"finalizeCart","summary":"finalizeCart","tags":["Cart","Public"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"cart_id":{"type":"string","description":"The card_id to be finalized."}}}}}},"responses":{"200":{"description":"The customer\'s cart reflecting the new finalized state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Cart with Totals and Tax Breakdown":{"$ref":"#/components/examples/cartComplete"}}}}},"400":{"description":"Invalid payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Cart not found."}}}},"/v1/cart/{cart-id}":{"get":{"description":"Retrieves a cart by id.","operationId":"getCart","summary":"getCart","tags":["Cart"],"parameters":[{"in":"path","name":"cart-id","description":"The id of the cart to be fetched","required":true}],"responses":{"200":{"description":"The customer\'s cart.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Cart with Totals and Tax Breakdown":{"$ref":"#/components/examples/cart"}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Cart not found"}}},"delete":{"description":"Deletes the Cart specified and returns its content.","operationId":"deleteCart","summary":"deleteCart","tags":["Cart"],"parameters":[{"in":"path","name":"cart-id","description":"The id of the cart to be deleted","required":true}],"responses":{"200":{"description":"The customer\'s cart.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cart"},"examples":{"Content of the deleted Cart":{"$ref":"#/components/examples/cart"}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/order":{"put":{"description":"Creates a new order or updates an existing one.\\nThe upsert operation is idempotent, meaning that multiple calls will have effect just once.\\nCalling the upsert multiple times will not duplicate the items on an order.\\n\\nWhen the the `cart_id` is specified, the cart items are appended to the existing order items, or replaced in-place if they belong to the same `cart_id`.\\n\\nOn multiple updates with the same `cart_id` the line items linked with that `cart_id` (`order.line_items[]?.metadata.cart_id`) are removed and re-added.\\n","operationId":"upsertOrder","summary":"upsertOrder","tags":["Order"],"parameters":[{"in":"query","name":"cart_id","description":"The `cart_id` used to explode order items into the order.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"},"examples":{"Sample order creation":{"$ref":"#/components/examples/orderCreationPayload"}}}}},"responses":{"200":{"description":"The updated Order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"},"examples":{"Order with Totals and Tax Breakdown":{"$ref":"#/components/examples/order"}}}}},"201":{"description":"The new Order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"},"examples":{"Order with Totals and Tax Breakdown":{"$ref":"#/components/examples/order"}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pricing/calculate":{"post":{"description":"Calculates the pricing amounts for a set of price items, including aggregated totals such as subtotal, total and aggregates per tax rate.\\n","operationId":"calculatePricing","summary":"calculatePricing","tags":["Pricing"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceItems"},"examples":{"Price items sample":{"$ref":"#/components/examples/priceItemsPayload"}}}}},"responses":{"200":{"description":"The","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"},"examples":{"Order with Totals and Tax Breakdown":{"$ref":"#/components/examples/order"}}}}},"201":{"description":"The new Order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"},"examples":{"Order with Totals and Tax Breakdown":{"$ref":"#/components/examples/order"}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Epilot Bearer Token"},"AsOrganization":{"type":"apiKey","in":"header","name":"x-ivy-org-id","description":"Set organization id when using internal auth"},"AsUser":{"type":"apiKey","in":"header","name":"x-ivy-user-id","description":"Set user id when using internal auth"}},"schemas":{"Error":{"required":["message"],"properties":{"message":{"type":"string","description":"Error message"}}},"MetaData":{"description":"A set of key-value pairs.","type":"array","items":{"oneOf":[{"type":"object","description":"Key value pair entry","properties":{"key":{"type":"string","description":"Item key"},"value":{"type":"string","description":"Item value"}}}]}},"Cart":{"description":"Supports shopping for products and services until ready for converting to an order.","properties":{"id":{"type":"string","description":"The cart identifier"},"org_id":{"type":"string","description":"The user\'s Organization Id the cart belongs to","readOnly":true},"status":{"enum":["open","complete","expired"],"type":"string","readOnly":true,"description":"The status of the Cart:\\n- open - the cart checkout is still in progress. Payment processing has not started\\n- complete - the cart checkout is complete. Payment processing may still be in progress\\n- expired - the cart checkout has expired. No further processing will occur\\n"},"customer":{"readOnly":true,"type":"string","description":"ID of an existing Customer, if one exists. Or the customer data object."},"customer_email":{"type":"string","description":"A valid email identifying the customer."},"metadata":{"$ref":"#/components/schemas/MetaData"},"line_items":{"$ref":"#/components/schemas/PriceItems"},"amount_subtotal":{"readOnly":true,"type":"integer","description":"Total of all items before (discounts or) taxes are applied."},"amount_total":{"readOnly":true,"type":"integer","description":"Total of all items after (discounts and) taxes are applied."},"total_details":{"$ref":"#/components/schemas/TotalDetails"},"created_at":{"readOnly":true,"type":"string","format":"date-time"},"updated_at":{"readOnly":true,"type":"string","format":"date-time"}}},"Order":{"type":"object","description":"The order entity","properties":{"order_number":{"type":"string","description":"The Order Id Number for the customer"},"customer_email":{"type":"string","description":"A valid email identifying the customer. \\nWhen the `customer` field is filled with an ID, this field is populated/overwritten with that customer\'s email.\\n"},"customer":{"readOnly":true,"type":"string","description":"ID of an existing Customer, if one exists. Or the customer data object."},"type":{"type":"string","enum":["Draft","Open","Paid","Shipped","Delivered","Complete"],"description":"The order status"},"billing_first_name":{"type":"string"},"billing_last_name":{"type":"string"},"billing_company_name":{"type":"string"},"billing_vat":{"type":"string"},"billing_email":{"type":"string"},"billing_phone":{"type":"string"},"billing_address":{"type":"string"},"billing_contact":{"type":"string"},"metadata":{"$ref":"#/components/schemas/MetaData"},"line_items":{"$ref":"#/components/schemas/PriceItems"},"amount_subtotal":{"readOnly":true,"type":"integer","description":"Total of all items before (discounts or) taxes are applied."},"amount_total":{"readOnly":true,"type":"integer","description":"Total of all items after (discounts and) taxes are applied."},"total_details":{"$ref":"#/components/schemas/TotalDetails"},"_org_id":{"type":"string","description":"Organization Id the order belongs to"},"_id":{"type":"string","readOnly":true},"_created_at":{"type":"string","readOnly":true},"_updated_at":{"type":"string","readOnly":true}}},"PriceItems":{"description":"Tracks a set of product prices, quantities, (discounts) and taxes.","type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/PriceItem"}]}},"PriceItem":{"description":"Represents a price item","type":"object","properties":{"id":{"type":"string","description":"price item id","readOnly":true},"metadata":{"$ref":"#/components/schemas/MetaData"},"amount_subtotal":{"type":"integer","description":"Total before any (discounts or) taxes are applied.","readOnly":true},"amount_total":{"type":"integer","description":"Total after (discounts and) taxes.","readOnly":true},"currency":{"type":"string","description":"Three-letter ISO currency code, in lowercase. \\nDefaults to the customer currency when the customer or customer_email field is provided, or to EUR as a fallback.\\n"},"description":{"type":"string","description":"An arbitrary string attached to the price item. Often useful for displaying to users. Defaults to product name."},"quantity":{"type":"integer","description":"The quantity of products being purchased."},"product":{"oneOf":[{"type":"string","description":"The id of the product."},{"$ref":"#/components/schemas/Product"}]},"price":{"oneOf":[{"type":"string","description":"The id of the price."},{"$ref":"#/components/schemas/Price"}]},"taxes":{"type":"array","description":"The taxes applied to the price item.","readOnly":true,"items":{"oneOf":[{"$ref":"#/components/schemas/TaxAmount"}]}}}},"TaxAmount":{"type":"object","description":"A tax amount associated with a specific tax rate.","readOnly":true,"properties":{"amount":{"type":"integer","description":"The tax amount."},"rate":{"type":"string","description":"The tax rate applied."}}},"TotalDetails":{"type":"object","description":"The total details with tax (and discount) aggregated totals.","readOnly":true,"properties":{"amount_shipping":{"type":"integer","description":"This is the sum of all the price item shipping amounts."},"amount_tax":{"type":"integer","description":"This is the sum of all the price item tax amounts."},"breakdown":{"type":"object","description":"Breakdown of individual tax (and discount) amounts that add up to the totals.","properties":{"taxes":{"type":"array","description":"The aggregated price items tax amount per rate.","items":{"oneOf":[{"$ref":"#/components/schemas/TaxAmount"}]}}}}}},"Product":{"type":"object","description":"The product configuration","readOnly":true,"properties":{"code":{"type":"string"},"type":{"type":"string","enum":["Product","Service"]},"categories":{"type":"array","items":[{"type":"string"}]},"name":{"type":"string"},"feature":{"type":"array","items":[{"type":"object","properties":{"_tags":{"type":"array","items":[{"type":"string"}]},"feature":{"type":"string"}}}]},"active":{"type":"boolean"},"_id":{"type":"string"},"_files":{"$ref":"#/components/schemas/FileField"},"_images":{"$ref":"#/components/schemas/FileField"},"_created_at":{"type":"string"},"_updated_at":{"type":"string"},"_title":{"type":"string"},"_tags":{"type":"array","items":[{"type":"string"}]}},"example":{"$ref":"#/components/examples/product"}},"Price":{"type":"object","description":"The price configuration","readOnly":true,"properties":{"active":{"type":"boolean"},"billing_scheme":{"type":"string","enum":["Per Unit"]},"description":{"type":"string"},"sales_tax":{"type":"string","enum":["Nontaxable","Reduced (7%)","Standard (19%)"]},"tax_behavior":{"type":"string","enum":["Inclusive (Price amount includes Tax)","Exclusive (Price amount excludes Tax)"]},"tiers_mode":{"type":"string","enum":["Standard"]},"type":{"type":"string","enum":["One Time","Recurring"]},"unit_amount":{"type":"string"},"_created_at":{"type":"string"},"_id":{"type":"string"},"_title":{"type":"string"},"_updated_at":{"type":"string"}},"example":{"$ref":"#/components/examples/price"}},"FileField":{"description":"The file field","properties":{"type":{"type":"string","enum":["file","image"]},"attachments":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"key":{"type":"string"},"mime":{"type":"string"},"name":{"type":"string"},"size":{"type":"number"},"image_url":{"type":"string"},"download_url":{"type":"string"}}}]}}},"example":{"$ref":"#/components/examples/price"}}},"examples":{"cart":{"description":"Example of a Shopping Cart","value":{"id":"p0ZoB1FwH6","status":"open","org_id":123,"customer":"fe2ce36e-7577-4dff-b33e-1c7da6f91c89","customer_email":"johndoe@epilot.cloud","metadata":[{"key":"journey-id","value":"8d0a2235-97ce-42d0-88a3-e374634ca44e"}],"line_items":[{"id":"mSjGCTfn8w","description":"Wallbox Premium - Premium Price","currency":"EUR","amount_subtotal":50000,"amount_total":61500,"quantity":1,"product":{"_id":"b7185fb7-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"df240bab-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":11500,"rate":"MwSt. 23%"}]},{"id":"mZkGCTfn6p","description":"Wallbox Basic with Full Add-ons - Basic Price","currency":"EUR","amount_subtotal":50000,"amount_total":53500,"quantity":1,"product":{"_id":"zzzzzz-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":3500,"rate":"MwSt. 7%"}]}],"amount_subtotal":100000,"amount_total":115000,"total_details":{"amount_shipping":10000,"amount_tax":15000,"breakdown":[{"amount":11500,"rate":"MwSt. 23%"},{"amount":3500,"rate":"MwSt. 7%"}]},"created_at":"2021-11-10T18:02:58.318Z","updated_at":"2021-11-10T18:02:58.318Z"}},"cartComplete":{"description":"Example of a Shopping Cart marked as complete","value":{"id":"p0ZoB1FwH6","status":"complete","org_id":123,"customer":"fe2ce36e-7577-4dff-b33e-1c7da6f91c89","customer_email":"johndoe@epilot.cloud","metadata":[{"key":"journey-id","value":"8d0a2235-97ce-42d0-88a3-e374634ca44e"}],"line_items":[{"id":"mSjGCTfn8w","description":"Wallbox Premium - Premium Price","currency":"EUR","amount_subtotal":50000,"amount_total":61500,"quantity":1,"product":{"_id":"b7185fb7-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"df240bab-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":11500,"rate":"MwSt. 23%"}]},{"id":"mZkGCTfn6p","description":"Wallbox Basic with Full Add-ons - Basic Price","currency":"EUR","amount_subtotal":50000,"amount_total":53500,"quantity":1,"product":{"_id":"zzzzzz-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":3500,"rate":"MwSt. 7%"}]}],"amount_subtotal":100000,"amount_total":115000,"total_details":{"amount_shipping":10000,"amount_tax":15000,"breakdown":[{"amount":11500,"rate":"MwSt. 23%"},{"amount":3500,"rate":"MwSt. 7%"}]},"created_at":"2021-11-10T18:02:58.318Z","updated_at":"2021-11-10T18:02:58.318Z"}},"cartCreationPayload":{"description":"Example of a Cart creation payload","value":{"customer_email":"johndoe@epilot.cloud","metadata":[{"key":"journey-id","value":"8d0a2235-97ce-42d0-88a3-e374634ca44e"}],"line_items":[{"quantity":1,"product":"b7185fb7-b10f-4875-bda7-288631446555","price":"df240bab-9f71-4a9a-a9e1-59f18827dbf9"},{"quantity":1,"product":"zzzzzz-b10f-4875-bda7-288631446555","price":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9"}]}},"orderCreationPayload":{"description":"Example of an Order creation payload","value":{"order_number":"a34234jd","customer_email":"johndoe@epilot.cloud","metadata":[{"key":"journey-id","value":"8d0a2235-97ce-42d0-88a3-e374634ca44e"}],"billing_first_name":"john","billing_last_name":"doe","billing_company_name":"i me and myself","billing_vat":234823948,"billing_email":"johndoe@nowhere.com","billing_phone":1234234545,"billing_address":"wallstreet, 1","billing_contact":"villy or zilly","line_items":[{"quantity":1,"product":"b7185fb7-b10f-4875-bda7-288631446555","price":"df240bab-9f71-4a9a-a9e1-59f18827dbf9"},{"quantity":1,"product":"zzzzzz-b10f-4875-bda7-288631446555","price":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9"}]}},"order":{"description":"Example of an Order","value":{"_id":"d1ZoC1FwZ6","type":"open","_org_id":123,"customer":"fe2ce36e-7577-4dff-b33e-1c7da6f91c89","customer_email":"johndoe@epilot.cloud","metadata":[{"key":"journey-id","value":"8d0a2235-97ce-42d0-88a3-e374634ca44e"},{"key":"cart-id-1","value":"p0ZoB1FwH6"}],"billing_first_name":"john","billing_last_name":"doe","billing_company_name":"i me and myself","billing_vat":234823948,"billing_email":"johndoe@nowhere.com","billing_phone":1234234545,"billing_address":"wallstreet, 1","billing_contact":"villy or zilly","line_items":[{"id":"mSjGCTfn8w","cart_id":"p0ZoB1FwH6","description":"Wallbox Premium - Premium Price","currency":"EUR","amount_subtotal":50000,"amount_total":61500,"quantity":1,"product":{"_id":"b7185fb7-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"df240bab-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":11500,"rate":"MwSt. 23%"}]},{"id":"mZkGCTfn6p","cart_id":"p0ZoB1FwH6","description":"Wallbox Basic with Full Add-ons - Basic Price","currency":"EUR","amount_subtotal":50000,"amount_total":53500,"quantity":1,"product":{"_id":"zzzzzz-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":3500,"rate":"MwSt. 7%"}]}],"amount_subtotal":100000,"amount_total":115000,"total_details":{"amount_shipping":10000,"amount_tax":15000,"breakdown":[{"amount":11500,"rate":"MwSt. 23%"},{"amount":3500,"rate":"MwSt. 7%"}]},"_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z"}},"priceItemsPayload":{"description":"A price items payload example","value":{"items":[{"id":"mSjGCTfn8w","cart_id":"p0ZoB1FwH6","description":"Wallbox Premium - Premium Price","currency":"EUR","amount_subtotal":50000,"amount_total":61500,"quantity":1,"product":{"_id":"b7185fb7-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"df240bab-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":11500,"rate":"MwSt. 23%"}]},{"id":"mZkGCTfn6p","cart_id":"p0ZoB1FwH6","description":"Wallbox Basic with Full Add-ons - Basic Price","currency":"EUR","amount_subtotal":50000,"amount_total":53500,"quantity":1,"product":{"_id":"zzzzzz-b10f-4875-bda7-288631446555","name":"Alfen Eve Single S-line Wallbox","code":904460583,"categories":["House Connection"]},"price":{"_id":"zzzzz-9f71-4a9a-a9e1-59f18827dbf9","unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"},"taxes":[{"amount":3500,"rate":"MwSt. 7%"}]}]}},"product":{"description":"A product example","value":{"name":"Alfen Eve Single S-line Wallbox","code":"904460583","categories":["House Connection"],"type":"Product","active":true,"_id":"b7185fb7-b10f-4875-bda7-288631446555","_created_at":"2021-11-10T18:01:39.681Z","_updated_at":"2021-11-11T10:40:23.430Z","_title":"Alfen Eve Single S-line Wallbox","_tags":["product review demo"],"feature":[{"_tags":[],"feature":"Bis zu 11 kW Ladeleistung (5x schneller laden)"},{"_tags":[],"feature":"Konfigurierbare Ladeleistung"},{"_tags":[],"feature":"Zugangskontrolle über RFID-Karten"}],"_images":{"type":"image","attachments":[{"key":"files/ckvtu0lq5000108me1pdc7y4k/original","mime":"image/jpeg","name":"juice-charger-me_closeup_bottom.jpeg","size":38210,"image_url":"https://avkhavsdjq.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu0lq5000108me1pdc7y4k/original?w=100","download_url":"https://e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu0lq5000108me1pdc7y4k/original","alt_text":""},{"key":"files/ckvtu06ny000008me01xl79ot/original","mime":"image/jpeg","name":"eve-single-s-line-socket-front-_1__web_1.jpeg","size":11587,"image_url":"https://avkhavsdjq.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu06ny000008me01xl79ot/original?w=100","download_url":"https://e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu06ny000008me01xl79ot/original","alt_text":""}]},"_files":{"type":"file","attachments":[{"key":"files/ckvutl6wp00000al5cx8063nz/original","mime":"application/pdf","name":"Wallbox_Pulsar-Plus_technisches-Datenblatt.pdf","size":171501,"image_url":"https://avkhavsdjq.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvutl6wp00000al5cx8063nz/original?w=100","download_url":"https://e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvutl6wp00000al5cx8063nz/original","alt_text":""}]}}},"price":{"description":"A price example","value":{"unit_amount":"€ 789","type":"One Time","active":true,"sales_tax":"Standard (19%)","tax_behavior":"Inclusive (Price amount includes Tax)","description":"Winter Sale","billing_scheme":"Per Unit","tiers_mode":"Standard","_schema":"price","_id":"8ca293d6-89f5-4b20-98f5-fa68341ef611","_org":"739224","_created_at":"2021-11-10T18:02:58.318Z","_updated_at":"2021-11-10T18:02:58.318Z","_title":"Winter Sale"}},"fileField":{"description":"A File Field example","value":{"type":"image","attachments":[{"key":"files/ckvtu0lq5000108me1pdc7y4k/original","mime":"image/jpeg","name":"juice-charger-me_closeup_bottom.jpeg","size":38210,"image_url":"https://avkhavsdjq.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu0lq5000108me1pdc7y4k/original?w=100","download_url":"https://e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu0lq5000108me1pdc7y4k/original","alt_text":""},{"key":"files/ckvtu06ny000008me01xl79ot/original","mime":"image/jpeg","name":"eve-single-s-line-socket-front-_1__web_1.jpeg","size":11587,"image_url":"https://avkhavsdjq.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu06ny000008me01xl79ot/original?w=100","download_url":"https://e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/ckvtu06ny000008me01xl79ot/original","alt_text":""}]}}}}}')}},t={};return function a(i){if(t[i])return t[i].exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,a),n.exports}(914)})());
@@ -0,0 +1,3 @@
1
+ export * from './client';
2
+ export type { Client, Components, Paths, PathsDictionary, OperationMethods } from './openapi';
3
+ export type { OpenAPIClient, OpenAPIClientAxios, Document } from 'openapi-client-axios';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./client"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,484 @@
1
+ /* eslint-disable */
2
+ import {
3
+ OpenAPIClient,
4
+ Parameters,
5
+ UnknownParamsObject,
6
+ OperationResponse,
7
+ AxiosRequestConfig,
8
+ } from 'openapi-client-axios';
9
+
10
+ declare namespace Components {
11
+ namespace Schemas {
12
+ /**
13
+ * Supports shopping for products and services until ready for converting to an order.
14
+ */
15
+ export interface Cart {
16
+ /**
17
+ * The cart identifier
18
+ */
19
+ id?: string;
20
+ /**
21
+ * The user's Organization Id the cart belongs to
22
+ */
23
+ readonly org_id?: string;
24
+ /**
25
+ * The status of the Cart:
26
+ * - open - the cart checkout is still in progress. Payment processing has not started
27
+ * - complete - the cart checkout is complete. Payment processing may still be in progress
28
+ * - expired - the cart checkout has expired. No further processing will occur
29
+ *
30
+ */
31
+ readonly status?: "open" | "complete" | "expired";
32
+ /**
33
+ * ID of an existing Customer, if one exists. Or the customer data object.
34
+ */
35
+ readonly customer?: string;
36
+ /**
37
+ * A valid email identifying the customer.
38
+ */
39
+ customer_email?: string;
40
+ metadata?: MetaData;
41
+ line_items?: PriceItems;
42
+ /**
43
+ * Total of all items before (discounts or) taxes are applied.
44
+ */
45
+ readonly amount_subtotal?: number;
46
+ /**
47
+ * Total of all items after (discounts and) taxes are applied.
48
+ */
49
+ readonly amount_total?: number;
50
+ total_details?: TotalDetails;
51
+ readonly created_at?: string; // date-time
52
+ readonly updated_at?: string; // date-time
53
+ }
54
+ export interface Error {
55
+ /**
56
+ * Error message
57
+ */
58
+ message: string;
59
+ }
60
+ /**
61
+ * The file field
62
+ * example:
63
+ * {
64
+ * "$ref": "#/components/examples/price"
65
+ * }
66
+ */
67
+ export interface FileField {
68
+ type?: "file" | "image";
69
+ attachments?: ({
70
+ key?: string;
71
+ mime?: string;
72
+ name?: string;
73
+ size?: number;
74
+ image_url?: string;
75
+ download_url?: string;
76
+ })[];
77
+ }
78
+ /**
79
+ * A set of key-value pairs.
80
+ */
81
+ export type MetaData = ({
82
+ /**
83
+ * Item key
84
+ */
85
+ key?: string;
86
+ /**
87
+ * Item value
88
+ */
89
+ value?: string;
90
+ })[];
91
+ /**
92
+ * The order entity
93
+ */
94
+ export interface Order {
95
+ /**
96
+ * The Order Id Number for the customer
97
+ */
98
+ order_number?: string;
99
+ /**
100
+ * A valid email identifying the customer.
101
+ * When the `customer` field is filled with an ID, this field is populated/overwritten with that customer's email.
102
+ *
103
+ */
104
+ customer_email?: string;
105
+ /**
106
+ * ID of an existing Customer, if one exists. Or the customer data object.
107
+ */
108
+ readonly customer?: string;
109
+ /**
110
+ * The order status
111
+ */
112
+ type?: "Draft" | "Open" | "Paid" | "Shipped" | "Delivered" | "Complete";
113
+ billing_first_name?: string;
114
+ billing_last_name?: string;
115
+ billing_company_name?: string;
116
+ billing_vat?: string;
117
+ billing_email?: string;
118
+ billing_phone?: string;
119
+ billing_address?: string;
120
+ billing_contact?: string;
121
+ metadata?: MetaData;
122
+ line_items?: PriceItems;
123
+ /**
124
+ * Total of all items before (discounts or) taxes are applied.
125
+ */
126
+ readonly amount_subtotal?: number;
127
+ /**
128
+ * Total of all items after (discounts and) taxes are applied.
129
+ */
130
+ readonly amount_total?: number;
131
+ total_details?: TotalDetails;
132
+ /**
133
+ * Organization Id the order belongs to
134
+ */
135
+ _org_id?: string;
136
+ readonly _id?: string;
137
+ readonly _created_at?: string;
138
+ readonly _updated_at?: string;
139
+ }
140
+ /**
141
+ * The price configuration
142
+ * example:
143
+ * {
144
+ * "$ref": "#/components/examples/price"
145
+ * }
146
+ */
147
+ export interface Price {
148
+ active?: boolean;
149
+ billing_scheme?: "Per Unit";
150
+ description?: string;
151
+ sales_tax?: "Nontaxable" | "Reduced (7%)" | "Standard (19%)";
152
+ tax_behavior?: "Inclusive (Price amount includes Tax)" | "Exclusive (Price amount excludes Tax)";
153
+ tiers_mode?: "Standard";
154
+ type?: "One Time" | "Recurring";
155
+ unit_amount?: string;
156
+ _created_at?: string;
157
+ _id?: string;
158
+ _title?: string;
159
+ _updated_at?: string;
160
+ }
161
+ /**
162
+ * Represents a price item
163
+ */
164
+ export interface PriceItem {
165
+ /**
166
+ * price item id
167
+ */
168
+ readonly id?: string;
169
+ metadata?: MetaData;
170
+ /**
171
+ * Total before any (discounts or) taxes are applied.
172
+ */
173
+ readonly amount_subtotal?: number;
174
+ /**
175
+ * Total after (discounts and) taxes.
176
+ */
177
+ readonly amount_total?: number;
178
+ /**
179
+ * Three-letter ISO currency code, in lowercase.
180
+ * Defaults to the customer currency when the customer or customer_email field is provided, or to EUR as a fallback.
181
+ *
182
+ */
183
+ currency?: string;
184
+ /**
185
+ * An arbitrary string attached to the price item. Often useful for displaying to users. Defaults to product name.
186
+ */
187
+ description?: string;
188
+ /**
189
+ * The quantity of products being purchased.
190
+ */
191
+ quantity?: number;
192
+ product?: string | Product;
193
+ price?: string | Price;
194
+ /**
195
+ * The taxes applied to the price item.
196
+ */
197
+ readonly taxes?: (TaxAmount)[];
198
+ }
199
+ /**
200
+ * Tracks a set of product prices, quantities, (discounts) and taxes.
201
+ */
202
+ export type PriceItems = (PriceItem)[];
203
+ /**
204
+ * The product configuration
205
+ * example:
206
+ * {
207
+ * "$ref": "#/components/examples/product"
208
+ * }
209
+ */
210
+ export interface Product {
211
+ code?: string;
212
+ type?: "Product" | "Service";
213
+ categories?: [string?, ...any[]];
214
+ name?: string;
215
+ feature?: [{
216
+ _tags?: [string?, ...any[]];
217
+ feature?: string;
218
+ }?, ...any[]];
219
+ active?: boolean;
220
+ _id?: string;
221
+ _files?: FileField;
222
+ _images?: FileField;
223
+ _created_at?: string;
224
+ _updated_at?: string;
225
+ _title?: string;
226
+ _tags?: [string?, ...any[]];
227
+ }
228
+ /**
229
+ * A tax amount associated with a specific tax rate.
230
+ */
231
+ export interface TaxAmount {
232
+ /**
233
+ * The tax amount.
234
+ */
235
+ amount?: number;
236
+ /**
237
+ * The tax rate applied.
238
+ */
239
+ rate?: string;
240
+ }
241
+ /**
242
+ * The total details with tax (and discount) aggregated totals.
243
+ */
244
+ export interface TotalDetails {
245
+ /**
246
+ * This is the sum of all the price item shipping amounts.
247
+ */
248
+ amount_shipping?: number;
249
+ /**
250
+ * This is the sum of all the price item tax amounts.
251
+ */
252
+ amount_tax?: number;
253
+ /**
254
+ * Breakdown of individual tax (and discount) amounts that add up to the totals.
255
+ */
256
+ breakdown?: {
257
+ /**
258
+ * The aggregated price items tax amount per rate.
259
+ */
260
+ taxes?: (TaxAmount)[];
261
+ };
262
+ }
263
+ }
264
+ }
265
+ declare namespace Paths {
266
+ namespace CalculatePricing {
267
+ export type RequestBody = Components.Schemas.PriceItems;
268
+ namespace Responses {
269
+ export type $200 = Components.Schemas.Order;
270
+ export type $201 = Components.Schemas.Order;
271
+ export type $400 = Components.Schemas.Error;
272
+ }
273
+ }
274
+ namespace DeleteCart {
275
+ namespace Responses {
276
+ export type $200 = Components.Schemas.Cart;
277
+ export type $400 = Components.Schemas.Error;
278
+ }
279
+ }
280
+ namespace FinalizeCart {
281
+ export interface RequestBody {
282
+ /**
283
+ * The card_id to be finalized.
284
+ */
285
+ cart_id?: string;
286
+ }
287
+ namespace Responses {
288
+ export type $200 = Components.Schemas.Cart;
289
+ export type $400 = Components.Schemas.Error;
290
+ }
291
+ }
292
+ namespace GetCart {
293
+ namespace Responses {
294
+ export type $200 = Components.Schemas.Cart;
295
+ export type $400 = Components.Schemas.Error;
296
+ }
297
+ }
298
+ namespace UpsertCart {
299
+ export interface HeaderParameters {
300
+ "X-Ivy-Org-ID": Parameters.XIvyOrgID;
301
+ }
302
+ namespace Parameters {
303
+ export type XIvyOrgID = string;
304
+ }
305
+ export type RequestBody = Components.Schemas.Cart;
306
+ namespace Responses {
307
+ export type $200 = Components.Schemas.Cart;
308
+ export type $201 = Components.Schemas.Cart;
309
+ export type $400 = Components.Schemas.Error;
310
+ }
311
+ }
312
+ namespace UpsertOrder {
313
+ namespace Parameters {
314
+ export type CartId = string;
315
+ }
316
+ export interface QueryParameters {
317
+ cart_id?: Parameters.CartId;
318
+ }
319
+ export type RequestBody = Components.Schemas.Order;
320
+ namespace Responses {
321
+ export type $200 = Components.Schemas.Order;
322
+ export type $201 = Components.Schemas.Order;
323
+ export type $400 = Components.Schemas.Error;
324
+ }
325
+ }
326
+ }
327
+
328
+ export interface OperationMethods {
329
+ /**
330
+ * upsertCart - upsertCart
331
+ *
332
+ * Creates a new cart or updates an existing one.
333
+ */
334
+ 'upsertCart'(
335
+ parameters?: Parameters<Paths.UpsertCart.HeaderParameters> | null,
336
+ data?: Paths.UpsertCart.RequestBody,
337
+ config?: AxiosRequestConfig
338
+ ): OperationResponse<Paths.UpsertCart.Responses.$200 | Paths.UpsertCart.Responses.$201 | Paths.UpsertCart.Responses.$400>
339
+ /**
340
+ * finalizeCart - finalizeCart
341
+ *
342
+ * Finalizes the cart by changing its status to 'complete'.
343
+ * The cart can no longer be modified after this operation.
344
+ *
345
+ */
346
+ 'finalizeCart'(
347
+ parameters?: Parameters<UnknownParamsObject> | null,
348
+ data?: Paths.FinalizeCart.RequestBody,
349
+ config?: AxiosRequestConfig
350
+ ): OperationResponse<Paths.FinalizeCart.Responses.$200 | Paths.FinalizeCart.Responses.$400>
351
+ /**
352
+ * getCart - getCart
353
+ *
354
+ * Retrieves a cart by id.
355
+ */
356
+ 'getCart'(
357
+ parameters?: Parameters<UnknownParamsObject> | null,
358
+ data?: any,
359
+ config?: AxiosRequestConfig
360
+ ): OperationResponse<Paths.GetCart.Responses.$200 | Paths.GetCart.Responses.$400>
361
+ /**
362
+ * deleteCart - deleteCart
363
+ *
364
+ * Deletes the Cart specified and returns its content.
365
+ */
366
+ 'deleteCart'(
367
+ parameters?: Parameters<UnknownParamsObject> | null,
368
+ data?: any,
369
+ config?: AxiosRequestConfig
370
+ ): OperationResponse<Paths.DeleteCart.Responses.$200 | Paths.DeleteCart.Responses.$400>
371
+ /**
372
+ * upsertOrder - upsertOrder
373
+ *
374
+ * Creates a new order or updates an existing one.
375
+ * The upsert operation is idempotent, meaning that multiple calls will have effect just once.
376
+ * Calling the upsert multiple times will not duplicate the items on an order.
377
+ *
378
+ * When the the `cart_id` is specified, the cart items are appended to the existing order items, or replaced in-place if they belong to the same `cart_id`.
379
+ *
380
+ * On multiple updates with the same `cart_id` the line items linked with that `cart_id` (`order.line_items[]?.metadata.cart_id`) are removed and re-added.
381
+ *
382
+ */
383
+ 'upsertOrder'(
384
+ parameters?: Parameters<Paths.UpsertOrder.QueryParameters> | null,
385
+ data?: Paths.UpsertOrder.RequestBody,
386
+ config?: AxiosRequestConfig
387
+ ): OperationResponse<Paths.UpsertOrder.Responses.$200 | Paths.UpsertOrder.Responses.$201 | Paths.UpsertOrder.Responses.$400>
388
+ /**
389
+ * calculatePricing - calculatePricing
390
+ *
391
+ * Calculates the pricing amounts for a set of price items, including aggregated totals such as subtotal, total and aggregates per tax rate.
392
+ *
393
+ */
394
+ 'calculatePricing'(
395
+ parameters?: Parameters<UnknownParamsObject> | null,
396
+ data?: Paths.CalculatePricing.RequestBody,
397
+ config?: AxiosRequestConfig
398
+ ): OperationResponse<Paths.CalculatePricing.Responses.$200 | Paths.CalculatePricing.Responses.$201 | Paths.CalculatePricing.Responses.$400>
399
+ }
400
+
401
+ export interface PathsDictionary {
402
+ ['/v1/public/cart']: {
403
+ /**
404
+ * upsertCart - upsertCart
405
+ *
406
+ * Creates a new cart or updates an existing one.
407
+ */
408
+ 'put'(
409
+ parameters?: Parameters<Paths.UpsertCart.HeaderParameters> | null,
410
+ data?: Paths.UpsertCart.RequestBody,
411
+ config?: AxiosRequestConfig
412
+ ): OperationResponse<Paths.UpsertCart.Responses.$200 | Paths.UpsertCart.Responses.$201 | Paths.UpsertCart.Responses.$400>
413
+ }
414
+ ['/v1/public/cart:finalize']: {
415
+ /**
416
+ * finalizeCart - finalizeCart
417
+ *
418
+ * Finalizes the cart by changing its status to 'complete'.
419
+ * The cart can no longer be modified after this operation.
420
+ *
421
+ */
422
+ 'post'(
423
+ parameters?: Parameters<UnknownParamsObject> | null,
424
+ data?: Paths.FinalizeCart.RequestBody,
425
+ config?: AxiosRequestConfig
426
+ ): OperationResponse<Paths.FinalizeCart.Responses.$200 | Paths.FinalizeCart.Responses.$400>
427
+ }
428
+ ['/v1/cart/{cart-id}']: {
429
+ /**
430
+ * getCart - getCart
431
+ *
432
+ * Retrieves a cart by id.
433
+ */
434
+ 'get'(
435
+ parameters?: Parameters<UnknownParamsObject> | null,
436
+ data?: any,
437
+ config?: AxiosRequestConfig
438
+ ): OperationResponse<Paths.GetCart.Responses.$200 | Paths.GetCart.Responses.$400>
439
+ /**
440
+ * deleteCart - deleteCart
441
+ *
442
+ * Deletes the Cart specified and returns its content.
443
+ */
444
+ 'delete'(
445
+ parameters?: Parameters<UnknownParamsObject> | null,
446
+ data?: any,
447
+ config?: AxiosRequestConfig
448
+ ): OperationResponse<Paths.DeleteCart.Responses.$200 | Paths.DeleteCart.Responses.$400>
449
+ }
450
+ ['/v1/order']: {
451
+ /**
452
+ * upsertOrder - upsertOrder
453
+ *
454
+ * Creates a new order or updates an existing one.
455
+ * The upsert operation is idempotent, meaning that multiple calls will have effect just once.
456
+ * Calling the upsert multiple times will not duplicate the items on an order.
457
+ *
458
+ * When the the `cart_id` is specified, the cart items are appended to the existing order items, or replaced in-place if they belong to the same `cart_id`.
459
+ *
460
+ * On multiple updates with the same `cart_id` the line items linked with that `cart_id` (`order.line_items[]?.metadata.cart_id`) are removed and re-added.
461
+ *
462
+ */
463
+ 'put'(
464
+ parameters?: Parameters<Paths.UpsertOrder.QueryParameters> | null,
465
+ data?: Paths.UpsertOrder.RequestBody,
466
+ config?: AxiosRequestConfig
467
+ ): OperationResponse<Paths.UpsertOrder.Responses.$200 | Paths.UpsertOrder.Responses.$201 | Paths.UpsertOrder.Responses.$400>
468
+ }
469
+ ['/v1/pricing/calculate']: {
470
+ /**
471
+ * calculatePricing - calculatePricing
472
+ *
473
+ * Calculates the pricing amounts for a set of price items, including aggregated totals such as subtotal, total and aggregates per tax rate.
474
+ *
475
+ */
476
+ 'post'(
477
+ parameters?: Parameters<UnknownParamsObject> | null,
478
+ data?: Paths.CalculatePricing.RequestBody,
479
+ config?: AxiosRequestConfig
480
+ ): OperationResponse<Paths.CalculatePricing.Responses.$200 | Paths.CalculatePricing.Responses.$201 | Paths.CalculatePricing.Responses.$400>
481
+ }
482
+ }
483
+
484
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@epilot/pricing-client",
3
+ "version": "0.1.0",
4
+ "description": "Client for epilot Pricing APIs",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://gitlab.com/e-pilot/product/checkout-and-pricing/pricing.git",
10
+ "directory": "client"
11
+ },
12
+ "homepage": "https://gitlab.com/e-pilot/product/checkout-and-pricing/pricing#readme",
13
+ "keywords": [
14
+ "order", "cart", "pricing"
15
+ ],
16
+ "scripts": {
17
+ "test": "jest",
18
+ "typescript": "tsc",
19
+ "bundle-definition": "webpack",
20
+ "openapi": "openapi read --json ../lambda/ApiHandlerFunction/openapi.yml > src/openapi.json",
21
+ "typegen": "echo '/* eslint-disable */' > src/openapi.d.ts && typegen ../lambda/ApiHandlerFunction/openapi.yml >> src/openapi.d.ts",
22
+ "build": "npm run openapi && npm run typegen && npm run typescript && npm run bundle-definition",
23
+ "eslint": "../node_modules/.bin/eslint -c ../.eslintrc.yml",
24
+ "prepublishOnly": "npm run build"
25
+ },
26
+ "files": [
27
+ "*.js",
28
+ "*.d.ts",
29
+ "**/*.js",
30
+ "**/*.d.ts",
31
+ "!*.test.*",
32
+ "!**/*.test.*",
33
+ "!node_modules",
34
+ "!src",
35
+ "!*.config.js"
36
+ ],
37
+ "author": "epilot GmbH",
38
+ "license": "UNLICENSED",
39
+ "peerDependencies": {
40
+ "axios": "^0.21.1"
41
+ },
42
+ "dependencies": {
43
+ "buffer": "^6.0.3",
44
+ "https-browserify": "^1.0.0",
45
+ "openapi-client-axios": "^3.13.1",
46
+ "stream-http": "^3.1.1",
47
+ "url": "^0.11.0",
48
+ "util": "^0.12.3"
49
+ },
50
+ "devDependencies": {
51
+ "@types/jest": "^26.0.20",
52
+ "axios": "^0.21.1",
53
+ "copy-webpack-plugin": "^7.0.0",
54
+ "jest": "^26.6.3",
55
+ "json-loader": "^0.5.7",
56
+ "openapi-client-axios-typegen": "^3.13.1",
57
+ "openapicmd": "^1.6.2",
58
+ "ts-jest": "^26.5.0",
59
+ "ts-loader": "^8.0.14",
60
+ "ts-node": "^9.1.1",
61
+ "typescript": "^4.1.3",
62
+ "webpack": "^5.18.0",
63
+ "webpack-cli": "^4.4.0"
64
+ }
65
+ }
@@ -0,0 +1,484 @@
1
+ /* eslint-disable */
2
+ import {
3
+ OpenAPIClient,
4
+ Parameters,
5
+ UnknownParamsObject,
6
+ OperationResponse,
7
+ AxiosRequestConfig,
8
+ } from 'openapi-client-axios';
9
+
10
+ declare namespace Components {
11
+ namespace Schemas {
12
+ /**
13
+ * Supports shopping for products and services until ready for converting to an order.
14
+ */
15
+ export interface Cart {
16
+ /**
17
+ * The cart identifier
18
+ */
19
+ id?: string;
20
+ /**
21
+ * The user's Organization Id the cart belongs to
22
+ */
23
+ readonly org_id?: string;
24
+ /**
25
+ * The status of the Cart:
26
+ * - open - the cart checkout is still in progress. Payment processing has not started
27
+ * - complete - the cart checkout is complete. Payment processing may still be in progress
28
+ * - expired - the cart checkout has expired. No further processing will occur
29
+ *
30
+ */
31
+ readonly status?: "open" | "complete" | "expired";
32
+ /**
33
+ * ID of an existing Customer, if one exists. Or the customer data object.
34
+ */
35
+ readonly customer?: string;
36
+ /**
37
+ * A valid email identifying the customer.
38
+ */
39
+ customer_email?: string;
40
+ metadata?: MetaData;
41
+ line_items?: PriceItems;
42
+ /**
43
+ * Total of all items before (discounts or) taxes are applied.
44
+ */
45
+ readonly amount_subtotal?: number;
46
+ /**
47
+ * Total of all items after (discounts and) taxes are applied.
48
+ */
49
+ readonly amount_total?: number;
50
+ total_details?: TotalDetails;
51
+ readonly created_at?: string; // date-time
52
+ readonly updated_at?: string; // date-time
53
+ }
54
+ export interface Error {
55
+ /**
56
+ * Error message
57
+ */
58
+ message: string;
59
+ }
60
+ /**
61
+ * The file field
62
+ * example:
63
+ * {
64
+ * "$ref": "#/components/examples/price"
65
+ * }
66
+ */
67
+ export interface FileField {
68
+ type?: "file" | "image";
69
+ attachments?: ({
70
+ key?: string;
71
+ mime?: string;
72
+ name?: string;
73
+ size?: number;
74
+ image_url?: string;
75
+ download_url?: string;
76
+ })[];
77
+ }
78
+ /**
79
+ * A set of key-value pairs.
80
+ */
81
+ export type MetaData = ({
82
+ /**
83
+ * Item key
84
+ */
85
+ key?: string;
86
+ /**
87
+ * Item value
88
+ */
89
+ value?: string;
90
+ })[];
91
+ /**
92
+ * The order entity
93
+ */
94
+ export interface Order {
95
+ /**
96
+ * The Order Id Number for the customer
97
+ */
98
+ order_number?: string;
99
+ /**
100
+ * A valid email identifying the customer.
101
+ * When the `customer` field is filled with an ID, this field is populated/overwritten with that customer's email.
102
+ *
103
+ */
104
+ customer_email?: string;
105
+ /**
106
+ * ID of an existing Customer, if one exists. Or the customer data object.
107
+ */
108
+ readonly customer?: string;
109
+ /**
110
+ * The order status
111
+ */
112
+ type?: "Draft" | "Open" | "Paid" | "Shipped" | "Delivered" | "Complete";
113
+ billing_first_name?: string;
114
+ billing_last_name?: string;
115
+ billing_company_name?: string;
116
+ billing_vat?: string;
117
+ billing_email?: string;
118
+ billing_phone?: string;
119
+ billing_address?: string;
120
+ billing_contact?: string;
121
+ metadata?: MetaData;
122
+ line_items?: PriceItems;
123
+ /**
124
+ * Total of all items before (discounts or) taxes are applied.
125
+ */
126
+ readonly amount_subtotal?: number;
127
+ /**
128
+ * Total of all items after (discounts and) taxes are applied.
129
+ */
130
+ readonly amount_total?: number;
131
+ total_details?: TotalDetails;
132
+ /**
133
+ * Organization Id the order belongs to
134
+ */
135
+ _org_id?: string;
136
+ readonly _id?: string;
137
+ readonly _created_at?: string;
138
+ readonly _updated_at?: string;
139
+ }
140
+ /**
141
+ * The price configuration
142
+ * example:
143
+ * {
144
+ * "$ref": "#/components/examples/price"
145
+ * }
146
+ */
147
+ export interface Price {
148
+ active?: boolean;
149
+ billing_scheme?: "Per Unit";
150
+ description?: string;
151
+ sales_tax?: "Nontaxable" | "Reduced (7%)" | "Standard (19%)";
152
+ tax_behavior?: "Inclusive (Price amount includes Tax)" | "Exclusive (Price amount excludes Tax)";
153
+ tiers_mode?: "Standard";
154
+ type?: "One Time" | "Recurring";
155
+ unit_amount?: string;
156
+ _created_at?: string;
157
+ _id?: string;
158
+ _title?: string;
159
+ _updated_at?: string;
160
+ }
161
+ /**
162
+ * Represents a price item
163
+ */
164
+ export interface PriceItem {
165
+ /**
166
+ * price item id
167
+ */
168
+ readonly id?: string;
169
+ metadata?: MetaData;
170
+ /**
171
+ * Total before any (discounts or) taxes are applied.
172
+ */
173
+ readonly amount_subtotal?: number;
174
+ /**
175
+ * Total after (discounts and) taxes.
176
+ */
177
+ readonly amount_total?: number;
178
+ /**
179
+ * Three-letter ISO currency code, in lowercase.
180
+ * Defaults to the customer currency when the customer or customer_email field is provided, or to EUR as a fallback.
181
+ *
182
+ */
183
+ currency?: string;
184
+ /**
185
+ * An arbitrary string attached to the price item. Often useful for displaying to users. Defaults to product name.
186
+ */
187
+ description?: string;
188
+ /**
189
+ * The quantity of products being purchased.
190
+ */
191
+ quantity?: number;
192
+ product?: string | Product;
193
+ price?: string | Price;
194
+ /**
195
+ * The taxes applied to the price item.
196
+ */
197
+ readonly taxes?: (TaxAmount)[];
198
+ }
199
+ /**
200
+ * Tracks a set of product prices, quantities, (discounts) and taxes.
201
+ */
202
+ export type PriceItems = (PriceItem)[];
203
+ /**
204
+ * The product configuration
205
+ * example:
206
+ * {
207
+ * "$ref": "#/components/examples/product"
208
+ * }
209
+ */
210
+ export interface Product {
211
+ code?: string;
212
+ type?: "Product" | "Service";
213
+ categories?: [string?, ...any[]];
214
+ name?: string;
215
+ feature?: [{
216
+ _tags?: [string?, ...any[]];
217
+ feature?: string;
218
+ }?, ...any[]];
219
+ active?: boolean;
220
+ _id?: string;
221
+ _files?: FileField;
222
+ _images?: FileField;
223
+ _created_at?: string;
224
+ _updated_at?: string;
225
+ _title?: string;
226
+ _tags?: [string?, ...any[]];
227
+ }
228
+ /**
229
+ * A tax amount associated with a specific tax rate.
230
+ */
231
+ export interface TaxAmount {
232
+ /**
233
+ * The tax amount.
234
+ */
235
+ amount?: number;
236
+ /**
237
+ * The tax rate applied.
238
+ */
239
+ rate?: string;
240
+ }
241
+ /**
242
+ * The total details with tax (and discount) aggregated totals.
243
+ */
244
+ export interface TotalDetails {
245
+ /**
246
+ * This is the sum of all the price item shipping amounts.
247
+ */
248
+ amount_shipping?: number;
249
+ /**
250
+ * This is the sum of all the price item tax amounts.
251
+ */
252
+ amount_tax?: number;
253
+ /**
254
+ * Breakdown of individual tax (and discount) amounts that add up to the totals.
255
+ */
256
+ breakdown?: {
257
+ /**
258
+ * The aggregated price items tax amount per rate.
259
+ */
260
+ taxes?: (TaxAmount)[];
261
+ };
262
+ }
263
+ }
264
+ }
265
+ declare namespace Paths {
266
+ namespace CalculatePricing {
267
+ export type RequestBody = Components.Schemas.PriceItems;
268
+ namespace Responses {
269
+ export type $200 = Components.Schemas.Order;
270
+ export type $201 = Components.Schemas.Order;
271
+ export type $400 = Components.Schemas.Error;
272
+ }
273
+ }
274
+ namespace DeleteCart {
275
+ namespace Responses {
276
+ export type $200 = Components.Schemas.Cart;
277
+ export type $400 = Components.Schemas.Error;
278
+ }
279
+ }
280
+ namespace FinalizeCart {
281
+ export interface RequestBody {
282
+ /**
283
+ * The card_id to be finalized.
284
+ */
285
+ cart_id?: string;
286
+ }
287
+ namespace Responses {
288
+ export type $200 = Components.Schemas.Cart;
289
+ export type $400 = Components.Schemas.Error;
290
+ }
291
+ }
292
+ namespace GetCart {
293
+ namespace Responses {
294
+ export type $200 = Components.Schemas.Cart;
295
+ export type $400 = Components.Schemas.Error;
296
+ }
297
+ }
298
+ namespace UpsertCart {
299
+ export interface HeaderParameters {
300
+ "X-Ivy-Org-ID": Parameters.XIvyOrgID;
301
+ }
302
+ namespace Parameters {
303
+ export type XIvyOrgID = string;
304
+ }
305
+ export type RequestBody = Components.Schemas.Cart;
306
+ namespace Responses {
307
+ export type $200 = Components.Schemas.Cart;
308
+ export type $201 = Components.Schemas.Cart;
309
+ export type $400 = Components.Schemas.Error;
310
+ }
311
+ }
312
+ namespace UpsertOrder {
313
+ namespace Parameters {
314
+ export type CartId = string;
315
+ }
316
+ export interface QueryParameters {
317
+ cart_id?: Parameters.CartId;
318
+ }
319
+ export type RequestBody = Components.Schemas.Order;
320
+ namespace Responses {
321
+ export type $200 = Components.Schemas.Order;
322
+ export type $201 = Components.Schemas.Order;
323
+ export type $400 = Components.Schemas.Error;
324
+ }
325
+ }
326
+ }
327
+
328
+ export interface OperationMethods {
329
+ /**
330
+ * upsertCart - upsertCart
331
+ *
332
+ * Creates a new cart or updates an existing one.
333
+ */
334
+ 'upsertCart'(
335
+ parameters?: Parameters<Paths.UpsertCart.HeaderParameters> | null,
336
+ data?: Paths.UpsertCart.RequestBody,
337
+ config?: AxiosRequestConfig
338
+ ): OperationResponse<Paths.UpsertCart.Responses.$200 | Paths.UpsertCart.Responses.$201 | Paths.UpsertCart.Responses.$400>
339
+ /**
340
+ * finalizeCart - finalizeCart
341
+ *
342
+ * Finalizes the cart by changing its status to 'complete'.
343
+ * The cart can no longer be modified after this operation.
344
+ *
345
+ */
346
+ 'finalizeCart'(
347
+ parameters?: Parameters<UnknownParamsObject> | null,
348
+ data?: Paths.FinalizeCart.RequestBody,
349
+ config?: AxiosRequestConfig
350
+ ): OperationResponse<Paths.FinalizeCart.Responses.$200 | Paths.FinalizeCart.Responses.$400>
351
+ /**
352
+ * getCart - getCart
353
+ *
354
+ * Retrieves a cart by id.
355
+ */
356
+ 'getCart'(
357
+ parameters?: Parameters<UnknownParamsObject> | null,
358
+ data?: any,
359
+ config?: AxiosRequestConfig
360
+ ): OperationResponse<Paths.GetCart.Responses.$200 | Paths.GetCart.Responses.$400>
361
+ /**
362
+ * deleteCart - deleteCart
363
+ *
364
+ * Deletes the Cart specified and returns its content.
365
+ */
366
+ 'deleteCart'(
367
+ parameters?: Parameters<UnknownParamsObject> | null,
368
+ data?: any,
369
+ config?: AxiosRequestConfig
370
+ ): OperationResponse<Paths.DeleteCart.Responses.$200 | Paths.DeleteCart.Responses.$400>
371
+ /**
372
+ * upsertOrder - upsertOrder
373
+ *
374
+ * Creates a new order or updates an existing one.
375
+ * The upsert operation is idempotent, meaning that multiple calls will have effect just once.
376
+ * Calling the upsert multiple times will not duplicate the items on an order.
377
+ *
378
+ * When the the `cart_id` is specified, the cart items are appended to the existing order items, or replaced in-place if they belong to the same `cart_id`.
379
+ *
380
+ * On multiple updates with the same `cart_id` the line items linked with that `cart_id` (`order.line_items[]?.metadata.cart_id`) are removed and re-added.
381
+ *
382
+ */
383
+ 'upsertOrder'(
384
+ parameters?: Parameters<Paths.UpsertOrder.QueryParameters> | null,
385
+ data?: Paths.UpsertOrder.RequestBody,
386
+ config?: AxiosRequestConfig
387
+ ): OperationResponse<Paths.UpsertOrder.Responses.$200 | Paths.UpsertOrder.Responses.$201 | Paths.UpsertOrder.Responses.$400>
388
+ /**
389
+ * calculatePricing - calculatePricing
390
+ *
391
+ * Calculates the pricing amounts for a set of price items, including aggregated totals such as subtotal, total and aggregates per tax rate.
392
+ *
393
+ */
394
+ 'calculatePricing'(
395
+ parameters?: Parameters<UnknownParamsObject> | null,
396
+ data?: Paths.CalculatePricing.RequestBody,
397
+ config?: AxiosRequestConfig
398
+ ): OperationResponse<Paths.CalculatePricing.Responses.$200 | Paths.CalculatePricing.Responses.$201 | Paths.CalculatePricing.Responses.$400>
399
+ }
400
+
401
+ export interface PathsDictionary {
402
+ ['/v1/public/cart']: {
403
+ /**
404
+ * upsertCart - upsertCart
405
+ *
406
+ * Creates a new cart or updates an existing one.
407
+ */
408
+ 'put'(
409
+ parameters?: Parameters<Paths.UpsertCart.HeaderParameters> | null,
410
+ data?: Paths.UpsertCart.RequestBody,
411
+ config?: AxiosRequestConfig
412
+ ): OperationResponse<Paths.UpsertCart.Responses.$200 | Paths.UpsertCart.Responses.$201 | Paths.UpsertCart.Responses.$400>
413
+ }
414
+ ['/v1/public/cart:finalize']: {
415
+ /**
416
+ * finalizeCart - finalizeCart
417
+ *
418
+ * Finalizes the cart by changing its status to 'complete'.
419
+ * The cart can no longer be modified after this operation.
420
+ *
421
+ */
422
+ 'post'(
423
+ parameters?: Parameters<UnknownParamsObject> | null,
424
+ data?: Paths.FinalizeCart.RequestBody,
425
+ config?: AxiosRequestConfig
426
+ ): OperationResponse<Paths.FinalizeCart.Responses.$200 | Paths.FinalizeCart.Responses.$400>
427
+ }
428
+ ['/v1/cart/{cart-id}']: {
429
+ /**
430
+ * getCart - getCart
431
+ *
432
+ * Retrieves a cart by id.
433
+ */
434
+ 'get'(
435
+ parameters?: Parameters<UnknownParamsObject> | null,
436
+ data?: any,
437
+ config?: AxiosRequestConfig
438
+ ): OperationResponse<Paths.GetCart.Responses.$200 | Paths.GetCart.Responses.$400>
439
+ /**
440
+ * deleteCart - deleteCart
441
+ *
442
+ * Deletes the Cart specified and returns its content.
443
+ */
444
+ 'delete'(
445
+ parameters?: Parameters<UnknownParamsObject> | null,
446
+ data?: any,
447
+ config?: AxiosRequestConfig
448
+ ): OperationResponse<Paths.DeleteCart.Responses.$200 | Paths.DeleteCart.Responses.$400>
449
+ }
450
+ ['/v1/order']: {
451
+ /**
452
+ * upsertOrder - upsertOrder
453
+ *
454
+ * Creates a new order or updates an existing one.
455
+ * The upsert operation is idempotent, meaning that multiple calls will have effect just once.
456
+ * Calling the upsert multiple times will not duplicate the items on an order.
457
+ *
458
+ * When the the `cart_id` is specified, the cart items are appended to the existing order items, or replaced in-place if they belong to the same `cart_id`.
459
+ *
460
+ * On multiple updates with the same `cart_id` the line items linked with that `cart_id` (`order.line_items[]?.metadata.cart_id`) are removed and re-added.
461
+ *
462
+ */
463
+ 'put'(
464
+ parameters?: Parameters<Paths.UpsertOrder.QueryParameters> | null,
465
+ data?: Paths.UpsertOrder.RequestBody,
466
+ config?: AxiosRequestConfig
467
+ ): OperationResponse<Paths.UpsertOrder.Responses.$200 | Paths.UpsertOrder.Responses.$201 | Paths.UpsertOrder.Responses.$400>
468
+ }
469
+ ['/v1/pricing/calculate']: {
470
+ /**
471
+ * calculatePricing - calculatePricing
472
+ *
473
+ * Calculates the pricing amounts for a set of price items, including aggregated totals such as subtotal, total and aggregates per tax rate.
474
+ *
475
+ */
476
+ 'post'(
477
+ parameters?: Parameters<UnknownParamsObject> | null,
478
+ data?: Paths.CalculatePricing.RequestBody,
479
+ config?: AxiosRequestConfig
480
+ ): OperationResponse<Paths.CalculatePricing.Responses.$200 | Paths.CalculatePricing.Responses.$201 | Paths.CalculatePricing.Responses.$400>
481
+ }
482
+ }
483
+
484
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>