Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
feat: added support for configure and in filter (#809)
Browse files Browse the repository at this point in the history
* feat: added support for `in` filter on Files endpoint

e.g. in(id,4b97cee1-70ea-4d97-8d46-9c441c3317de,2b435629-28d3-4555-9ce1-204a2f72b412)

example use:

```
gateway.Files.Filter({
    in: {
      id: [
        '4b97cee1-70ea-4d97-8d46-9c441c3317de',
        '2b435629-28d3-4555-9ce1-204a2f72b412'
      ]
    }
  }).All()
```

* feat: added support for `configure` for product bundle components on Shopper Product endpoint.

This enables implicit token users to get pricing and configuration for selected component options.

e.g. /catalog/products/14edd744-c615-4a33-a2c2-df999bbb5103/configure

example use:

```
gateway.ShopperCatalog.Products.Configure({
    productId: '14edd744-c615-4a33-a2c2-df999bbb5103',
    selectedOptions: {
      plants: {
        'a158ffa0-5d16-4325-8dcc-be8acd55eecf': 1
      },
      pots: {
        'fc520b37-a709-4032-99b3-8d4ecc990027': 1
      },
      tools: {
        '1cc7f871-1071-4908-a79d-633adc56044a': 1,
        '7ffe107d-c5bd-4de4-b8f0-a58d90cb3cd3': 1
      }
    }
  })
```
  • Loading branch information
field123 authored May 26, 2023
1 parent 094fece commit 94ac843
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
19 changes: 19 additions & 0 deletions src/endpoints/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,25 @@ class Products extends ShopperCatalogProductsQuery {
)
}

Configure({
productId,
selectedOptions,
token = null,
additionalHeaders = null
}) {
return this.request.send(
`catalog/${this.endpoint}/${productId}/configure`,
'POST',
{
selected_options: selectedOptions
},
token,
undefined,
true,
additionalHeaders
)
}

Get({ productId, token = null, additionalHeaders = null }) {
const { includes } = this

Expand Down
11 changes: 11 additions & 0 deletions src/types/catalog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ export interface ShopperCatalogProductsEndpoint
additionalHeaders?: ShopperCatalogAdditionalHeaders
}): Promise<ShopperCatalogResourcePage<ProductResponse>>

Configure(options: {
token?: string
additionalHeaders?: ShopperCatalogAdditionalHeaders
productId: string
selectedOptions: {
[key: string]: {
[key: string]: number
}
}
})

Get(options: {
productId: string
token?: string
Expand Down
17 changes: 10 additions & 7 deletions src/types/file.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export interface FileFilter {
height?: number
file_size?: number
}
in?: {
id?: string[]
}
}

/**
Expand All @@ -81,12 +84,12 @@ export interface FileFilter {
*/
export interface FileEndpoint
extends CrudQueryableResource<
File,
FileBase,
never,
FileFilter,
never,
never
> {
File,
FileBase,
never,
FileFilter,
never,
never
> {
endpoint: 'file'
}

0 comments on commit 94ac843

Please sign in to comment.