@acmekit/utils 2.13.2 → 2.13.3
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/dist/bundles.d.ts +0 -7
- package/dist/bundles.d.ts.map +1 -1
- package/dist/bundles.js +1 -8
- package/dist/bundles.js.map +1 -1
- package/dist/common/define-config.d.ts.map +1 -1
- package/dist/common/define-config.js +2 -49
- package/dist/common/define-config.js.map +1 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/link/links.d.ts +0 -21
- package/dist/link/links.d.ts.map +1 -1
- package/dist/link/links.js +0 -21
- package/dist/link/links.js.map +1 -1
- package/dist/modules-sdk/definition.d.ts +0 -39
- package/dist/modules-sdk/definition.d.ts.map +1 -1
- package/dist/modules-sdk/definition.js +0 -26
- package/dist/modules-sdk/definition.js.map +1 -1
- package/dist/modules-sdk/modules-to-container-types.d.ts.map +1 -1
- package/dist/modules-sdk/modules-to-container-types.js +0 -13
- package/dist/modules-sdk/modules-to-container-types.js.map +1 -1
- package/dist/translations/index.d.ts +0 -1
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +0 -1
- package/dist/translations/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/fulfillment/events.d.ts +0 -77
- package/dist/fulfillment/events.d.ts.map +0 -1
- package/dist/fulfillment/events.js +0 -117
- package/dist/fulfillment/events.js.map +0 -1
- package/dist/fulfillment/geo-zone.d.ts +0 -7
- package/dist/fulfillment/geo-zone.d.ts.map +0 -1
- package/dist/fulfillment/geo-zone.js +0 -11
- package/dist/fulfillment/geo-zone.js.map +0 -1
- package/dist/fulfillment/index.d.ts +0 -5
- package/dist/fulfillment/index.d.ts.map +0 -1
- package/dist/fulfillment/index.js +0 -21
- package/dist/fulfillment/index.js.map +0 -1
- package/dist/fulfillment/provider.d.ts +0 -394
- package/dist/fulfillment/provider.d.ts.map +0 -1
- package/dist/fulfillment/provider.js +0 -412
- package/dist/fulfillment/provider.js.map +0 -1
- package/dist/fulfillment/shipping-options.d.ts +0 -5
- package/dist/fulfillment/shipping-options.d.ts.map +0 -1
- package/dist/fulfillment/shipping-options.js +0 -9
- package/dist/fulfillment/shipping-options.js.map +0 -1
- package/dist/inventory/events.d.ts +0 -26
- package/dist/inventory/events.d.ts.map +0 -1
- package/dist/inventory/events.js +0 -40
- package/dist/inventory/events.js.map +0 -1
- package/dist/inventory/index.d.ts +0 -2
- package/dist/inventory/index.d.ts.map +0 -1
- package/dist/inventory/index.js +0 -18
- package/dist/inventory/index.js.map +0 -1
- package/dist/order/index.d.ts +0 -4
- package/dist/order/index.d.ts.map +0 -1
- package/dist/order/index.js +0 -20
- package/dist/order/index.js.map +0 -1
- package/dist/order/order-change-action.d.ts +0 -25
- package/dist/order/order-change-action.d.ts.map +0 -1
- package/dist/order/order-change-action.js +0 -29
- package/dist/order/order-change-action.js.map +0 -1
- package/dist/order/order-change.d.ts +0 -31
- package/dist/order/order-change.d.ts.map +0 -1
- package/dist/order/order-change.js +0 -36
- package/dist/order/order-change.js.map +0 -1
- package/dist/order/status.d.ts +0 -85
- package/dist/order/status.d.ts.map +0 -1
- package/dist/order/status.js +0 -92
- package/dist/order/status.js.map +0 -1
- package/dist/payment/abstract-payment-provider.d.ts +0 -632
- package/dist/payment/abstract-payment-provider.d.ts.map +0 -1
- package/dist/payment/abstract-payment-provider.js +0 -110
- package/dist/payment/abstract-payment-provider.js.map +0 -1
- package/dist/payment/index.d.ts +0 -5
- package/dist/payment/index.d.ts.map +0 -1
- package/dist/payment/index.js +0 -21
- package/dist/payment/index.js.map +0 -1
- package/dist/payment/payment-collection.d.ts +0 -40
- package/dist/payment/payment-collection.d.ts.map +0 -1
- package/dist/payment/payment-collection.js +0 -44
- package/dist/payment/payment-collection.js.map +0 -1
- package/dist/payment/payment-session.d.ts +0 -32
- package/dist/payment/payment-session.d.ts.map +0 -1
- package/dist/payment/payment-session.js +0 -36
- package/dist/payment/payment-session.js.map +0 -1
- package/dist/payment/webhook.d.ts +0 -37
- package/dist/payment/webhook.d.ts.map +0 -1
- package/dist/payment/webhook.js +0 -42
- package/dist/payment/webhook.js.map +0 -1
- package/dist/pricing/builders.d.ts +0 -10
- package/dist/pricing/builders.d.ts.map +0 -1
- package/dist/pricing/builders.js +0 -53
- package/dist/pricing/builders.js.map +0 -1
- package/dist/pricing/enums.d.ts +0 -8
- package/dist/pricing/enums.d.ts.map +0 -1
- package/dist/pricing/enums.js +0 -12
- package/dist/pricing/enums.js.map +0 -1
- package/dist/pricing/events.d.ts +0 -38
- package/dist/pricing/events.d.ts.map +0 -1
- package/dist/pricing/events.js +0 -50
- package/dist/pricing/events.js.map +0 -1
- package/dist/pricing/index.d.ts +0 -5
- package/dist/pricing/index.d.ts.map +0 -1
- package/dist/pricing/index.js +0 -21
- package/dist/pricing/index.js.map +0 -1
- package/dist/pricing/price-list.d.ts +0 -9
- package/dist/pricing/price-list.d.ts.map +0 -1
- package/dist/pricing/price-list.js +0 -14
- package/dist/pricing/price-list.js.map +0 -1
- package/dist/product/csv-normalizer.d.ts +0 -43
- package/dist/product/csv-normalizer.d.ts.map +0 -1
- package/dist/product/csv-normalizer.js +0 -382
- package/dist/product/csv-normalizer.js.map +0 -1
- package/dist/product/enums.d.ts +0 -7
- package/dist/product/enums.d.ts.map +0 -1
- package/dist/product/enums.js +0 -11
- package/dist/product/enums.js.map +0 -1
- package/dist/product/events.d.ts +0 -62
- package/dist/product/events.d.ts.map +0 -1
- package/dist/product/events.js +0 -88
- package/dist/product/events.js.map +0 -1
- package/dist/product/get-variant-availability.d.ts +0 -59
- package/dist/product/get-variant-availability.d.ts.map +0 -1
- package/dist/product/get-variant-availability.js +0 -111
- package/dist/product/get-variant-availability.js.map +0 -1
- package/dist/product/index.d.ts +0 -6
- package/dist/product/index.d.ts.map +0 -1
- package/dist/product/index.js +0 -45
- package/dist/product/index.js.map +0 -1
- package/dist/product/validators.d.ts +0 -894
- package/dist/product/validators.d.ts.map +0 -1
- package/dist/product/validators.js +0 -163
- package/dist/product/validators.js.map +0 -1
- package/dist/promotion/index.d.ts +0 -57
- package/dist/promotion/index.d.ts.map +0 -1
- package/dist/promotion/index.js +0 -70
- package/dist/promotion/index.js.map +0 -1
- package/dist/shipping/index.d.ts +0 -6
- package/dist/shipping/index.d.ts.map +0 -1
- package/dist/shipping/index.js +0 -10
- package/dist/shipping/index.js.map +0 -1
- package/dist/totals/adjustment/index.d.ts +0 -16
- package/dist/totals/adjustment/index.d.ts.map +0 -1
- package/dist/totals/adjustment/index.js +0 -49
- package/dist/totals/adjustment/index.js.map +0 -1
- package/dist/totals/cart/index.d.ts +0 -40
- package/dist/totals/cart/index.d.ts.map +0 -1
- package/dist/totals/cart/index.js +0 -165
- package/dist/totals/cart/index.js.map +0 -1
- package/dist/totals/create-raw-properties-from-bignumber.d.ts +0 -5
- package/dist/totals/create-raw-properties-from-bignumber.d.ts.map +0 -1
- package/dist/totals/create-raw-properties-from-bignumber.js +0 -52
- package/dist/totals/create-raw-properties-from-bignumber.js.map +0 -1
- package/dist/totals/credit-lines/index.d.ts +0 -14
- package/dist/totals/credit-lines/index.d.ts.map +0 -1
- package/dist/totals/credit-lines/index.js +0 -46
- package/dist/totals/credit-lines/index.js.map +0 -1
- package/dist/totals/index.d.ts +0 -9
- package/dist/totals/index.d.ts.map +0 -1
- package/dist/totals/index.js +0 -25
- package/dist/totals/index.js.map +0 -1
- package/dist/totals/line-item/index.d.ts +0 -48
- package/dist/totals/line-item/index.d.ts.map +0 -1
- package/dist/totals/line-item/index.js +0 -123
- package/dist/totals/line-item/index.js.map +0 -1
- package/dist/totals/math.d.ts +0 -26
- package/dist/totals/math.d.ts.map +0 -1
- package/dist/totals/math.js +0 -107
- package/dist/totals/math.js.map +0 -1
- package/dist/totals/promotion/index.d.ts +0 -5
- package/dist/totals/promotion/index.d.ts.map +0 -1
- package/dist/totals/promotion/index.js +0 -124
- package/dist/totals/promotion/index.js.map +0 -1
- package/dist/totals/shipping-method/index.d.ts +0 -28
- package/dist/totals/shipping-method/index.d.ts.map +0 -1
- package/dist/totals/shipping-method/index.js +0 -59
- package/dist/totals/shipping-method/index.js.map +0 -1
- package/dist/totals/tax/index.d.ts +0 -16
- package/dist/totals/tax/index.d.ts.map +0 -1
- package/dist/totals/tax/index.js +0 -37
- package/dist/totals/tax/index.js.map +0 -1
- package/dist/totals/transform-properties-to-bignumber.d.ts +0 -6
- package/dist/totals/transform-properties-to-bignumber.d.ts.map +0 -1
- package/dist/totals/transform-properties-to-bignumber.js +0 -40
- package/dist/totals/transform-properties-to-bignumber.js.map +0 -1
- package/dist/translations/apply-translations-to-tax-lines.d.ts +0 -12
- package/dist/translations/apply-translations-to-tax-lines.d.ts.map +0 -1
- package/dist/translations/apply-translations-to-tax-lines.js +0 -38
- package/dist/translations/apply-translations-to-tax-lines.js.map +0 -1
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
import { CalculatedShippingOptionPrice, CalculateShippingOptionPriceDTO, CreateFulfillmentResult, CreateShippingOptionDTO, FulfillmentDTO, FulfillmentItemDTO, FulfillmentOption, FulfillmentOrderDTO, IFulfillmentProvider, ValidateFulfillmentDataContext } from "@acmekit/types";
|
|
2
|
-
/**
|
|
3
|
-
* ### constructor
|
|
4
|
-
*
|
|
5
|
-
* The constructor allows you to access resources from the [module's container](https://docs.acmekit.com/learn/fundamentals/modules/container)
|
|
6
|
-
* using the first parameter, and the module's options using the second parameter.
|
|
7
|
-
*
|
|
8
|
-
* :::note
|
|
9
|
-
*
|
|
10
|
-
* A module's options are passed when you register it in the AcmeKit application.
|
|
11
|
-
*
|
|
12
|
-
* :::
|
|
13
|
-
*
|
|
14
|
-
* If you're creating a client or establishing a connection with a third-party service, do it in the constructor.
|
|
15
|
-
*
|
|
16
|
-
* #### Example
|
|
17
|
-
*
|
|
18
|
-
* ```ts title="src/modules/my-fulfillment/service.ts"
|
|
19
|
-
* import { AbstractFulfillmentProviderService } from "@acmekit/framework/utils"
|
|
20
|
-
* import { Logger } from "@acmekit/framework/types"
|
|
21
|
-
*
|
|
22
|
-
* type InjectedDependencies = {
|
|
23
|
-
* logger: Logger
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* type Options = {
|
|
27
|
-
* apiKey: string
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
31
|
-
* // other properties...
|
|
32
|
-
* protected logger_: Logger
|
|
33
|
-
* protected options_: Options
|
|
34
|
-
* // assuming you're initializing a client
|
|
35
|
-
* protected client
|
|
36
|
-
*
|
|
37
|
-
* constructor(
|
|
38
|
-
* { logger }: InjectedDependencies,
|
|
39
|
-
* options: Options
|
|
40
|
-
* ) {
|
|
41
|
-
* super()
|
|
42
|
-
*
|
|
43
|
-
* this.logger_ = logger
|
|
44
|
-
* this.options_ = options
|
|
45
|
-
*
|
|
46
|
-
* // TODO initialize your client
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* export default MyFulfillmentProviderService
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export declare class AbstractFulfillmentProviderService implements IFulfillmentProvider {
|
|
54
|
-
/**
|
|
55
|
-
* Each fulfillment provider has a unique identifier defined in its class. The provider's ID
|
|
56
|
-
* will be stored as `fp_{identifier}_{id}`, where `{id}` is the provider's `id`
|
|
57
|
-
* property in the `acmekit-config.ts`.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
61
|
-
* static identifier = "my-fulfillment"
|
|
62
|
-
*
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
*/
|
|
66
|
-
static identifier: string;
|
|
67
|
-
/**
|
|
68
|
-
* @ignore
|
|
69
|
-
*/
|
|
70
|
-
static _isFulfillmentService: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* @ignore
|
|
73
|
-
*/
|
|
74
|
-
static isFulfillmentService(obj: any): any;
|
|
75
|
-
/**
|
|
76
|
-
* @ignore
|
|
77
|
-
*/
|
|
78
|
-
getIdentifier(): any;
|
|
79
|
-
/**
|
|
80
|
-
* This method retrieves a list of fulfillment options that this provider supports. Admin users will then choose from these options when
|
|
81
|
-
* they're creating a shipping option. The chosen fulfillment option's object is then stored within the created shipping option's `data` property.
|
|
82
|
-
* The `data` property is useful to store data relevant for the third-party provider to later process the fulfillment.
|
|
83
|
-
*
|
|
84
|
-
* This method is useful if your third-party provider allows you to retrieve support options, carriers, or services from an API. You can then
|
|
85
|
-
* retrieve those and return then in the method, allowing the admin user to choose from the services provided by the third-party provider.
|
|
86
|
-
*
|
|
87
|
-
* @returns The list of fulfillment options. Each object in the array should have an `id` property unique to an item, and a `name` property
|
|
88
|
-
* that's used to display the option in the admin.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* // other imports...
|
|
92
|
-
* import { FulfillmentOption } from "@acmekit/framework/types"
|
|
93
|
-
*
|
|
94
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
95
|
-
* // ...
|
|
96
|
-
* async getFulfillmentOptions(): Promise<FulfillmentOption[]> {
|
|
97
|
-
* // assuming you have a client
|
|
98
|
-
* const services = await this.client.getServices()
|
|
99
|
-
*
|
|
100
|
-
* return services.map((service) => ({
|
|
101
|
-
* id: service.service_id,
|
|
102
|
-
* name: service.name,
|
|
103
|
-
* service_code: service.code,
|
|
104
|
-
* // can add other relevant data for the provider to later process the shipping option.
|
|
105
|
-
* }))
|
|
106
|
-
* }
|
|
107
|
-
* }
|
|
108
|
-
*/
|
|
109
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
110
|
-
/**
|
|
111
|
-
* This method validates the `data` property of a shipping method and returns it. The returned data
|
|
112
|
-
* is stored in the shipping method's `data` property.
|
|
113
|
-
*
|
|
114
|
-
* Your fulfillment provider can use the `data` property to store additional information useful for
|
|
115
|
-
* handling the fulfillment later. For example, you may store an ID from the third-party fulfillment
|
|
116
|
-
* system.
|
|
117
|
-
*
|
|
118
|
-
* @param optionData - The `data` property of the shipping option.
|
|
119
|
-
* @param data - The `data` property of the shipping method.
|
|
120
|
-
* @param context - Context details, such as context of the cart or customer.
|
|
121
|
-
* @returns the data to store in the `data` property of the shipping method.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
125
|
-
* // ...
|
|
126
|
-
* async validateFulfillmentData(
|
|
127
|
-
* optionData: any,
|
|
128
|
-
* data: any,
|
|
129
|
-
* context: any
|
|
130
|
-
* ): Promise<any> {
|
|
131
|
-
* // assuming your client retrieves an ID from the
|
|
132
|
-
* // third-party service
|
|
133
|
-
* const externalId = await this.client.getId()
|
|
134
|
-
*
|
|
135
|
-
* return {
|
|
136
|
-
* ...data,
|
|
137
|
-
* externalId
|
|
138
|
-
* }
|
|
139
|
-
* }
|
|
140
|
-
* }
|
|
141
|
-
*/
|
|
142
|
-
validateFulfillmentData(optionData: Record<string, unknown>, data: Record<string, unknown>, context: ValidateFulfillmentDataContext): Promise<any>;
|
|
143
|
-
/**
|
|
144
|
-
* This method validates the `data` property of a shipping option when it's created.
|
|
145
|
-
*
|
|
146
|
-
* The `data` property can hold useful information that's later added to the `data` attribute
|
|
147
|
-
* of shipping methods created from this option.
|
|
148
|
-
*
|
|
149
|
-
* @param data - The data to validate.
|
|
150
|
-
* @return Whether the data is valid.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
154
|
-
* // ...
|
|
155
|
-
* async validateOption(data: any): Promise<boolean> {
|
|
156
|
-
* return data.external_id !== undefined
|
|
157
|
-
* }
|
|
158
|
-
* }
|
|
159
|
-
*/
|
|
160
|
-
validateOption(data: Record<string, unknown>): Promise<boolean>;
|
|
161
|
-
/**
|
|
162
|
-
* This method validates whether a shippin option's price can be calculated during checkout. It's executed when the admin user creates a shipping
|
|
163
|
-
* option of type `calculated`. If this method returns `false`, an error is thrown as the shipping option's price can't be calculated.
|
|
164
|
-
*
|
|
165
|
-
* You can perform the checking using the third-party provider if applicable. The `data` parameter will hold the shipping option's `data` property, which
|
|
166
|
-
* includes the data of a fulfillment option returned by {@link getFulfillmentOptions}.
|
|
167
|
-
*
|
|
168
|
-
* @param data - The `data` property of the shipping option.
|
|
169
|
-
* @returns Whether the price can be calculated for the shipping option.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
173
|
-
* // ...
|
|
174
|
-
* async canCalculate(data: CreateShippingOptionDTO): Promise<boolean> {
|
|
175
|
-
* // assuming you have a client
|
|
176
|
-
* return await this.client.hasRates(data.id)
|
|
177
|
-
* }
|
|
178
|
-
* }
|
|
179
|
-
*/
|
|
180
|
-
canCalculate(data: CreateShippingOptionDTO): Promise<boolean>;
|
|
181
|
-
/**
|
|
182
|
-
* This method calculates the price of a shipping method when it's created or its cart is refreshed.
|
|
183
|
-
*
|
|
184
|
-
* In this method, you can send a request to your third-party provider to retrieve the prices. The first
|
|
185
|
-
* parameters holds the `data` property of the shipping method's shipping option, which has fulfillment
|
|
186
|
-
* object data returned by {@link getFulfillmentOptions}.
|
|
187
|
-
*
|
|
188
|
-
* The second parameter holds the `data` property of the shipping method, which has data returned by {@link validateFulfillmentData}.
|
|
189
|
-
* It can also hold custom data passed from the frontend during checkout.
|
|
190
|
-
*
|
|
191
|
-
* So, using both of these data, assuming you're storing in them data related to the third-party service,
|
|
192
|
-
* you can retrieve the calculated price of the shipping method.
|
|
193
|
-
*
|
|
194
|
-
* @param optionData - The `data` property of a shipping option.
|
|
195
|
-
* @param data - The shipping method's `data` property with custom data passed from the frontend.
|
|
196
|
-
* @param context - The context details, such as the cart details.
|
|
197
|
-
* @returns The calculated price's details.
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* import { CalculateShippingOptionPriceDTO } from "@acmekit/framework/types"
|
|
201
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
202
|
-
* // ...
|
|
203
|
-
* async calculatePrice(
|
|
204
|
-
* optionData: CalculateShippingOptionPriceDTO["optionData"],
|
|
205
|
-
* data: CalculateShippingOptionPriceDTO["data"],
|
|
206
|
-
* context: CalculateShippingOptionPriceDTO["context"]
|
|
207
|
-
* ): Promise<CalculatedShippingOptionPrice> {
|
|
208
|
-
* // assuming the client can calculate the price using
|
|
209
|
-
* // the third-party service
|
|
210
|
-
* const price = await this.client.calculate(data)
|
|
211
|
-
* return {
|
|
212
|
-
* calculated_amount: price,
|
|
213
|
-
* // Update this boolean value based on your logic
|
|
214
|
-
* is_calculated_price_tax_inclusive: true,
|
|
215
|
-
* }
|
|
216
|
-
* }
|
|
217
|
-
* }
|
|
218
|
-
*/
|
|
219
|
-
calculatePrice(optionData: CalculateShippingOptionPriceDTO["optionData"], data: CalculateShippingOptionPriceDTO["data"], context: CalculateShippingOptionPriceDTO["context"]): Promise<CalculatedShippingOptionPrice>;
|
|
220
|
-
/**
|
|
221
|
-
* This method is used when a fulfillment is created. If the method returns in the object a
|
|
222
|
-
* `data` property, it's stored in the fulfillment's `data` property.
|
|
223
|
-
*
|
|
224
|
-
* The `data` property is useful when handling the fulfillment later,
|
|
225
|
-
* as you can access information useful for your integration, such as the ID in the
|
|
226
|
-
* third-party provider.
|
|
227
|
-
*
|
|
228
|
-
* You can also use this method to perform an action with the third-party fulfillment service
|
|
229
|
-
* since a fulfillment is created, such as purchase a label.
|
|
230
|
-
*
|
|
231
|
-
* @param data - The `data` property of the shipping method this fulfillment is created for.
|
|
232
|
-
* @param items - The items in the fulfillment.
|
|
233
|
-
* @param order - The order this fulfillment is created for.
|
|
234
|
-
* @param fulfillment - The fulfillment's details.
|
|
235
|
-
* @returns An object whose `data` property is stored in the fulfillment's `data` property.
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
239
|
-
* // ...
|
|
240
|
-
* async createFulfillment(
|
|
241
|
-
* data: Record<string, unknown>,
|
|
242
|
-
* items: Partial<Omit<FulfillmentItemDTO, "fulfillment">>[],
|
|
243
|
-
* order: Partial<FulfillmentOrderDTO> | undefined,
|
|
244
|
-
* fulfillment: Partial<Omit<FulfillmentDTO, "provider_id" | "data" | "items">>
|
|
245
|
-
* ): Promise<CreateFulfillmentResult> {
|
|
246
|
-
* // assuming the client creates a fulfillment
|
|
247
|
-
* // in the third-party service
|
|
248
|
-
* const externalData = await this.client.create(
|
|
249
|
-
* fulfillment,
|
|
250
|
-
* items
|
|
251
|
-
* )
|
|
252
|
-
*
|
|
253
|
-
* return {
|
|
254
|
-
* data: {
|
|
255
|
-
* ...(fulfillment.data as object || {}),
|
|
256
|
-
* ...externalData
|
|
257
|
-
* }
|
|
258
|
-
* }
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
*/
|
|
262
|
-
createFulfillment(data: Record<string, unknown>, items: Partial<Omit<FulfillmentItemDTO, "fulfillment">>[], order: Partial<FulfillmentOrderDTO> | undefined, fulfillment: Partial<Omit<FulfillmentDTO, "provider_id" | "data" | "items">>): Promise<CreateFulfillmentResult>;
|
|
263
|
-
/**
|
|
264
|
-
* This method is used when a fulfillment is canceled. Use it to perform operations
|
|
265
|
-
* with the third-party fulfillment service.
|
|
266
|
-
*
|
|
267
|
-
* @param data - The fulfillment's `data` property.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
271
|
-
* // ...
|
|
272
|
-
* async cancelFulfillment(data: Record<string, unknown>): Promise<any> {
|
|
273
|
-
* // assuming the client cancels a fulfillment
|
|
274
|
-
* // in the third-party service
|
|
275
|
-
* const { external_id } = data as {
|
|
276
|
-
* external_id: string
|
|
277
|
-
* }
|
|
278
|
-
* await this.client.cancel(external_id)
|
|
279
|
-
* }
|
|
280
|
-
* }
|
|
281
|
-
*/
|
|
282
|
-
cancelFulfillment(data: Record<string, unknown>): Promise<any>;
|
|
283
|
-
/**
|
|
284
|
-
* This method retrieves the documents of a fulfillment.
|
|
285
|
-
*
|
|
286
|
-
* @param data - The `data` property of the fulfillment.
|
|
287
|
-
* @returns The fulfillment's documents.
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
291
|
-
* // ...
|
|
292
|
-
* async getFulfillmentDocuments(data: any): Promise<never[]> {
|
|
293
|
-
* // assuming the client retrieves documents
|
|
294
|
-
* // from a third-party service
|
|
295
|
-
* return await this.client.documents(data)
|
|
296
|
-
* }
|
|
297
|
-
* }
|
|
298
|
-
*/
|
|
299
|
-
getFulfillmentDocuments(data: Record<string, unknown>): Promise<never[]>;
|
|
300
|
-
/**
|
|
301
|
-
* This method is used when a fulfillment is created for a return. If the method returns in the object a
|
|
302
|
-
* `data` property, it's stored in the fulfillment's `data` property.
|
|
303
|
-
*
|
|
304
|
-
* The `data` property is useful when handling the fulfillment later,
|
|
305
|
-
* as you can access information useful for your integration. For example, you
|
|
306
|
-
* can store an ID for the fulfillment in the third-party service.
|
|
307
|
-
*
|
|
308
|
-
* Use this method to perform actions necessary in the third-party fulfillment service, such as
|
|
309
|
-
* purchasing a label for the return fulfillment.
|
|
310
|
-
*
|
|
311
|
-
* @param fulfillment - The fulfillment's details.
|
|
312
|
-
* @returns An object containing `data` which is stored in the fulfillment's `data` property and `labels` array which is used to create FulfillmentLabels.
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
316
|
-
* // ...
|
|
317
|
-
* async createReturnFulfillment(fulfillment: Record<string, unknown>): Promise<CreateFulfillmentResult> {
|
|
318
|
-
* // assuming the client creates a fulfillment for a return
|
|
319
|
-
* // in the third-party service
|
|
320
|
-
* const externalData = await this.client.createReturn(
|
|
321
|
-
* fulfillment
|
|
322
|
-
* )
|
|
323
|
-
*
|
|
324
|
-
* return {
|
|
325
|
-
* data: {
|
|
326
|
-
* ...(fulfillment.data as object || {}),
|
|
327
|
-
* ...externalData
|
|
328
|
-
* }
|
|
329
|
-
* }
|
|
330
|
-
* }
|
|
331
|
-
* }
|
|
332
|
-
*/
|
|
333
|
-
createReturnFulfillment(fulfillment: Record<string, unknown>): Promise<CreateFulfillmentResult>;
|
|
334
|
-
/**
|
|
335
|
-
* This method retrieves documents for a return's fulfillment.
|
|
336
|
-
*
|
|
337
|
-
* @param data - The `data` property of the fulfillment.
|
|
338
|
-
* @returns The fulfillment's documents.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
342
|
-
* // ...
|
|
343
|
-
* async getReturnDocuments(data: any): Promise<never[]> {
|
|
344
|
-
* // assuming the client retrieves documents
|
|
345
|
-
* // from a third-party service
|
|
346
|
-
* return await this.client.documents(data)
|
|
347
|
-
* }
|
|
348
|
-
* }
|
|
349
|
-
*/
|
|
350
|
-
getReturnDocuments(data: Record<string, unknown>): Promise<never[]>;
|
|
351
|
-
/**
|
|
352
|
-
* This method retrieves the documents for a shipment.
|
|
353
|
-
*
|
|
354
|
-
* @param data - The `data` property of the shipmnet.
|
|
355
|
-
* @returns The shipment's documents.
|
|
356
|
-
*
|
|
357
|
-
* @example
|
|
358
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
359
|
-
* // ...
|
|
360
|
-
* async getShipmentDocuments(data: any): Promise<never[]> {
|
|
361
|
-
* // assuming the client retrieves documents
|
|
362
|
-
* // from a third-party service
|
|
363
|
-
* return await this.client.documents(data)
|
|
364
|
-
* }
|
|
365
|
-
* }
|
|
366
|
-
*
|
|
367
|
-
*/
|
|
368
|
-
getShipmentDocuments(data: Record<string, unknown>): Promise<never[]>;
|
|
369
|
-
/**
|
|
370
|
-
* This method retrieves the documents of a fulfillment of a certain type.
|
|
371
|
-
*
|
|
372
|
-
* @param fulfillmentData - The `data` property of the fulfillment.
|
|
373
|
-
* @param documentType - The document's type. For example, `invoice`.
|
|
374
|
-
* @returns The fulfillment's documents.
|
|
375
|
-
*
|
|
376
|
-
* @example
|
|
377
|
-
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
|
378
|
-
* // ...
|
|
379
|
-
* async retrieveDocuments(
|
|
380
|
-
* fulfillmentData: any,
|
|
381
|
-
* documentType: any
|
|
382
|
-
* ): Promise<void> {
|
|
383
|
-
* // assuming the client retrieves documents
|
|
384
|
-
* // from a third-party service
|
|
385
|
-
* return await this.client.documents(
|
|
386
|
-
* fulfillmentData,
|
|
387
|
-
* documentType
|
|
388
|
-
* )
|
|
389
|
-
* }
|
|
390
|
-
* }
|
|
391
|
-
*/
|
|
392
|
-
retrieveDocuments(fulfillmentData: Record<string, unknown>, documentType: string): Promise<void>;
|
|
393
|
-
}
|
|
394
|
-
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/fulfillment/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,gBAAgB,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBAAa,kCACX,YAAW,oBAAoB;IAE/B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,MAAM,CAAC,qBAAqB,UAAO;IAEnC;;OAEG;IACH,MAAM,CAAC,oBAAoB,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