@23blocks/block-sales 2.1.0 → 2.2.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/dist/index.esm.js CHANGED
@@ -243,6 +243,62 @@ function createOrderDetailsService(transport, _config) {
243
243
  };
244
244
  }
245
245
 
246
+ const orderTaxMapper = {
247
+ type: 'OrderTax',
248
+ map: (resource)=>({
249
+ id: resource.id,
250
+ uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
251
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
252
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
253
+ orderUniqueId: parseString(resource.attributes['order_unique_id']) || '',
254
+ name: parseString(resource.attributes['name']) || '',
255
+ rate: parseNumber(resource.attributes['rate']),
256
+ amount: parseNumber(resource.attributes['amount']),
257
+ type: parseString(resource.attributes['type']) || '',
258
+ payload: resource.attributes['payload']
259
+ })
260
+ };
261
+
262
+ function createOrderTaxesService(transport, _config) {
263
+ return {
264
+ async list (orderUniqueId) {
265
+ const response = await transport.get(`/orders/${orderUniqueId}/taxes`);
266
+ return decodeMany(response, orderTaxMapper);
267
+ },
268
+ async get (orderUniqueId, uniqueId) {
269
+ const response = await transport.get(`/orders/${orderUniqueId}/taxes/${uniqueId}`);
270
+ return decodeOne(response, orderTaxMapper);
271
+ },
272
+ async create (orderUniqueId, data) {
273
+ const response = await transport.post(`/orders/${orderUniqueId}/taxes`, {
274
+ order_tax: {
275
+ name: data.name,
276
+ rate: data.rate,
277
+ amount: data.amount,
278
+ type: data.type,
279
+ payload: data.payload
280
+ }
281
+ });
282
+ return decodeOne(response, orderTaxMapper);
283
+ },
284
+ async update (orderUniqueId, uniqueId, data) {
285
+ const response = await transport.put(`/orders/${orderUniqueId}/taxes/${uniqueId}`, {
286
+ order_tax: {
287
+ name: data.name,
288
+ rate: data.rate,
289
+ amount: data.amount,
290
+ type: data.type,
291
+ payload: data.payload
292
+ }
293
+ });
294
+ return decodeOne(response, orderTaxMapper);
295
+ },
296
+ async delete (orderUniqueId, uniqueId) {
297
+ await transport.delete(`/orders/${orderUniqueId}/taxes/${uniqueId}`);
298
+ }
299
+ };
300
+ }
301
+
246
302
  const paymentMapper = {
247
303
  type: 'Payment',
248
304
  map: (resource)=>({
@@ -1729,6 +1785,7 @@ function createSalesBlock(transport, config) {
1729
1785
  return {
1730
1786
  orders: createOrdersService(transport),
1731
1787
  orderDetails: createOrderDetailsService(transport),
1788
+ orderTaxes: createOrderTaxesService(transport),
1732
1789
  payments: createPaymentsService(transport),
1733
1790
  subscriptions: createSubscriptionsService(transport),
1734
1791
  subscriptionModels: createSubscriptionModelsService(transport),
@@ -1,5 +1,6 @@
1
1
  export * from './order.mapper';
2
2
  export * from './order-detail.mapper';
3
+ export * from './order-tax.mapper';
3
4
  export * from './payment.mapper';
4
5
  export * from './subscription.mapper';
5
6
  export * from './subscription-model.mapper';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ResourceMapper } from '@23blocks/jsonapi-codec';
2
+ import type { OrderTax } from '../types/order-tax';
3
+ export declare const orderTaxMapper: ResourceMapper<OrderTax>;
4
+ //# sourceMappingURL=order-tax.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-tax.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/order-tax.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,QAAQ,CAenD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Transport, BlockConfig, BlockMetadata } from '@23blocks/contracts';
2
- import { type OrdersService, type OrderDetailsService, type PaymentsService, type SubscriptionsService, type SubscriptionModelsService, type SalesEntitiesService, type SalesUsersService, type SalesCustomersService, type FlexibleOrdersService, type StripeService, type MercadoPagoService, type VendorPaymentsService } from './services';
2
+ import { type OrdersService, type OrderDetailsService, type OrderTaxesService, type PaymentsService, type SubscriptionsService, type SubscriptionModelsService, type SalesEntitiesService, type SalesUsersService, type SalesCustomersService, type FlexibleOrdersService, type StripeService, type MercadoPagoService, type VendorPaymentsService } from './services';
3
3
  export interface SalesBlockConfig extends BlockConfig {
4
4
  appId: string;
5
5
  tenantId?: string;
@@ -7,6 +7,7 @@ export interface SalesBlockConfig extends BlockConfig {
7
7
  export interface SalesBlock {
8
8
  orders: OrdersService;
9
9
  orderDetails: OrderDetailsService;
10
+ orderTaxes: OrderTaxesService;
10
11
  payments: PaymentsService;
11
12
  subscriptions: SubscriptionsService;
12
13
  subscriptionModels: SubscriptionModelsService;
@@ -1 +1 @@
1
- {"version":3,"file":"sales.block.d.ts","sourceRoot":"","sources":["../../../src/lib/sales.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAaL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,kBAAkB,EAAE,yBAAyB,CAAC;IAC9C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,qBAAqB,CAAC;IACjC,cAAc,EAAE,qBAAqB,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,qBAAqB,CAAC;CACvC;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,GACvB,UAAU,CAeZ;AAED,eAAO,MAAM,kBAAkB,EAAE,aAUhC,CAAC"}
1
+ {"version":3,"file":"sales.block.d.ts","sourceRoot":"","sources":["../../../src/lib/sales.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAcL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,mBAAmB,CAAC;IAClC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,kBAAkB,EAAE,yBAAyB,CAAC;IAC9C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,qBAAqB,CAAC;IACjC,cAAc,EAAE,qBAAqB,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,qBAAqB,CAAC;CACvC;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,GACvB,UAAU,CAgBZ;AAED,eAAO,MAAM,kBAAkB,EAAE,aAUhC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from './orders.service';
2
2
  export * from './order-details.service';
3
+ export * from './order-taxes.service';
3
4
  export * from './payments.service';
4
5
  export * from './subscriptions.service';
5
6
  export * from './subscription-models.service';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Transport } from '@23blocks/contracts';
2
+ import type { OrderTax, CreateOrderTaxRequest, UpdateOrderTaxRequest } from '../types/order-tax';
3
+ export interface OrderTaxesService {
4
+ list(orderUniqueId: string): Promise<OrderTax[]>;
5
+ get(orderUniqueId: string, uniqueId: string): Promise<OrderTax>;
6
+ create(orderUniqueId: string, data: CreateOrderTaxRequest): Promise<OrderTax>;
7
+ update(orderUniqueId: string, uniqueId: string, data: UpdateOrderTaxRequest): Promise<OrderTax>;
8
+ delete(orderUniqueId: string, uniqueId: string): Promise<void>;
9
+ }
10
+ export declare function createOrderTaxesService(transport: Transport, _config: {
11
+ appId: string;
12
+ }): OrderTaxesService;
13
+ //# sourceMappingURL=order-taxes.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-taxes.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/order-taxes.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGjG,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChE,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9E,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChG,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CA0C3G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@23blocks/block-sales",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Sales block for 23blocks SDK - orders, payments, subscriptions, transactions",
5
5
  "license": "MIT",
6
6
  "author": "23blocks <hello@23blocks.com>",