docs: Add Services reference (#1548)
This commit is contained in:
136
docs/content/references/services/classes/AuthService.md
Normal file
136
docs/content/references/services/classes/AuthService.md
Normal file
@@ -0,0 +1,136 @@
|
||||
# Class: AuthService
|
||||
|
||||
Can authenticate a user based on email password combination
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`AuthService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new AuthService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/auth.ts:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L12)
|
||||
|
||||
## Methods
|
||||
|
||||
### authenticate
|
||||
|
||||
▸ **authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a given user based on an email, password combination. Uses
|
||||
scrypt to match password with hashed value.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user |
|
||||
| `password` | `string` | the password of the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/auth.ts:78](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### authenticateAPIToken
|
||||
|
||||
▸ **authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a given user with an API token
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `token` | `string` | the api_token of the user to authenticate |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/auth.ts:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### authenticateCustomer
|
||||
|
||||
▸ **authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a customer based on an email, password combination. Uses
|
||||
scrypt to match password with hashed value.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user |
|
||||
| `password` | `string` | the password of the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/auth.ts:123](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L123)
|
||||
|
||||
___
|
||||
|
||||
### comparePassword\_
|
||||
|
||||
▸ **comparePassword_**(`password`, `hash`): `Promise`<`boolean`\>
|
||||
|
||||
Verifies if a password is valid given the provided password hash
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the raw password to check |
|
||||
| `hash` | `string` | the hash to compare against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
the result of the comparison
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/auth.ts:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L28)
|
||||
1210
docs/content/references/services/classes/CartService.md
Normal file
1210
docs/content/references/services/classes/CartService.md
Normal file
File diff suppressed because it is too large
Load Diff
219
docs/content/references/services/classes/ClaimItemService.md
Normal file
219
docs/content/references/services/classes/ClaimItemService.md
Normal file
@@ -0,0 +1,219 @@
|
||||
# Class: ClaimItemService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ClaimItemService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ClaimItemService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L11)
|
||||
|
||||
## Properties
|
||||
|
||||
### claimImageRepository\_
|
||||
|
||||
• **claimImageRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L27)
|
||||
|
||||
___
|
||||
|
||||
### claimTagRepository\_
|
||||
|
||||
• **claimTagRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:26](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L26)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`id`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:212](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L212)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L55)
|
||||
|
||||
___
|
||||
|
||||
### deleteMetadata
|
||||
|
||||
▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\>
|
||||
|
||||
Dedicated method to delete metadata for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the order to delete metadata from. |
|
||||
| `key` | `string` | key for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:259](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L259)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:219](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L219)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets a claim item by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of ClaimItem to retrieve |
|
||||
| `config` | `any` | configuration for the find operation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the ClaimItem
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:234](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L234)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L135)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`ClaimItemService`](ClaimItemService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `manager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ClaimItemService`](ClaimItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim-item.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L36)
|
||||
438
docs/content/references/services/classes/ClaimService.md
Normal file
438
docs/content/references/services/classes/ClaimService.md
Normal file
@@ -0,0 +1,438 @@
|
||||
# Class: ClaimService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ClaimService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ClaimService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L14)
|
||||
|
||||
## Properties
|
||||
|
||||
### addressRepo\_
|
||||
|
||||
• **addressRepo\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L36)
|
||||
|
||||
___
|
||||
|
||||
### claimItemService\_
|
||||
|
||||
• **claimItemService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:37](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L37)
|
||||
|
||||
___
|
||||
|
||||
### claimRepository\_
|
||||
|
||||
• **claimRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L38)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• **eventBus\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L39)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderService\_
|
||||
|
||||
• **fulfillmentProviderService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L40)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentService\_
|
||||
|
||||
• **fulfillmentService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L41)
|
||||
|
||||
___
|
||||
|
||||
### inventoryService\_
|
||||
|
||||
• **inventoryService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L42)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• **lineItemService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L43)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• **paymentProviderService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L44)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• **regionService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L45)
|
||||
|
||||
___
|
||||
|
||||
### returnService\_
|
||||
|
||||
• **returnService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L46)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• **shippingOptionService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L47)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• **taxProviderService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L48)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• **totalsService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L49)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `FULFILLMENT_CREATED` | `string` |
|
||||
| `REFUND_PROCESSED` | `string` |
|
||||
| `SHIPMENT_CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`id`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:644](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L644)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `fulfillmentId` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:512](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L512)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `any`
|
||||
|
||||
Creates a Claim on an Order. Claims consists of items that are claimed and
|
||||
optionally items to be sent as replacement for the claimed items. The
|
||||
shipping address that the new items will be shipped to
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `any` | the object containing all data required to create a claim |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
created claim
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:159](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L159)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`id`, `config?`): `Claim`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the object containing all data required to create a claim |
|
||||
| `config` | `Object` | config object |
|
||||
| `config.metadata` | `any` | config metadata |
|
||||
| `config.no_notification` | `undefined` \| `boolean` | config no notification |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Claim`
|
||||
|
||||
created claim
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:378](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L378)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`id`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `any` | `undefined` |
|
||||
| `fulfillmentId` | `any` | `undefined` |
|
||||
| `trackingLinks` | `any` | `undefined` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.metadata` | `Object` | `{}` |
|
||||
| `config.no_notification` | `undefined` | `undefined` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:577](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L577)
|
||||
|
||||
___
|
||||
|
||||
### deleteMetadata
|
||||
|
||||
▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\>
|
||||
|
||||
Dedicated method to delete metadata for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the order to delete metadata from. |
|
||||
| `key` | `string` | key for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:734](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L734)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:696](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L696)
|
||||
|
||||
___
|
||||
|
||||
### processRefund
|
||||
|
||||
▸ **processRefund**(`id`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:535](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L535)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`claimId`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `claimId` | `string` | id of order to retrieve |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:711](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L711)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L80)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`ClaimService`](ClaimService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `manager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ClaimService`](ClaimService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/claim.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L52)
|
||||
@@ -0,0 +1,126 @@
|
||||
# Class: CustomShippingOptionService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`CustomShippingOptionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomShippingOptionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/custom-shipping-option.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`, `config?`): `Promise`<`CustomShippingOption`\>
|
||||
|
||||
Creates a custom shipping option associated with a given author
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `any` | the custom shipping option to create |
|
||||
| `config` | `any` | any configurations if needed, including meta data |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomShippingOption`\>
|
||||
|
||||
resolves to the creation result
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/custom-shipping-option.js:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L88)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`CustomShippingOption`[]\>
|
||||
|
||||
Fetches all custom shipping options related to the given selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomShippingOption`[]\>
|
||||
|
||||
custom shipping options matching the query
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/custom-shipping-option.js:65](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L65)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`CustomShippingOption`\>
|
||||
|
||||
Retrieves a specific shipping option.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the custom shipping option to retrieve. |
|
||||
| `config` | `any` | any options needed to query for the result. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomShippingOption`\>
|
||||
|
||||
which resolves to the requested custom shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/custom-shipping-option.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L40)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
Sets the service's manager to a given transaction manager
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `manager` | `EntityManager` | the manager to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
a cloned CustomShippingOption service
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/custom-shipping-option.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L20)
|
||||
275
docs/content/references/services/classes/CustomerGroupService.md
Normal file
275
docs/content/references/services/classes/CustomerGroupService.md
Normal file
@@ -0,0 +1,275 @@
|
||||
# Class: CustomerGroupService
|
||||
|
||||
Provides layer to manipulate discounts.
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`CustomerGroupService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomerGroupService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `CustomerGroupConstructorProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L31)
|
||||
|
||||
## Properties
|
||||
|
||||
### customerGroupRepository\_
|
||||
|
||||
• `Private` **customerGroupRepository\_**: typeof `CustomerGroupRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Private` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L25)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCustomers
|
||||
|
||||
▸ **addCustomers**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Add a batch of customers to a customer group at once
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the customer group to add customers to |
|
||||
| `customerIds` | `string` \| `string`[] | customer id's to add to the group |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the customer group after insertion
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:113](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L113)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`group`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Creates a customer group with the provided data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `group` | `DeepPartial`<`CustomerGroup`\> | the customer group to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:86](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L86)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`groupId`): `Promise`<`void`\>
|
||||
|
||||
Remove customer group
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `groupId` | `string` | id of the customer group to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
a promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:194](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L194)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config`): `Promise`<`CustomerGroup`[]\>
|
||||
|
||||
List customer groups.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableCustomerGroupProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:217](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config`): `Promise`<[`CustomerGroup`[], `number`]\>
|
||||
|
||||
Retrieve a list of customer groups and total count of records that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableCustomerGroupProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`CustomerGroup`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:236](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L236)
|
||||
|
||||
___
|
||||
|
||||
### removeCustomer
|
||||
|
||||
▸ **removeCustomer**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Remove list of customers from a customergroup
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the customer group from which the customers are removed |
|
||||
| `customerIds` | `string` \| `string`[] | id's of the customer to remove from group |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the customergroup with the provided id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:271](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L271)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`customerGroupId`, `update`): `Promise`<`CustomerGroup`[]\>
|
||||
|
||||
Update a customer group.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerGroupId` | `string` | id of the customer group |
|
||||
| `update` | `CustomerGroupUpdate` | customer group partial data |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`[]\>
|
||||
|
||||
resulting customer group
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:162](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L162)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`CustomerGroupService`](CustomerGroupService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomerGroupService`](CustomerGroupService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer-group.ts:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L46)
|
||||
452
docs/content/references/services/classes/CustomerService.md
Normal file
452
docs/content/references/services/classes/CustomerService.md
Normal file
@@ -0,0 +1,452 @@
|
||||
# Class: CustomerService
|
||||
|
||||
Provides layer to manipulate customers.
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`CustomerService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomerService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L20)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `PASSWORD_RESET` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L14)
|
||||
|
||||
## Methods
|
||||
|
||||
### addAddress
|
||||
|
||||
▸ **addAddress**(`customerId`, `address`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `any` |
|
||||
| `address` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:479](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L479)
|
||||
|
||||
___
|
||||
|
||||
### count
|
||||
|
||||
▸ **count**(): `Promise`<`any`\>
|
||||
|
||||
Return the total number of documents in database
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the count operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:192](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L192)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`customer`): `Promise`<`any`\>
|
||||
|
||||
Creates a customer from an email - customers can have accounts associated,
|
||||
e.g. to login and view order history, etc. If a password is provided the
|
||||
customer will automatically get an account, otherwise the customer is just
|
||||
used to hold details of customers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customer` | `any` | the customer to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:290](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L290)
|
||||
|
||||
___
|
||||
|
||||
### decorate
|
||||
|
||||
▸ **decorate**(`customer`, `fields?`, `expandFields?`): `Customer`
|
||||
|
||||
Decorates a customer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `customer` | `Customer` | `undefined` | the cart to decorate. |
|
||||
| `fields` | `string`[] | `[]` | the fields to include. |
|
||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Customer`
|
||||
|
||||
return the decorated customer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:547](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L547)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`customerId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a customer from a given customer id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the customer to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:523](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L523)
|
||||
|
||||
___
|
||||
|
||||
### generateResetPasswordToken
|
||||
|
||||
▸ **generateResetPasswordToken**(`customerId`): `string`
|
||||
|
||||
Generate a JSON Web token, that will be sent to a customer, that wishes to
|
||||
reset password.
|
||||
The token will be signed with the customer's current password hash as a
|
||||
secret a long side a payload with userId and the expiry time for the token,
|
||||
which is always 15 minutes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the customer to reset the password for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the generated JSON web token
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:67](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L67)
|
||||
|
||||
___
|
||||
|
||||
### hashPassword\_
|
||||
|
||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||
|
||||
Hashes a password
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the value to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
hashed password
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:277](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L277)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:106](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L106)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:147](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L147)
|
||||
|
||||
___
|
||||
|
||||
### removeAddress
|
||||
|
||||
▸ **removeAddress**(`customerId`, `addressId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `any` |
|
||||
| `addressId` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L460)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`customerId`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a customer by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the customer to get. |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:205](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L205)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByEmail
|
||||
|
||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a customer by email.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the customer to get. |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:230](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L230)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByPhone
|
||||
|
||||
▸ **retrieveByPhone**(`phone`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a customer by phone.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `phone` | `string` | the phone of the customer to get. |
|
||||
| `config` | `any` | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:254](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L254)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`customerId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a customer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the variant. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:346](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L346)
|
||||
|
||||
___
|
||||
|
||||
### updateAddress
|
||||
|
||||
▸ **updateAddress**(`customerId`, `addressId`, `address`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `any` |
|
||||
| `addressId` | `any` |
|
||||
| `address` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:441](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L441)
|
||||
|
||||
___
|
||||
|
||||
### updateBillingAddress\_
|
||||
|
||||
▸ **updateBillingAddress_**(`customer`, `addressOrId`, `addrRepo`): `Promise`<`any`\>
|
||||
|
||||
Updates the customers' billing address.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customer` | `Customer` | the Customer to update |
|
||||
| `addressOrId` | `any` | the value to set the billing address to |
|
||||
| `addrRepo` | `any` | address repository |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:408](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L408)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/customer.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L41)
|
||||
637
docs/content/references/services/classes/DiscountService.md
Normal file
637
docs/content/references/services/classes/DiscountService.md
Normal file
@@ -0,0 +1,637 @@
|
||||
# Class: DiscountService
|
||||
|
||||
Provides layer to manipulate discounts.
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`DiscountService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new DiscountService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L59)
|
||||
|
||||
## Properties
|
||||
|
||||
### discountConditionRepository\_
|
||||
|
||||
• `Private` **discountConditionRepository\_**: typeof `DiscountConditionRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### discountConditionService\_
|
||||
|
||||
• `Private` **discountConditionService\_**: `DiscountConditionService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:53](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### discountRepository\_
|
||||
|
||||
• `Private` **discountRepository\_**: typeof `DiscountRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### discountRuleRepository\_
|
||||
|
||||
• `Private` **discountRuleRepository\_**: typeof `DiscountRuleRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:50](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:57](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### giftCardRepository\_
|
||||
|
||||
• `Private` **giftCardRepository\_**: typeof `GiftCardRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L51)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Private` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Private` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Private` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:54](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L54)
|
||||
|
||||
## Methods
|
||||
|
||||
### addRegion
|
||||
|
||||
▸ **addRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||
|
||||
Adds a region to the discount regions array.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount |
|
||||
| `regionId` | `string` | id of region to add |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:521](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L521)
|
||||
|
||||
___
|
||||
|
||||
### calculateDiscountForLineItem
|
||||
|
||||
▸ **calculateDiscountForLineItem**(`discountId`, `lineItem`, `cart`): `Promise`<`number`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountId` | `string` |
|
||||
| `lineItem` | `LineItem` |
|
||||
| `cart` | `Cart` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:624](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L624)
|
||||
|
||||
___
|
||||
|
||||
### canApplyForCustomer
|
||||
|
||||
▸ **canApplyForCustomer**(`discountRuleId`, `customerId`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountRuleId` | `string` |
|
||||
| `customerId` | `undefined` \| `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:762](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L762)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`discount`): `Promise`<`Discount`\>
|
||||
|
||||
Creates a discount with provided data given that the data is validated.
|
||||
Normalizes discount code to uppercase.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discount` | `CreateDiscountInput` | the discount data to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:220](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L220)
|
||||
|
||||
___
|
||||
|
||||
### createDynamicCode
|
||||
|
||||
▸ **createDynamicCode**(`discountId`, `data`): `Promise`<`Discount`\>
|
||||
|
||||
Creates a dynamic code for a discount id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | the id of the discount to create a code for |
|
||||
| `data` | `CreateDynamicDiscountInput` | the object containing a code to identify the discount by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the newly created dynamic code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:446](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L446)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`discountId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a discount idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:583](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L583)
|
||||
|
||||
___
|
||||
|
||||
### deleteDynamicCode
|
||||
|
||||
▸ **deleteDynamicCode**(`discountId`, `code`): `Promise`<`void`\>
|
||||
|
||||
Deletes a dynamic code for a discount id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | the id of the discount to create a code for |
|
||||
| `code` | `string` | the code to identify the discount by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the newly created dynamic code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:498](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L498)
|
||||
|
||||
___
|
||||
|
||||
### hasExpired
|
||||
|
||||
▸ **hasExpired**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:733](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L733)
|
||||
|
||||
___
|
||||
|
||||
### hasNotStarted
|
||||
|
||||
▸ **hasNotStarted**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:729](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L729)
|
||||
|
||||
___
|
||||
|
||||
### hasReachedLimit
|
||||
|
||||
▸ **hasReachedLimit**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:723](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L723)
|
||||
|
||||
___
|
||||
|
||||
### isDisabled
|
||||
|
||||
▸ **isDisabled**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:741](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L741)
|
||||
|
||||
___
|
||||
|
||||
### isValidForRegion
|
||||
|
||||
▸ **isValidForRegion**(`discount`, `region_id`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
| `region_id` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:745](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L745)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`Discount`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:156](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L156)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Discount`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Discount`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:173](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L173)
|
||||
|
||||
___
|
||||
|
||||
### removeRegion
|
||||
|
||||
▸ **removeRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||
|
||||
Removes a region from the discount regions array.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount |
|
||||
| `regionId` | `string` | id of region to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:557](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L557)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`discountId`, `config?`): `Promise`<`Discount`\>
|
||||
|
||||
Gets a discount by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount to retrieve |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:285](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L285)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCode
|
||||
|
||||
▸ **retrieveByCode**(`discountCode`, `config?`): `Promise`<`Discount`\>
|
||||
|
||||
Gets a discount by discount code.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountCode` | `string` | discount code of discount to retrieve |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the discount document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:313](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L313)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`discountId`, `update`): `Promise`<`Discount`\>
|
||||
|
||||
Updates a discount.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | discount id of discount to update |
|
||||
| `update` | `UpdateDiscountInput` | the data to update the discount with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:348](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L348)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountForCartOrThrow
|
||||
|
||||
▸ **validateDiscountForCartOrThrow**(`cart`, `discount`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cart` | `Cart` |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:665](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L665)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountForProduct
|
||||
|
||||
▸ **validateDiscountForProduct**(`discountRuleId`, `productId`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountRuleId` | `string` |
|
||||
| `productId` | `undefined` \| `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:599](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L599)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountRule\_
|
||||
|
||||
▸ **validateDiscountRule_**<`T`\>(`discountRule`): `T`
|
||||
|
||||
Creates a discount rule with provided data given that the data is validated.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | extends `Object` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountRule` | `T` | the discount rule to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:138](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L138)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`DiscountService`](DiscountService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`DiscountService`](DiscountService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/discount.ts:108](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L108)
|
||||
266
docs/content/references/services/classes/DraftOrderService.md
Normal file
266
docs/content/references/services/classes/DraftOrderService.md
Normal file
@@ -0,0 +1,266 @@
|
||||
# Class: DraftOrderService
|
||||
|
||||
Handles draft orders
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`DraftOrderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new DraftOrderService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L15)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L10)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Creates a draft order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `any` | data to create draft order from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the created draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:233](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L233)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`draftOrderId`): `Promise`<`any`\>
|
||||
|
||||
Deletes draft order idempotently.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `draftOrderId` | `string` | id of draft order to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L135)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Lists draft orders
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | query object for find |
|
||||
| `config` | `any` | configurable attributes for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
list of draft orders
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:215](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L215)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<`DraftOrder`[]\>
|
||||
|
||||
Lists draft orders alongside the count
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | query selector to filter draft orders |
|
||||
| `config` | `any` | query config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`[]\>
|
||||
|
||||
draft orders
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L161)
|
||||
|
||||
___
|
||||
|
||||
### registerCartCompletion
|
||||
|
||||
▸ **registerCartCompletion**(`doId`, `orderId`): `Promise`<`any`\>
|
||||
|
||||
Registers a draft order as completed, when an order has been completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `doId` | `string` | id of draft order to complete |
|
||||
| `orderId` | `string` | id of order completed from draft order cart |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the created order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:336](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L336)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Retrieves a draft order with the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the draft order to retrieve |
|
||||
| `config` | `any` | query object for findOne |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L84)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCartId
|
||||
|
||||
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Retrieves a draft order based on its associated cart id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartId` | `string` | cart id that the draft orders's cart has |
|
||||
| `config` | `any` | query object for findOne |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:111](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L111)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`doId`, `data`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Updates a draft order with the given data
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `doId` | `string` | id of the draft order |
|
||||
| `data` | `DraftOrder` | values to update the order with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the updated draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:357](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L357)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`DraftOrderService`](DraftOrderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`DraftOrderService`](DraftOrderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/draft-order.js:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L56)
|
||||
332
docs/content/references/services/classes/EventBusService.md
Normal file
332
docs/content/references/services/classes/EventBusService.md
Normal file
@@ -0,0 +1,332 @@
|
||||
# Class: EventBusService
|
||||
|
||||
Can keep track of multiple subscribers to different events and run the
|
||||
subscribers when events happen. Events will run asynchronously.
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new EventBusService**(`__namedParameters`, `config`, `singleton?`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `__namedParameters` | `Object` | `undefined` |
|
||||
| `config` | `any` | `undefined` |
|
||||
| `singleton` | `boolean` | `true` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L10)
|
||||
|
||||
## Properties
|
||||
|
||||
### config\_
|
||||
|
||||
• **config\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L31)
|
||||
|
||||
___
|
||||
|
||||
### enRun\_
|
||||
|
||||
• **enRun\_**: `undefined` \| `boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:182](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L182)
|
||||
|
||||
___
|
||||
|
||||
### enqueue\_
|
||||
|
||||
• **enqueue\_**: `undefined` \| `Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:183](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L183)
|
||||
|
||||
___
|
||||
|
||||
### redisClient\_
|
||||
|
||||
• **redisClient\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L51)
|
||||
|
||||
___
|
||||
|
||||
### redisSubscriber\_
|
||||
|
||||
• **redisSubscriber\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L52)
|
||||
|
||||
___
|
||||
|
||||
### stagedJobRepository\_
|
||||
|
||||
• **stagedJobRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L39)
|
||||
|
||||
## Methods
|
||||
|
||||
### createCronJob
|
||||
|
||||
▸ **createCronJob**(`eventName`, `data`, `cron`, `handler`): `void`
|
||||
|
||||
Registers a cron job.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the name of the event |
|
||||
| `data` | `any` | the data to be sent with the event |
|
||||
| `cron` | `string` | the cron pattern |
|
||||
| `handler` | `Function` | the handler to call on each cron job |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:280](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L280)
|
||||
|
||||
___
|
||||
|
||||
### cronWorker\_
|
||||
|
||||
▸ **cronWorker_**(`job`): `Promise`<`any`\>
|
||||
|
||||
Handles incoming jobs.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `job` | `any` | The job object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the results of the subscriber calls.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:255](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L255)
|
||||
|
||||
___
|
||||
|
||||
### emit
|
||||
|
||||
▸ **emit**(`eventName`, `data`, `options?`): `BullJob`
|
||||
|
||||
Calls all subscribers when an event occurs.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the name of the event to be process. |
|
||||
| `data` | `any` | the data to send to the subscriber. |
|
||||
| `options` | `any` | options to add the job with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`BullJob`
|
||||
|
||||
- the job from our queue
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:154](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L154)
|
||||
|
||||
___
|
||||
|
||||
### enqueuer\_
|
||||
|
||||
▸ **enqueuer_**(): `Promise`<`void`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:191](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L191)
|
||||
|
||||
___
|
||||
|
||||
### registerCronHandler\_
|
||||
|
||||
▸ **registerCronHandler_**(`event`, `subscriber`): `void`
|
||||
|
||||
Adds a function to a list of event subscribers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` | the event that the subscriber will listen for. |
|
||||
| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L135)
|
||||
|
||||
___
|
||||
|
||||
### sleep
|
||||
|
||||
▸ **sleep**(`ms`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `ms` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:175](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L175)
|
||||
|
||||
___
|
||||
|
||||
### startEnqueuer
|
||||
|
||||
▸ **startEnqueuer**(): `Promise`<`void`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:181](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L181)
|
||||
|
||||
___
|
||||
|
||||
### stopEnqueuer
|
||||
|
||||
▸ **stopEnqueuer**(): `Promise`<`void`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:186](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L186)
|
||||
|
||||
___
|
||||
|
||||
### subscribe
|
||||
|
||||
▸ **subscribe**(`event`, `subscriber`): `void`
|
||||
|
||||
Adds a function to a list of event subscribers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` | the event that the subscriber will listen for. |
|
||||
| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L98)
|
||||
|
||||
___
|
||||
|
||||
### unsubscribe
|
||||
|
||||
▸ **unsubscribe**(`event`, `subscriber`): `void`
|
||||
|
||||
Adds a function to a list of event subscribers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` | the event that the subscriber will listen for. |
|
||||
| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L116)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:69](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L69)
|
||||
|
||||
___
|
||||
|
||||
### worker\_
|
||||
|
||||
▸ **worker_**(`job`): `Promise`<`any`\>
|
||||
|
||||
Handles incoming jobs.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `job` | `any` | The job object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the results of the subscriber calls.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/event-bus.js:226](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L226)
|
||||
@@ -0,0 +1,266 @@
|
||||
# Class: FulfillmentProviderService
|
||||
|
||||
Helps retrive fulfillment providers
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new FulfillmentProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `any` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:7](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L7)
|
||||
|
||||
## Methods
|
||||
|
||||
### calculatePrice
|
||||
|
||||
▸ **calculatePrice**(`option`, `data`, `cart`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `any` |
|
||||
| `data` | `any` |
|
||||
| `cart` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:79](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L79)
|
||||
|
||||
___
|
||||
|
||||
### canCalculate
|
||||
|
||||
▸ **canCalculate**(`option`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:64](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L64)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillment`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `fulfillment` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:74](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L74)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`method`, `items`, `order`, `fulfillment`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `method` | `any` |
|
||||
| `items` | `any` |
|
||||
| `order` | `any` |
|
||||
| `fulfillment` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L59)
|
||||
|
||||
___
|
||||
|
||||
### createReturn
|
||||
|
||||
▸ **createReturn**(`returnOrder`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnOrder` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L89)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`any`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L23)
|
||||
|
||||
___
|
||||
|
||||
### listFulfillmentOptions
|
||||
|
||||
▸ **listFulfillmentOptions**(`providers`): `Promise`<`any`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L30)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L12)
|
||||
|
||||
___
|
||||
|
||||
### retrieveDocuments
|
||||
|
||||
▸ **retrieveDocuments**(`providerId`, `fulfillmentData`, `documentType`): `Promise`<`any`\>
|
||||
|
||||
Fetches documents from the fulfillment provider
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the id of the provider |
|
||||
| `fulfillmentData` | `any` | the data relating to the fulfillment |
|
||||
| `documentType` | ``"invoice"`` \| ``"label"`` | the typ of document to fetch |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L102)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**(`provider_id`): `FulfillmentService`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `provider_id` | `string` | the provider id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`FulfillmentService`
|
||||
|
||||
the payment fulfillment provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L48)
|
||||
|
||||
___
|
||||
|
||||
### validateFulfillmentData
|
||||
|
||||
▸ **validateFulfillmentData**(`option`, `data`, `cart`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `any` |
|
||||
| `data` | `any` |
|
||||
| `cart` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:69](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L69)
|
||||
|
||||
___
|
||||
|
||||
### validateOption
|
||||
|
||||
▸ **validateOption**(`option`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment-provider.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L84)
|
||||
234
docs/content/references/services/classes/FulfillmentService.md
Normal file
234
docs/content/references/services/classes/FulfillmentService.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# Class: FulfillmentService
|
||||
|
||||
Handles Fulfillments
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`FulfillmentService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new FulfillmentService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L9)
|
||||
|
||||
## Methods
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentOrId`): `Promise`<`any`\>
|
||||
|
||||
Cancels a fulfillment with the fulfillment provider. Will decrement the
|
||||
fulfillment_quantity on the line items associated with the fulfillment.
|
||||
Throws if the fulfillment has already been shipped.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentOrId` | `any` | the fulfillment object or id. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the save operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:223](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L223)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`order`, `itemsToFulfill`, `custom?`): `Fulfillment`[]
|
||||
|
||||
Creates an order fulfillment
|
||||
If items needs to be fulfilled by different provider, we make
|
||||
sure to partition those items, and create fulfillment for
|
||||
those partitions.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | order to create fulfillment for |
|
||||
| `itemsToFulfill` | { `item_id`: `string` ; `quantity`: `number` }[] | - |
|
||||
| `custom` | `any` | potential custom values to add |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Fulfillment`[]
|
||||
|
||||
the created fulfillments
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:171](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L171)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`fulfillmentId`, `trackingLinks`, `config?`): `Fulfillment`
|
||||
|
||||
Creates a shipment by marking a fulfillment as shipped. Adds
|
||||
tracking links and potentially more metadata.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `Order` | the fulfillment to ship |
|
||||
| `trackingLinks` | `TrackingLink`[] | tracking links for the shipment |
|
||||
| `config` | `any` | potential configuration settings, such as no_notification and metadata |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Fulfillment`
|
||||
|
||||
the shipped fulfillment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:270](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L270)
|
||||
|
||||
___
|
||||
|
||||
### getFulfillmentItems\_
|
||||
|
||||
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Retrieves the order line items, given an array of items.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get line items from |
|
||||
| `items` | `Object` | the items to get |
|
||||
| `items.item_id` | `string` | - |
|
||||
| `items.quantity` | `number` | - |
|
||||
| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the line items generated by the transformer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:94](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L94)
|
||||
|
||||
___
|
||||
|
||||
### partitionItems\_
|
||||
|
||||
▸ **partitionItems_**(`shippingMethods`, `items`): { `shipping_method`: `any` = method }[]
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingMethods` | `any` |
|
||||
| `items` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
{ `shipping_method`: `any` = method }[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L62)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Fulfillment`
|
||||
|
||||
Retrieves a fulfillment by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the fulfillment to retrieve |
|
||||
| `config` | `any` | optional values to include with fulfillmentRepository query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Fulfillment`
|
||||
|
||||
the fulfillment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:142](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L142)
|
||||
|
||||
___
|
||||
|
||||
### validateFulfillmentLineItem\_
|
||||
|
||||
▸ **validateFulfillmentLineItem_**(`item`, `quantity`): `LineItem`
|
||||
|
||||
Checks that a given quantity of a line item can be fulfilled. Fails if the
|
||||
fulfillable quantity is lower than the requested fulfillment quantity.
|
||||
Fulfillable quantity is calculated by subtracting the already fulfilled
|
||||
quantity from the quantity that was originally purchased.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `item` | `LineItem` | the line item to check has sufficient fulfillable quantity. |
|
||||
| `quantity` | `number` | the quantity that is requested to be fulfilled. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineItem`
|
||||
|
||||
a line item that has the requested fulfillment quantity
|
||||
set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L116)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/fulfillment.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L42)
|
||||
245
docs/content/references/services/classes/GiftCardService.md
Normal file
245
docs/content/references/services/classes/GiftCardService.md
Normal file
@@ -0,0 +1,245 @@
|
||||
# Class: GiftCardService
|
||||
|
||||
Provides layer to manipulate gift cards.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`GiftCardService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new GiftCardService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L15)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L11)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`giftCard`): `Promise`<`GiftCard`\>
|
||||
|
||||
Creates a gift card with provided data given that the data is validated.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCard` | `GiftCard` | the gift card data to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:134](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L134)
|
||||
|
||||
___
|
||||
|
||||
### createTransaction
|
||||
|
||||
▸ **createTransaction**(`data`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L120)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`giftCardId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a gift card idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | id of gift card to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:288](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L288)
|
||||
|
||||
___
|
||||
|
||||
### generateCode\_
|
||||
|
||||
▸ **generateCode_**(): `string`
|
||||
|
||||
Generates a 16 character gift card code
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the generated gift card code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L62)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:78](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L78)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`giftCardId`, `config?`): `Promise`<`GiftCard`\>
|
||||
|
||||
Gets a gift card by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | id of gift card to retrieve |
|
||||
| `config` | `any` | optional values to include with gift card query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
the gift card
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:175](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L175)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCode
|
||||
|
||||
▸ **retrieveByCode**(`code`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `any` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:209](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L209)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`giftCardId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a giftCard.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | giftCard id of giftCard to update |
|
||||
| `update` | `GiftCard` | the data to update the giftCard with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:247](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L247)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`GiftCardService`](GiftCardService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`GiftCardService`](GiftCardService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/gift-card.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L40)
|
||||
@@ -0,0 +1,182 @@
|
||||
# Class: IdempotencyKeyService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`IdempotencyKeyService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new IdempotencyKeyService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`payload`): `Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
Creates an idempotency key for a request.
|
||||
If no idempotency key is provided in request, we will create a unique
|
||||
identifier.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `payload` | `any` | payload of request to create idempotency key for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
the created idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L55)
|
||||
|
||||
___
|
||||
|
||||
### initializeRequest
|
||||
|
||||
▸ **initializeRequest**(`headerKey`, `reqMethod`, `reqParams`, `reqPath`): `Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
Execute the initial steps in a idempotent request.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `headerKey` | `string` | potential idempotency key from header |
|
||||
| `reqMethod` | `string` | method of request |
|
||||
| `reqParams` | `string` | params of request |
|
||||
| `reqPath` | `string` | path of request |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
the existing or created idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L29)
|
||||
|
||||
___
|
||||
|
||||
### lock
|
||||
|
||||
▸ **lock**(`idempotencyKey`): `Promise`<`any`\>
|
||||
|
||||
Locks an idempotency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | key to lock |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:94](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L94)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`idempotencyKey`): `Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
Retrieves an idempotency key
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | key to retrieve |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKeyModel`\>
|
||||
|
||||
idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:76](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L76)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`idempotencyKey`, `update`): `Promise`<`any`\>
|
||||
|
||||
Locks an idempotency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | key to update |
|
||||
| `update` | `any` | update object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L121)
|
||||
|
||||
___
|
||||
|
||||
### workStage
|
||||
|
||||
▸ **workStage**(`idempotencyKey`, `func`): `IdempotencyKeyModel`
|
||||
|
||||
Performs an atomic work stage.
|
||||
An atomic work stage contains some related functionality, that needs to be
|
||||
transactionally executed in isolation. An idempotent request will
|
||||
always consist of 2 or more of these phases. The required phases are
|
||||
"started" and "finished".
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | current idempotency key |
|
||||
| `func` | `Function` | functionality to execute within the phase |
|
||||
|
||||
#### Returns
|
||||
|
||||
`IdempotencyKeyModel`
|
||||
|
||||
new updated idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/idempotency-key.js:148](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L148)
|
||||
99
docs/content/references/services/classes/InventoryService.md
Normal file
99
docs/content/references/services/classes/InventoryService.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# Class: InventoryService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`InventoryService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new InventoryService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/inventory.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### adjustInventory
|
||||
|
||||
▸ **adjustInventory**(`variantId`, `adjustment`): `Promise`<`any`\>
|
||||
|
||||
Updates the inventory of a variant based on a given adjustment.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to update |
|
||||
| `adjustment` | `number` | the number to adjust the inventory quantity by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/inventory.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L36)
|
||||
|
||||
___
|
||||
|
||||
### confirmInventory
|
||||
|
||||
▸ **confirmInventory**(`variantId`, `quantity`): `Promise`<`boolean`\>
|
||||
|
||||
Checks if the inventory of a variant can cover a given quantity. Will
|
||||
return true if the variant doesn't have managed inventory or if the variant
|
||||
allows backorders or if the inventory quantity is greater than `quantity`.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to check |
|
||||
| `quantity` | `number` | the number of units to check availability for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
true if the inventory covers the quantity
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/inventory.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L62)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`InventoryService`](InventoryService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`InventoryService`](InventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/inventory.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L15)
|
||||
305
docs/content/references/services/classes/LineItemService.md
Normal file
305
docs/content/references/services/classes/LineItemService.md
Normal file
@@ -0,0 +1,305 @@
|
||||
# Class: LineItemService
|
||||
|
||||
Provides layer to manipulate line items.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`LineItemService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new LineItemService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L38)
|
||||
|
||||
## Properties
|
||||
|
||||
### cartRepository\_
|
||||
|
||||
• `Protected` `Readonly` **cartRepository\_**: typeof `CartRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### itemTaxLineRepo\_
|
||||
|
||||
• `Protected` `Readonly` **itemTaxLineRepo\_**: typeof `LineItemTaxLineRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### lineItemAdjustmentService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemAdjustmentService\_**: `LineItemAdjustmentService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### lineItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemRepository\_**: typeof `LineItemRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` `Readonly` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:33](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L35)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`LineItem`\>
|
||||
|
||||
Create a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `Partial`<`LineItem`\> | the line item object to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
the created line item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:261](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L261)
|
||||
|
||||
___
|
||||
|
||||
### createReturnLines
|
||||
|
||||
▸ **createReturnLines**(`returnId`, `cartId`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Creates return line items for a given cart based on the return items in a
|
||||
return.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnId` | `string` | the id to generate return items from. |
|
||||
| `cartId` | `string` | the cart to assign the return line items to. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the created line items
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:133](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L133)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`undefined` \| `LineItem`\>
|
||||
|
||||
Deletes a line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `LineItem`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:309](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L309)
|
||||
|
||||
___
|
||||
|
||||
### generate
|
||||
|
||||
▸ **generate**(`variantId`, `regionId`, `quantity`, `context?`): `Promise`<`LineItem`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantId` | `string` |
|
||||
| `regionId` | `string` |
|
||||
| `quantity` | `number` |
|
||||
| `context` | `Object` |
|
||||
| `context.cart?` | `Cart` |
|
||||
| `context.customer_id?` | `string` |
|
||||
| `context.metadata?` | `Record`<`string`, `unknown`\> |
|
||||
| `context.unit_price?` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:186](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L186)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`LineItem`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | `undefined` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.order` | `Object` | `undefined` |
|
||||
| `config.order.created_at` | `string` | `"DESC"` |
|
||||
| `config.skip` | `number` | `0` |
|
||||
| `config.take` | `number` | `50` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:81](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`LineItem`\>
|
||||
|
||||
Retrieves a line item by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to retrieve |
|
||||
| `config` | `Object` | the config to be used at query building |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
the line item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`LineItem`\>
|
||||
|
||||
Updates a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to update |
|
||||
| `data` | `Partial`<`LineItem`\> | the properties to update on line item |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
the update line item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:280](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L280)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/line-item.ts:60](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L60)
|
||||
248
docs/content/references/services/classes/MiddlewareService.md
Normal file
248
docs/content/references/services/classes/MiddlewareService.md
Normal file
@@ -0,0 +1,248 @@
|
||||
# Class: MiddlewareService
|
||||
|
||||
Orchestrates dynamic middleware registered through the Medusa Middleware API
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new MiddlewareService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `any` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:7](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L7)
|
||||
|
||||
## Properties
|
||||
|
||||
### postAuthentication\_
|
||||
|
||||
• **postAuthentication\_**: `any`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L8)
|
||||
|
||||
___
|
||||
|
||||
### preAuthentication\_
|
||||
|
||||
• **preAuthentication\_**: `any`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L9)
|
||||
|
||||
___
|
||||
|
||||
### preCartCreation\_
|
||||
|
||||
• **preCartCreation\_**: `any`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L10)
|
||||
|
||||
___
|
||||
|
||||
### routers
|
||||
|
||||
• **routers**: `Object`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L11)
|
||||
|
||||
## Methods
|
||||
|
||||
### addPostAuthentication
|
||||
|
||||
▸ **addPostAuthentication**(`middleware`, `options`): `void`
|
||||
|
||||
Adds a middleware function to be called after authentication is completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
||||
| `options` | `any` | the arguments that will be passed to the middleware |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L45)
|
||||
|
||||
___
|
||||
|
||||
### addPreAuthentication
|
||||
|
||||
▸ **addPreAuthentication**(`middleware`, `options`): `void`
|
||||
|
||||
Adds a middleware function to be called before authentication is completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
||||
| `options` | `any` | the arguments that will be passed to the middleware |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:61](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L61)
|
||||
|
||||
___
|
||||
|
||||
### addPreCartCreation
|
||||
|
||||
▸ **addPreCartCreation**(`middleware`): `void`
|
||||
|
||||
Adds a middleware function to be called before cart creation
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:75](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L75)
|
||||
|
||||
___
|
||||
|
||||
### addRouter
|
||||
|
||||
▸ **addRouter**(`path`, `router`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `path` | `any` |
|
||||
| `router` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L14)
|
||||
|
||||
___
|
||||
|
||||
### getRouters
|
||||
|
||||
▸ **getRouters**(`path`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `path` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L19)
|
||||
|
||||
___
|
||||
|
||||
### usePostAuthentication
|
||||
|
||||
▸ **usePostAuthentication**(`app`): `void`
|
||||
|
||||
Adds post authentication middleware to an express app.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `app` | `ExpressApp` | the express app to add the middleware to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:85](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L85)
|
||||
|
||||
___
|
||||
|
||||
### usePreAuthentication
|
||||
|
||||
▸ **usePreAuthentication**(`app`): `void`
|
||||
|
||||
Adds pre authentication middleware to an express app.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `app` | `ExpressApp` | the express app to add the middleware to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:96](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L96)
|
||||
|
||||
___
|
||||
|
||||
### usePreCartCreation
|
||||
|
||||
▸ **usePreCartCreation**(): `any`[]
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L102)
|
||||
|
||||
___
|
||||
|
||||
### validateMiddleware\_
|
||||
|
||||
▸ **validateMiddleware_**(`fn`): `void`
|
||||
|
||||
Validates a middleware function, throws if fn is not of type function.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fn` | `Function` | the middleware function to validate. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/middleware.js:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L28)
|
||||
194
docs/content/references/services/classes/NoteService.md
Normal file
194
docs/content/references/services/classes/NoteService.md
Normal file
@@ -0,0 +1,194 @@
|
||||
# Class: NoteService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`NoteService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new NoteService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L12)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L6)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Creates a note associated with a given author
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateNoteInput` | the note to create |
|
||||
| `config` | `any` | any configurations if needed, including meta data |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the creation result
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L98)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`noteId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a given note
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `noteId` | `any` | id of the note to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:154](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L154)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Note`[]\>
|
||||
|
||||
Fetches all notes related to the given selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `Object` | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
| `config.relations` | `string`[] | Which relations to include in the resulting list of Notes. |
|
||||
| `config.skip` | `number` | How many Notes to skip in the resulting list of Notes. |
|
||||
| `config.take` | `number` | How many Notes to take in the resulting list of Notes. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`[]\>
|
||||
|
||||
notes related to the given search.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:77](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L77)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Note`\>
|
||||
|
||||
Retrieves a specific note.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the note to retrieve. |
|
||||
| `config` | `any` | any options needed to query for the result. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`\>
|
||||
|
||||
which resolves to the requested note.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L51)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`noteId`, `value`): `Promise`<`any`\>
|
||||
|
||||
Updates a given note with a new value
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `noteId` | `any` | the id of the note to update |
|
||||
| `value` | `any` | the new value |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated element
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:131](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L131)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`NoteService`](NoteService.md)
|
||||
|
||||
Sets the service's manager to a given transaction manager
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` | the manager to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`NoteService`](NoteService.md)
|
||||
|
||||
a cloned note service
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/note.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L30)
|
||||
326
docs/content/references/services/classes/NotificationService.md
Normal file
326
docs/content/references/services/classes/NotificationService.md
Normal file
@@ -0,0 +1,326 @@
|
||||
# Class: NotificationService
|
||||
|
||||
Provides layer to manipulate orchestrate notifications.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`NotificationService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new NotificationService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L9)
|
||||
|
||||
## Properties
|
||||
|
||||
### attachmentGenerator\_
|
||||
|
||||
• **attachmentGenerator\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L30)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• **container\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L19)
|
||||
|
||||
___
|
||||
|
||||
### logger\_
|
||||
|
||||
• **logger\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L23)
|
||||
|
||||
___
|
||||
|
||||
### notificationProviderRepository\_
|
||||
|
||||
• **notificationProviderRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L27)
|
||||
|
||||
___
|
||||
|
||||
### subscribers\_
|
||||
|
||||
• **subscribers\_**: `Object`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L29)
|
||||
|
||||
## Methods
|
||||
|
||||
### handleEvent
|
||||
|
||||
▸ **handleEvent**(`eventName`, `data`): `Promise`<`any`\>
|
||||
|
||||
Handles an event by relaying the event data to the subscribing providers.
|
||||
The result of the notification send will be persisted in the database in
|
||||
order to allow for resends. Will log any errors that are encountered.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the event to handle |
|
||||
| `data` | `any` | the data the event was sent with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
- the result of notification subscribed
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:166](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L166)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Notification`[]
|
||||
|
||||
Retrieves a list of notifications.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the params to select the notifications by. |
|
||||
| `config` | `any` | the configuration to apply to the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Notification`[]
|
||||
|
||||
the notifications that satisfy the query.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L84)
|
||||
|
||||
___
|
||||
|
||||
### registerAttachmentGenerator
|
||||
|
||||
▸ **registerAttachmentGenerator**(`service`): `void`
|
||||
|
||||
Registers an attachment generator to the service. The generator can be
|
||||
used to generate on demand invoices or other documents.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `service` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L38)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
Takes a list of notification provider ids and persists them in the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providers` | `string`[] | a list of provider ids |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:68](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L68)
|
||||
|
||||
___
|
||||
|
||||
### resend
|
||||
|
||||
▸ **resend**(`id`, `config?`): `Notification`
|
||||
|
||||
Resends a notification by retrieving a prior notification and calling the
|
||||
underlying provider's resendNotification method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the notification |
|
||||
| `config` | `any` | any configuration that might override the previous send |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Notification`
|
||||
|
||||
the newly created notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:237](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L237)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Notification`
|
||||
|
||||
Retrieves a notification with a given id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the notification |
|
||||
| `config` | `any` | the configuration to apply to the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Notification`
|
||||
|
||||
the notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:101](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L101)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider\_
|
||||
|
||||
▸ **retrieveProvider_**(`id`): `NotificationProvider`
|
||||
|
||||
Finds a provider with a given id. Will throw a NOT_FOUND error if the
|
||||
resolution fails.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the provider |
|
||||
|
||||
#### Returns
|
||||
|
||||
`NotificationProvider`
|
||||
|
||||
the notification provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:147](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L147)
|
||||
|
||||
___
|
||||
|
||||
### send
|
||||
|
||||
▸ **send**(`event`, `eventData`, `providerId`): `Notification`
|
||||
|
||||
Sends a notification, by calling the given provider's sendNotification
|
||||
method. Persists the Notification in the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` | the name of the event |
|
||||
| `eventData` | `any` | the data the event was sent with |
|
||||
| `providerId` | `string` | the provider that should hande the event. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Notification`
|
||||
|
||||
the created notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:195](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L195)
|
||||
|
||||
___
|
||||
|
||||
### subscribe
|
||||
|
||||
▸ **subscribe**(`eventName`, `providerId`): `void`
|
||||
|
||||
Subscribes a given provider to an event.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the event to subscribe to |
|
||||
| `providerId` | `string` | the provider that the event will be sent to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:126](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L126)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`NotificationService`](NotificationService.md)
|
||||
|
||||
Sets the service's manager to a given transaction manager.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` | the manager to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`NotificationService`](NotificationService.md)
|
||||
|
||||
a cloned notification service
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/notification.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L47)
|
||||
227
docs/content/references/services/classes/OauthService.md
Normal file
227
docs/content/references/services/classes/OauthService.md
Normal file
@@ -0,0 +1,227 @@
|
||||
# Class: OauthService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`OauthService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OauthService**(`cradle`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cradle` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
OauthService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L10)
|
||||
|
||||
## Properties
|
||||
|
||||
### container\_
|
||||
|
||||
• **container\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• **eventBus\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:17](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L17)
|
||||
|
||||
___
|
||||
|
||||
### manager
|
||||
|
||||
• **manager**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L14)
|
||||
|
||||
___
|
||||
|
||||
### oauthRepository\_
|
||||
|
||||
• **oauthRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L16)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `TOKEN_GENERATED` | `string` |
|
||||
| `TOKEN_REFRESHED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L32)
|
||||
|
||||
___
|
||||
|
||||
### generateToken
|
||||
|
||||
▸ **generateToken**(`appName`, `code`, `state`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `any` |
|
||||
| `code` | `any` |
|
||||
| `state` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:66](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L66)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L27)
|
||||
|
||||
___
|
||||
|
||||
### refreshToken
|
||||
|
||||
▸ **refreshToken**(`appName`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:96](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L96)
|
||||
|
||||
___
|
||||
|
||||
### registerOauthApp
|
||||
|
||||
▸ **registerOauthApp**(`appDetails`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appDetails` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L56)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByName
|
||||
|
||||
▸ **retrieveByName**(`appName`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L20)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `update`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `update` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/oauth.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L45)
|
||||
759
docs/content/references/services/classes/OrderService.md
Normal file
759
docs/content/references/services/classes/OrderService.md
Normal file
@@ -0,0 +1,759 @@
|
||||
# Class: OrderService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`OrderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OrderService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L25)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `COMPLETED` | `string` |
|
||||
| `FULFILLMENT_CANCELED` | `string` |
|
||||
| `FULFILLMENT_CREATED` | `string` |
|
||||
| `GIFT_CARD_CREATED` | `string` |
|
||||
| `ITEMS_RETURNED` | `string` |
|
||||
| `PAYMENT_CAPTURED` | `string` |
|
||||
| `PAYMENT_CAPTURE_FAILED` | `string` |
|
||||
| `PLACED` | `string` |
|
||||
| `REFUND_CREATED` | `string` |
|
||||
| `REFUND_FAILED` | `string` |
|
||||
| `RETURN_ACTION_REQUIRED` | `string` |
|
||||
| `RETURN_REQUESTED` | `string` |
|
||||
| `SHIPMENT_CREATED` | `string` |
|
||||
| `SWAP_CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L6)
|
||||
|
||||
## Methods
|
||||
|
||||
### addShippingMethod
|
||||
|
||||
▸ **addShippingMethod**(`orderId`, `optionId`, `data`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderId` | `any` |
|
||||
| `optionId` | `any` |
|
||||
| `data` | `any` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:806](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L806)
|
||||
|
||||
___
|
||||
|
||||
### archive
|
||||
|
||||
▸ **archive**(`orderId`): `Promise`<`any`\>
|
||||
|
||||
Archives an order. It only alloved, if the order has been fulfilled
|
||||
and payment has been captured.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the order to archive |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1301](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1301)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`orderId`): `Promise`<`any`\>
|
||||
|
||||
Cancels an order.
|
||||
Throws if fulfillment process has been initiated.
|
||||
Throws if payment process has been initiated.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of order to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:952](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L952)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\>
|
||||
|
||||
Cancels a fulfillment (if related to an order)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `string` | the ID of the fulfillment to cancel |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
updated order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1242](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1242)
|
||||
|
||||
___
|
||||
|
||||
### capturePayment
|
||||
|
||||
▸ **capturePayment**(`orderId`): `Promise`<`any`\>
|
||||
|
||||
Captures payment for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of order to capture payment for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1021](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1021)
|
||||
|
||||
___
|
||||
|
||||
### completeOrder
|
||||
|
||||
▸ **completeOrder**(`orderId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of the order to complete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:429](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L429)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`any`\>
|
||||
|
||||
Creates an order
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `any` | the data to create an order |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:723](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L723)
|
||||
|
||||
___
|
||||
|
||||
### createFromCart
|
||||
|
||||
▸ **createFromCart**(`cartId`): `Promise`<`any`\>
|
||||
|
||||
Creates an order from a cart
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartId` | `string` | id of the cart to create an order from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:465](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L465)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`orderId`, `itemsToFulfill`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Creates fulfillments for an order.
|
||||
In a situation where the order has more than one shipping method,
|
||||
we need to partition the order items, such that they can be sent
|
||||
to their respective fulfillment provider.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of order to cancel. |
|
||||
| `itemsToFulfill` | `any` | items to fulfil. |
|
||||
| `config` | `any` | the config to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1121)
|
||||
|
||||
___
|
||||
|
||||
### createRefund
|
||||
|
||||
▸ **createRefund**(`orderId`, `refundAmount`, `reason`, `note`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Refunds a given amount back to the customer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of the order to refund. |
|
||||
| `refundAmount` | `float` | the amount to refund. |
|
||||
| `reason` | `string` | the reason to refund. |
|
||||
| `note` | `undefined` \| `string` | note for refund. |
|
||||
| `config` | `any` | the config for refund. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the refund operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1328](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1328)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`orderId`, `fulfillmentId`, `trackingLinks`, `config?`): `order`
|
||||
|
||||
Adds a shipment to the order to indicate that an order has left the
|
||||
warehouse. Will ask the fulfillment provider for any documents that may
|
||||
have been created in regards to the shipment.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the id of the order that has been shipped |
|
||||
| `fulfillmentId` | `string` | the fulfillment that has now been shipped |
|
||||
| `trackingLinks` | `undefined` \| `TrackingLink`[] | array of tracking numebers associated with the shipment |
|
||||
| `config` | `any` | the config of the order that has been shipped |
|
||||
|
||||
#### Returns
|
||||
|
||||
`order`
|
||||
|
||||
the resulting order following the update.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:643](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L643)
|
||||
|
||||
___
|
||||
|
||||
### decorateTotals\_
|
||||
|
||||
▸ **decorateTotals_**(`order`, `totalsFields?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `any` | `undefined` |
|
||||
| `totalsFields` | `any`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1377](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1377)
|
||||
|
||||
___
|
||||
|
||||
### deleteMetadata
|
||||
|
||||
▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\>
|
||||
|
||||
Dedicated method to delete metadata for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the order to delete metadata from. |
|
||||
| `key` | `string` | key for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1550](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1550)
|
||||
|
||||
___
|
||||
|
||||
### existsByCartId
|
||||
|
||||
▸ **existsByCartId**(`cartId`): `Promise`<`Order`\>
|
||||
|
||||
Checks the existence of an order by cart id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartId` | `string` | cart id to find order |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:417](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L417)
|
||||
|
||||
___
|
||||
|
||||
### getFulfillmentItems\_
|
||||
|
||||
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Retrieves the order line items, given an array of items.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get line items from |
|
||||
| `items` | `Object` | the items to get |
|
||||
| `items.item_id` | `string` | - |
|
||||
| `items.quantity` | `number` | - |
|
||||
| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the line items generated by the transformer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1284](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1284)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:148](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L148)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | `undefined` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.order` | `Object` | `undefined` |
|
||||
| `config.order.created_at` | `string` | `"DESC"` |
|
||||
| `config.skip` | `number` | `0` |
|
||||
| `config.take` | `number` | `50` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:173](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L173)
|
||||
|
||||
___
|
||||
|
||||
### registerReturnReceived
|
||||
|
||||
▸ **registerReturnReceived**(`orderId`, `receivedReturn`, `customRefundAmount`): `Promise`<`any`\>
|
||||
|
||||
Handles receiving a return. This will create a
|
||||
refund to the customer. If the returned items don't match the requested
|
||||
items the return status will be updated to requires_action. This behaviour
|
||||
is useful in sitautions where a custom refund amount is requested, but the
|
||||
retuned items are not matching the requested items. Setting the
|
||||
allowMismatch argument to true, will process the return, ignoring any
|
||||
mismatches.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the order to return. |
|
||||
| `receivedReturn` | `any` | the received return |
|
||||
| `customRefundAmount` | `float` | the custom refund amount return |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1473](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1473)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`orderId`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | id of order to retrieve |
|
||||
| `config` | `any` | config of order to retrieve |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:305](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L305)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCartId
|
||||
|
||||
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets an order by cart id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartId` | `string` | cart id to find order |
|
||||
| `config` | `any` | the config to be used to find order |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L343)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByExternalId
|
||||
|
||||
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `externalId` | `string` | id of order to retrieve |
|
||||
| `config` | `any` | query config to get order by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:380](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L380)
|
||||
|
||||
___
|
||||
|
||||
### transformQueryForTotals\_
|
||||
|
||||
▸ **transformQueryForTotals_**(`config`): { `relations`: `any` ; `select`: `any` ; `totalsToSelect`: `never`[] = [] } \| { `relations`: `any` ; `select`: `any`[] = toSelect; `totalsToSelect`: `any` }
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `config` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
{ `relations`: `any` ; `select`: `any` ; `totalsToSelect`: `never`[] = [] } \| { `relations`: `any` ; `select`: `any`[] = toSelect; `totalsToSelect`: `any` }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:234](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L234)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`orderId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates an order. Metadata updates should
|
||||
use dedicated method, e.g. `setMetadata` etc. The function
|
||||
will throw errors if metadata updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderId` | `string` | the id of the order. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:864](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L864)
|
||||
|
||||
___
|
||||
|
||||
### updateBillingAddress\_
|
||||
|
||||
▸ **updateBillingAddress_**(`order`, `address`): `Promise`<`any`\>
|
||||
|
||||
Updates the order's billing address.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `any` | the order to update |
|
||||
| `address` | `any` | the value to set the billing address to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:744](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L744)
|
||||
|
||||
___
|
||||
|
||||
### updateShippingAddress\_
|
||||
|
||||
▸ **updateShippingAddress_**(`order`, `address`): `Promise`<`any`\>
|
||||
|
||||
Updates the order's shipping address.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `any` | the order to update |
|
||||
| `address` | `any` | the value to set the shipping address to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:779](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L779)
|
||||
|
||||
___
|
||||
|
||||
### validateFulfillmentLineItem\_
|
||||
|
||||
▸ **validateFulfillmentLineItem_**(`item`, `quantity`): `LineItem`
|
||||
|
||||
Checks that a given quantity of a line item can be fulfilled. Fails if the
|
||||
fulfillable quantity is lower than the requested fulfillment quantity.
|
||||
Fulfillable quantity is calculated by subtracting the already fulfilled
|
||||
quantity from the quantity that was originally purchased.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `item` | `LineItem` | the line item to check has sufficient fulfillable quantity. |
|
||||
| `quantity` | `number` | the quantity that is requested to be fulfilled. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineItem`
|
||||
|
||||
a line item that has the requested fulfillment quantity
|
||||
set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:1091](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1091)
|
||||
|
||||
___
|
||||
|
||||
### validateId\_
|
||||
|
||||
▸ **validateId_**(`rawId`): `string`
|
||||
|
||||
Used to validate order ids. Throws an error if the cast fails
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `rawId` | `string` | the raw order id to validate. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the validated id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:139](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L139)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`OrderService`](OrderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `manager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`OrderService`](OrderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/order.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L102)
|
||||
@@ -0,0 +1,497 @@
|
||||
# Class: PaymentProviderService
|
||||
|
||||
Helps retrive payment providers
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`PaymentProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PaymentProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L8)
|
||||
|
||||
## Properties
|
||||
|
||||
### manager\_
|
||||
|
||||
• **manager\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L14)
|
||||
|
||||
___
|
||||
|
||||
### paymentRepository\_
|
||||
|
||||
• **paymentRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:18](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L18)
|
||||
|
||||
___
|
||||
|
||||
### paymentSessionRepository\_
|
||||
|
||||
• **paymentSessionRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L16)
|
||||
|
||||
___
|
||||
|
||||
### refundRepository\_
|
||||
|
||||
• **refundRepository\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L20)
|
||||
|
||||
## Methods
|
||||
|
||||
### authorizePayment
|
||||
|
||||
▸ **authorizePayment**(`paymentSession`, `context`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentSession` | `any` |
|
||||
| `context` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:283](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L283)
|
||||
|
||||
___
|
||||
|
||||
### cancelPayment
|
||||
|
||||
▸ **cancelPayment**(`paymentObj`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentObj` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:324](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L324)
|
||||
|
||||
___
|
||||
|
||||
### capturePayment
|
||||
|
||||
▸ **capturePayment**(`paymentObj`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentObj` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L343)
|
||||
|
||||
___
|
||||
|
||||
### createPayment
|
||||
|
||||
▸ **createPayment**(`cart`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cart` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:246](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L246)
|
||||
|
||||
___
|
||||
|
||||
### createSession
|
||||
|
||||
▸ **createSession**(`providerId`, `cart`): `Promise`<`any`\>
|
||||
|
||||
Creates a payment session with the given provider.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the id of the provider to create payment with |
|
||||
| `cart` | `Cart` | a cart object used to calculate the amount, etc. from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the payment session
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L121)
|
||||
|
||||
___
|
||||
|
||||
### deleteSession
|
||||
|
||||
▸ **deleteSession**(`paymentSession`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentSession` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:202](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L202)
|
||||
|
||||
___
|
||||
|
||||
### getStatus
|
||||
|
||||
▸ **getStatus**(`payment`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `payment` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:338](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L338)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`any`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L47)
|
||||
|
||||
___
|
||||
|
||||
### listPayments
|
||||
|
||||
▸ **listPayments**(`selector`, `config?`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | `undefined` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.order` | `Object` | `undefined` |
|
||||
| `config.order.created_at` | `string` | `"DESC"` |
|
||||
| `config.skip` | `number` | `0` |
|
||||
| `config.take` | `number` | `50` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L80)
|
||||
|
||||
___
|
||||
|
||||
### refreshSession
|
||||
|
||||
▸ **refreshSession**(`paymentSession`, `cart`): `Promise`<`any`\>
|
||||
|
||||
Refreshes a payment session with the given provider.
|
||||
This means, that we delete the current one and create a new.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentSession` | `PaymentSession` | the payment session object to update |
|
||||
| `cart` | `Cart` | a cart object used to calculate the amount, etc. from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the payment session
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L152)
|
||||
|
||||
___
|
||||
|
||||
### refundPayment
|
||||
|
||||
▸ **refundPayment**(`payObjs`, `amount`, `reason`, `note`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `payObjs` | `any` |
|
||||
| `amount` | `any` |
|
||||
| `reason` | `any` |
|
||||
| `note` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:358](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L358)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L35)
|
||||
|
||||
___
|
||||
|
||||
### retrievePayment
|
||||
|
||||
▸ **retrievePayment**(`id`, `relations?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `any` | `undefined` |
|
||||
| `relations` | `any`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:54](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L54)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**(`providerId`): `PaymentService`
|
||||
|
||||
Finds a provider given an id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the id of the provider to get |
|
||||
|
||||
#### Returns
|
||||
|
||||
`PaymentService`
|
||||
|
||||
the payment provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:228](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L228)
|
||||
|
||||
___
|
||||
|
||||
### retrieveRefund
|
||||
|
||||
▸ **retrieveRefund**(`id`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:422](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L422)
|
||||
|
||||
___
|
||||
|
||||
### retrieveSession
|
||||
|
||||
▸ **retrieveSession**(`id`, `relations?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `any` | `undefined` |
|
||||
| `relations` | `any`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L89)
|
||||
|
||||
___
|
||||
|
||||
### updatePayment
|
||||
|
||||
▸ **updatePayment**(`paymentId`, `update`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentId` | `any` |
|
||||
| `update` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:266](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L266)
|
||||
|
||||
___
|
||||
|
||||
### updateSession
|
||||
|
||||
▸ **updateSession**(`paymentSession`, `cart`): `Promise`<`any`\>
|
||||
|
||||
Updates an existing payment session.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentSession` | `PaymentSession` | the payment session object to update |
|
||||
| `cart` | `Cart` | the cart object to update for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the updated payment session
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L188)
|
||||
|
||||
___
|
||||
|
||||
### updateSessionData
|
||||
|
||||
▸ **updateSessionData**(`paySession`, `update`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paySession` | `any` |
|
||||
| `update` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:308](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L308)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `manager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/payment-provider.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L23)
|
||||
@@ -0,0 +1,264 @@
|
||||
# Class: ProductCollectionService
|
||||
|
||||
Provides layer to manipulate product collections.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ProductCollectionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductCollectionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L11)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProducts
|
||||
|
||||
▸ **addProducts**(`collectionId`, `productIds`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `collectionId` | `any` |
|
||||
| `productIds` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:170](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L170)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`collection`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Creates a product collection
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collection` | `any` | the collection to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
created collection
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L104)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`collectionId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a product collection idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | id of collection to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L152)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Lists product collections
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:206](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L206)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Lists product collections and add count.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:221](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L221)
|
||||
|
||||
___
|
||||
|
||||
### removeProducts
|
||||
|
||||
▸ **removeProducts**(`collectionId`, `productIds`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `collectionId` | `any` |
|
||||
| `productIds` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L188)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`collectionId`, `config?`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Retrieves a product collection by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | the id of the collection to retrieve. |
|
||||
| `config` | `any` | the config of the collection to retrieve. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
the collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L55)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByHandle
|
||||
|
||||
▸ **retrieveByHandle**(`collectionHandle`, `config?`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Retrieves a product collection by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionHandle` | `string` | the handle of the collection to retrieve. |
|
||||
| `config` | `any` | query config for request |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
the collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:81](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L81)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`collectionId`, `update`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Updates a product collection
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | id of collection to update |
|
||||
| `update` | `any` | update object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
update collection
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:125](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L125)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ProductCollectionService`](ProductCollectionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductCollectionService`](ProductCollectionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-collection.js:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L32)
|
||||
662
docs/content/references/services/classes/ProductService.md
Normal file
662
docs/content/references/services/classes/ProductService.md
Normal file
@@ -0,0 +1,662 @@
|
||||
# Class: ProductService
|
||||
|
||||
Provides layer to manipulate products.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ProductService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L19)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:13](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L13)
|
||||
|
||||
___
|
||||
|
||||
### IndexName
|
||||
|
||||
▪ `Static` **IndexName**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L12)
|
||||
|
||||
## Methods
|
||||
|
||||
### addOption
|
||||
|
||||
▸ **addOption**(`productId`, `optionTitle`): `Promise`<`any`\>
|
||||
|
||||
Adds an option to a product. Options can, for example, be "Size", "Color",
|
||||
etc. Will update all the products variants with a dummy value for the newly
|
||||
created option. The same option cannot be added more than once.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product to apply the new option to |
|
||||
| `optionTitle` | `string` | the display title of the option, e.g. "Size" |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the model update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:707](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L707)
|
||||
|
||||
___
|
||||
|
||||
### count
|
||||
|
||||
▸ **count**(`selector?`): `Promise`<`any`\>
|
||||
|
||||
Return the total number of documents in database
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the selector to choose products by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the count operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:223](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L223)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`productObject`): `Promise`<`any`\>
|
||||
|
||||
Creates a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productObject` | `any` | the product to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:483](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L483)
|
||||
|
||||
___
|
||||
|
||||
### decorate
|
||||
|
||||
▸ **decorate**(`productId`, `fields?`, `expandFields?`, `config?`): `Product`
|
||||
|
||||
Decorates a product with product variants.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `productId` | `string` | `undefined` | the productId to decorate. |
|
||||
| `fields` | `string`[] | `[]` | the fields to include. |
|
||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
||||
| `config` | `any` | `{}` | retrieve config for price calculation. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Product`
|
||||
|
||||
return the decorated product.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:945](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L945)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`productId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a product from a given product id. The product's associated
|
||||
variants will also be deleted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:673](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L673)
|
||||
|
||||
___
|
||||
|
||||
### deleteOption
|
||||
|
||||
▸ **deleteOption**(`productId`, `optionId`): `Promise`<`any`\>
|
||||
|
||||
Delete an option from a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product to delete an option from |
|
||||
| `optionId` | `string` | the option to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the updated product
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:881](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L881)
|
||||
|
||||
___
|
||||
|
||||
### getFreeTextQueryBuilder\_
|
||||
|
||||
▸ **getFreeTextQueryBuilder_**(`productRepo`, `query`, `q`): `QueryBuilder`<`Product`\>
|
||||
|
||||
Creates a QueryBuilder that can fetch products based on free text.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productRepo` | `ProductRepository` | an instance of a ProductRepositry |
|
||||
| `query` | `FindOptions`<`Product`\> | the query to get products by |
|
||||
| `q` | `string` | the text to perform free text search from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`QueryBuilder`<`Product`\>
|
||||
|
||||
a query builder that can fetch products
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:1014](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L1014)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`Product`[]\>
|
||||
|
||||
Lists products based on the provided parameters.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | an object that defines rules to filter products by |
|
||||
| `config` | `any` | object that defines the scope for what should be returned |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:109](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L109)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Product`[], `number`]\>
|
||||
|
||||
Lists products based on the provided parameters and includes the count of
|
||||
products that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | an object that defines rules to filter products by |
|
||||
| `config` | `any` | object that defines the scope for what should be returned |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Product`[], `number`]\>
|
||||
|
||||
an array containing the products as
|
||||
the first element and the total count of products that matches the query
|
||||
as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:164](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L164)
|
||||
|
||||
___
|
||||
|
||||
### listTagsByUsage
|
||||
|
||||
▸ **listTagsByUsage**(`count?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `count` | `number` | `10` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:412](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L412)
|
||||
|
||||
___
|
||||
|
||||
### listTypes
|
||||
|
||||
▸ **listTypes**(): `Promise`<`any`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:404](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L404)
|
||||
|
||||
___
|
||||
|
||||
### prepareListQuery\_
|
||||
|
||||
▸ **prepareListQuery_**(`selector`, `config`): `any`
|
||||
|
||||
Creates a query object to be used for list queries.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the selector to create the query from |
|
||||
| `config` | `any` | the config to use for the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
an object containing the query, relations and free-text
|
||||
search param.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:980](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L980)
|
||||
|
||||
___
|
||||
|
||||
### reorderOptions
|
||||
|
||||
▸ **reorderOptions**(`productId`, `optionOrder`): `Promise`<`any`\>
|
||||
|
||||
Changes the order of a product's options. Will throw if the length of
|
||||
optionOrder and the length of the product's options are different. Will
|
||||
throw optionOrder contains an id not associated with the product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product whose options we are reordering |
|
||||
| `optionOrder` | `string`[] | the ids of the product's options in the new order |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:790](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L790)
|
||||
|
||||
___
|
||||
|
||||
### reorderVariants
|
||||
|
||||
▸ **reorderVariants**(`productId`, `variantOrder`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productId` | `any` |
|
||||
| `variantOrder` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:746](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L746)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`productId`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | id of the product to get. |
|
||||
| `config` | `any` | object that defines what should be included in the query response |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:239](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L239)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByExternalId
|
||||
|
||||
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by external id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `externalId` | `string` | handle of the product to get. |
|
||||
| `config` | `any` | details about what to get from the product |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:342](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L342)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByHandle
|
||||
|
||||
▸ **retrieveByHandle**(`productHandle`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by handle.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productHandle` | `string` | handle of the product to get. |
|
||||
| `config` | `any` | details about what to get from the product |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:291](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L291)
|
||||
|
||||
___
|
||||
|
||||
### retrieveVariants
|
||||
|
||||
▸ **retrieveVariants**(`productId`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Gets all variants belonging to a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product to get variants from. |
|
||||
| `config` | `FindConfig`<`Product`\> | The config to select and configure relations etc... |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
an array of variants
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:392](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L392)
|
||||
|
||||
___
|
||||
|
||||
### setAdditionalPrices
|
||||
|
||||
▸ **setAdditionalPrices**(`products`, `currency_code`, `region_id`, `cart_id`, `customer_id`, `include_discount_prices?`): `Promise`<`Product`[]\>
|
||||
|
||||
Set additional prices on a list of products.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `products` | `any` | `undefined` | list of products on which to set additional prices |
|
||||
| `currency_code` | `string` | `undefined` | currency code to fetch prices for |
|
||||
| `region_id` | `string` | `undefined` | region to fetch prices for |
|
||||
| `cart_id` | `string` | `undefined` | string of cart to use as a basis for getting currency and region |
|
||||
| `customer_id` | `string` | `undefined` | id of potentially logged in customer, used to get prices valid for their customer groups |
|
||||
| `include_discount_prices` | `boolean` | `false` | indication wether or not to include sales prices in result |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`[]\>
|
||||
|
||||
A list of products with variants decorated with "additional_prices"
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:1055](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L1055)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`productId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a product. Product variant updates should use dedicated methods,
|
||||
e.g. `addVariant`, etc. The function will throw errors if metadata or
|
||||
product variant updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:573](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L573)
|
||||
|
||||
___
|
||||
|
||||
### updateOption
|
||||
|
||||
▸ **updateOption**(`productId`, `optionId`, `data`): `Promise`<`any`\>
|
||||
|
||||
Updates a product's option. Throws if the call tries to update an option
|
||||
not associated with the product. Throws if the updated title already exists.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product whose option we are updating |
|
||||
| `optionId` | `string` | the id of the option we are updating |
|
||||
| `data` | `any` | the data to update the option with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the updated product
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:831](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L831)
|
||||
|
||||
___
|
||||
|
||||
### upsertImages\_
|
||||
|
||||
▸ **upsertImages_**(`images`): `Promise`<`any`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `images` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:542](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L542)
|
||||
|
||||
___
|
||||
|
||||
### upsertProductTags\_
|
||||
|
||||
▸ **upsertProductTags_**(`tags`): `Promise`<`any`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `tags` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:455](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L455)
|
||||
|
||||
___
|
||||
|
||||
### upsertProductType\_
|
||||
|
||||
▸ **upsertProductType_**(`type`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `type` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L430)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ProductService`](ProductService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product.js:76](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L76)
|
||||
145
docs/content/references/services/classes/ProductTypeService.md
Normal file
145
docs/content/references/services/classes/ProductTypeService.md
Normal file
@@ -0,0 +1,145 @@
|
||||
# Class: ProductTypeService
|
||||
|
||||
Provides layer to manipulate products.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ProductTypeService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductTypeService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L16)
|
||||
|
||||
## Properties
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### typeRepository\_
|
||||
|
||||
• `Private` **typeRepository\_**: typeof `ProductTypeRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L15)
|
||||
|
||||
## Methods
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`ProductType`[]\>
|
||||
|
||||
Lists product types
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductTypeProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductType`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:72](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductType`[], `number`]\>
|
||||
|
||||
Lists product tags and adds count.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductTypeProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductType`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L88)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`ProductType`\>
|
||||
|
||||
Gets a product by id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the product to get. |
|
||||
| `config` | `FindConfig`<`ProductType`\> | object that defines what should be included in the query response |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductType`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-type.ts:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L23)
|
||||
@@ -0,0 +1,631 @@
|
||||
# Class: ProductVariantService
|
||||
|
||||
Provides layer to manipulate product variants.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ProductVariantService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductVariantService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L52)
|
||||
|
||||
## Properties
|
||||
|
||||
### cartRepository\_
|
||||
|
||||
• `Private` **cartRepository\_**: typeof `CartRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:50](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### moneyAmountRepository\_
|
||||
|
||||
• `Private` **moneyAmountRepository\_**: typeof `MoneyAmountRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### priceSelectionStrategy\_
|
||||
|
||||
• `Private` **priceSelectionStrategy\_**: `IPriceSelectionStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### productOptionValueRepository\_
|
||||
|
||||
• `Private` **productOptionValueRepository\_**: typeof `ProductOptionValueRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### productRepository\_
|
||||
|
||||
• `Private` **productRepository\_**: typeof `ProductRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### productVariantRepository\_
|
||||
|
||||
• `Private` **productVariantRepository\_**: typeof `ProductVariantRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Private` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L36)
|
||||
|
||||
## Methods
|
||||
|
||||
### addOptionValue
|
||||
|
||||
▸ **addOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
||||
|
||||
Adds option value to a varaint.
|
||||
Fails when product with variant does not exists or
|
||||
if that product does not have an option with the given
|
||||
option id. Fails if given variant is not found.
|
||||
Option value must be of type string or number.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
| `optionValue` | `string` | option value to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductOptionValue`\>
|
||||
|
||||
the result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:553](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L553)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`productOrProductId`, `variant`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Creates an unpublished product variant. Will validate against parent product
|
||||
to ensure that the variant can in fact be created.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productOrProductId` | `string` \| `Product` | the product the variant will be added to |
|
||||
| `variant` | `CreateProductVariantInput` | the variant to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:207](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L207)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`variantId`): `Promise`<`void`\>
|
||||
|
||||
Deletes variant.
|
||||
Will never fail due to delete being idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:746](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L746)
|
||||
|
||||
___
|
||||
|
||||
### deleteOptionValue
|
||||
|
||||
▸ **deleteOptionValue**(`variantId`, `optionId`): `Promise`<`void`\>
|
||||
|
||||
Deletes option value from given variant.
|
||||
Will never fail due to delete being idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:580](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L580)
|
||||
|
||||
___
|
||||
|
||||
### getFreeTextQueryBuilder\_
|
||||
|
||||
▸ **getFreeTextQueryBuilder_**(`variantRepo`, `query`, `q?`): `SelectQueryBuilder`<`ProductVariant`\>
|
||||
|
||||
Lists variants based on the provided parameters and includes the count of
|
||||
variants that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantRepo` | `ProductVariantRepository` | the variant repository |
|
||||
| `query` | `FindWithRelationsOptions` | object that defines the scope for what should be returned |
|
||||
| `q?` | `string` | free text query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`SelectQueryBuilder`<`ProductVariant`\>
|
||||
|
||||
an array containing the products as the first element and the total
|
||||
count of products that matches the query as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:852](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L852)
|
||||
|
||||
___
|
||||
|
||||
### getRegionPrice
|
||||
|
||||
▸ **getRegionPrice**(`variantId`, `context`): `Promise`<`number`\>
|
||||
|
||||
Gets the price specific to a region. If no region specific money amount
|
||||
exists the function will try to use a currency price. If no default
|
||||
currency price exists the function will throw an error.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to get price from |
|
||||
| `context` | `GetRegionPriceContext` | context for getting region price |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the price specific to the region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:428](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L428)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:677](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L677)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:607](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L607)
|
||||
|
||||
___
|
||||
|
||||
### prepareListQuery\_
|
||||
|
||||
▸ **prepareListQuery_**(`selector`, `config`): `Object`
|
||||
|
||||
Creates a query object to be used for list queries.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductVariantProps` | the selector to create the query from |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> | the config to use for the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
an object containing the query, relations and free-text
|
||||
search param.
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `q?` | `string` |
|
||||
| `query` | `FindWithRelationsOptions` |
|
||||
| `relations` | `string`[] |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:813](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L813)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`variantId`, `config?`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Gets a product variant by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the product to get. |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
the product document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:117](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L117)
|
||||
|
||||
___
|
||||
|
||||
### retrieveBySKU
|
||||
|
||||
▸ **retrieveBySKU**(`sku`, `config?`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Gets a product variant by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `sku` | `string` | The unique stock keeping unit used to identify the product variant. |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
the product document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:162](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L162)
|
||||
|
||||
___
|
||||
|
||||
### setAdditionalPrices
|
||||
|
||||
▸ **setAdditionalPrices**(`variant`, `currency_code`, `region_id`, `cart_id`, `customer_id`, `include_discount_prices?`): `Promise`<`ProductVariant` \| `ProductVariant`[]\>
|
||||
|
||||
Set additional prices on a list of variants.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `variant` | `any` | `undefined` | variant on which to set additional prices |
|
||||
| `currency_code` | `any` | `undefined` | currency code to fetch prices for |
|
||||
| `region_id` | `any` | `undefined` | region to fetch prices for |
|
||||
| `cart_id` | `any` | `undefined` | string of cart to use as a basis for getting currency and region |
|
||||
| `customer_id` | `any` | `undefined` | id of potentially logged in customer, used to get prices valid for their customer groups |
|
||||
| `include_discount_prices` | `boolean` | `false` | should result include discount pricing |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant` \| `ProductVariant`[]\>
|
||||
|
||||
A list of variants with variants decorated with "additional_prices"
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:897](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L897)
|
||||
|
||||
___
|
||||
|
||||
### setCurrencyPrice
|
||||
|
||||
▸ **setCurrencyPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||
|
||||
Sets the default price for the given currency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to set prices for |
|
||||
| `price` | `ProductVariantPrice` | the price for the variant |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`MoneyAmount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:494](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L494)
|
||||
|
||||
___
|
||||
|
||||
### setMetadata\_
|
||||
|
||||
▸ **setMetadata_**(`variant`, `metadata`): `Record`<`string`, `unknown`\>
|
||||
|
||||
Dedicated method to set metadata for a variant.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variant` | `ProductVariant` | the variant to set metadata for. |
|
||||
| `metadata` | `object` | the metadata to set |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `unknown`\>
|
||||
|
||||
updated metadata object
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:781](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L781)
|
||||
|
||||
___
|
||||
|
||||
### setRegionPrice
|
||||
|
||||
▸ **setRegionPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||
|
||||
Sets the default price of a specific region
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to update |
|
||||
| `price` | `ProductVariantPrice` | the price for the variant. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`MoneyAmount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:457](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L457)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Updates a variant.
|
||||
Price updates should use dedicated methods.
|
||||
The function will throw, if price updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> | variant or id of a variant. |
|
||||
| `update` | `UpdateProductVariantInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:312](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L312)
|
||||
|
||||
___
|
||||
|
||||
### updateOptionValue
|
||||
|
||||
▸ **updateOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
||||
|
||||
Updates variant's option value.
|
||||
Option value must be of type string or number.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
| `optionValue` | `string` | option value to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductOptionValue`\>
|
||||
|
||||
the result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:515](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L515)
|
||||
|
||||
___
|
||||
|
||||
### updateVariantPrices
|
||||
|
||||
▸ **updateVariantPrices**(`variantId`, `prices`): `Promise`<`void`\>
|
||||
|
||||
Updates a variant's prices.
|
||||
Deletes any prices that are not in the update object, and is not associated with a price list.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of variant variant |
|
||||
| `prices` | `ProductVariantPrice`[] | the update prices |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:390](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L390)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/product-variant.ts:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L89)
|
||||
@@ -0,0 +1,79 @@
|
||||
# Class: QueryBuilderService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`QueryBuilderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new QueryBuilderService**()
|
||||
|
||||
#### Inherited from
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
## Methods
|
||||
|
||||
### buildFilterQuery
|
||||
|
||||
▸ **buildFilterQuery**(`filters`): `undefined` \| {}
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `filters` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`undefined` \| {}
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/query-builder.js:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L25)
|
||||
|
||||
___
|
||||
|
||||
### buildQuery
|
||||
|
||||
▸ **buildQuery**(`params`, `properties`): `Object`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `params` | `any` |
|
||||
| `properties` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/query-builder.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L5)
|
||||
|
||||
___
|
||||
|
||||
### buildTextSearchQuery
|
||||
|
||||
▸ **buildTextSearchQuery**(`search`, `searchProperties`): `undefined` \| { `$or`: `any` = searchQuery }
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `search` | `any` |
|
||||
| `searchProperties` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`undefined` \| { `$or`: `any` = searchQuery }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/query-builder.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L39)
|
||||
457
docs/content/references/services/classes/RegionService.md
Normal file
457
docs/content/references/services/classes/RegionService.md
Normal file
@@ -0,0 +1,457 @@
|
||||
# Class: RegionService
|
||||
|
||||
Provides layer to manipulate regions.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`RegionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new RegionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L16)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L10)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCountry
|
||||
|
||||
▸ **addCountry**(`regionId`, `code`): `Promise`<`any`\>
|
||||
|
||||
Adds a country to the region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add a country to |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L460)
|
||||
|
||||
___
|
||||
|
||||
### addFulfillmentProvider
|
||||
|
||||
▸ **addFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||
|
||||
Adds a fulfillment provider that is available in the region. Fails if the
|
||||
provider doesn't exist.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add the provider to |
|
||||
| `providerId` | `string` | the provider to add to the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:580](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L580)
|
||||
|
||||
___
|
||||
|
||||
### addPaymentProvider
|
||||
|
||||
▸ **addPaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||
|
||||
Adds a payment provider that is available in the region. Fails if the
|
||||
provider doesn't exist.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add the provider to |
|
||||
| `providerId` | `string` | the provider to add to the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:533](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L533)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`regionObject`): `Region`
|
||||
|
||||
Creates a region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionObject` | `Region` | the unvalidated region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Region`
|
||||
|
||||
the newly created region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:95](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L95)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`regionId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L430)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
Lists all regions based on a query
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | query object for find |
|
||||
| `config` | `any` | configuration settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:418](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L418)
|
||||
|
||||
___
|
||||
|
||||
### removeCountry
|
||||
|
||||
▸ **removeCountry**(`regionId`, `code`): `Promise`<`any`\>
|
||||
|
||||
Removes a country from a Region
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove from |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:497](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L497)
|
||||
|
||||
___
|
||||
|
||||
### removeFulfillmentProvider
|
||||
|
||||
▸ **removeFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||
|
||||
Removes a fulfillment provider from a region. Is idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove the provider from |
|
||||
| `providerId` | `string` | the provider to remove from the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:658](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L658)
|
||||
|
||||
___
|
||||
|
||||
### removePaymentProvider
|
||||
|
||||
▸ **removePaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||
|
||||
Removes a payment provider from a region. Is idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove the provider from |
|
||||
| `providerId` | `string` | the provider to remove from the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:624](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L624)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`regionId`, `config?`): `Region`
|
||||
|
||||
Retrieves a region by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the id of the region to retrieve |
|
||||
| `config` | `any` | configuration settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Region`
|
||||
|
||||
the region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:394](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L394)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCountryCode
|
||||
|
||||
▸ **retrieveByCountryCode**(`code`, `config?`): `Promise`<`Region`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `any` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:360](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L360)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`regionId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a region
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to update |
|
||||
| `update` | `any` | the data to update the region with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:153](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L153)
|
||||
|
||||
___
|
||||
|
||||
### validateCountry\_
|
||||
|
||||
▸ **validateCountry_**(`code`, `regionId`): `Promise`<`any`\>
|
||||
|
||||
Validates a country code. Will normalize the code before checking for
|
||||
existence.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code |
|
||||
| `regionId` | `string` | the id of the current region to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:323](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L323)
|
||||
|
||||
___
|
||||
|
||||
### validateCurrency\_
|
||||
|
||||
▸ **validateCurrency_**(`currencyCode`): `Promise`<`void`\>
|
||||
|
||||
Validates a currency code. Will throw if the currency code doesn't exist.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `currencyCode` | `string` | an ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:302](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L302)
|
||||
|
||||
___
|
||||
|
||||
### validateFields\_
|
||||
|
||||
▸ **validateFields_**(`region`, `id?`): `any`
|
||||
|
||||
Validates fields for creation and updates. If the region already exisits
|
||||
the id can be passed to check that country updates are allowed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `region` | `any` | `undefined` | the region data to validate |
|
||||
| `id` | ``null`` \| `string` | `undefined` | optional id of the region to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
the validated region data
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:213](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L213)
|
||||
|
||||
___
|
||||
|
||||
### validateTaxRate\_
|
||||
|
||||
▸ **validateTaxRate_**(`taxRate`): `void`
|
||||
|
||||
Validates a tax rate. Will throw if the tax rate is not between 0 and 1.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `taxRate` | `number` | a number representing the tax rate of the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:289](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L289)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`RegionService`](RegionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/region.js:65](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L65)
|
||||
156
docs/content/references/services/classes/ReturnReasonService.md
Normal file
156
docs/content/references/services/classes/ReturnReasonService.md
Normal file
@@ -0,0 +1,156 @@
|
||||
# Class: ReturnReasonService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ReturnReasonService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ReturnReasonService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L30)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`returnReasonId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnReasonId` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L114)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:82](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L82)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of order to retrieve |
|
||||
| `config` | `any` | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:97](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L97)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L52)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`manager`): [`ReturnReasonService`](ReturnReasonService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `manager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ReturnReasonService`](ReturnReasonService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return-reason.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L15)
|
||||
355
docs/content/references/services/classes/ReturnService.md
Normal file
355
docs/content/references/services/classes/ReturnService.md
Normal file
@@ -0,0 +1,355 @@
|
||||
# Class: ReturnService
|
||||
|
||||
Handles Returns
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ReturnService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ReturnService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L9)
|
||||
|
||||
## Properties
|
||||
|
||||
### inventoryService\_
|
||||
|
||||
• **inventoryService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L49)
|
||||
|
||||
___
|
||||
|
||||
### returnReasonService\_
|
||||
|
||||
• **returnReasonService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L47)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• **taxProviderService\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L39)
|
||||
|
||||
## Methods
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`returnId`): `Promise`<`Return`\>
|
||||
|
||||
Cancels a return if possible. Returns can be canceled if it has not been received.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnId` | `string` | the id of the return to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the updated Return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:134](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L134)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`Return`\>
|
||||
|
||||
Creates a return request for an order, with given items, and a shipping
|
||||
method. If no refund amount is provided the refund amount is calculated from
|
||||
the return lines and the shipping cost.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `any` | data to use for the return e.g. shipping_method, items or refund_amount |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the created return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:307](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L307)
|
||||
|
||||
___
|
||||
|
||||
### fulfill
|
||||
|
||||
▸ **fulfill**(`returnId`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnId` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:450](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L450)
|
||||
|
||||
___
|
||||
|
||||
### getFulfillmentItems\_
|
||||
|
||||
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Retrieves the order line items, given an array of items
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get line items from |
|
||||
| `items` | `Object` | the items to get |
|
||||
| `items.item_id` | `string` | - |
|
||||
| `items.quantity` | `number` | - |
|
||||
| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the line items generated by the transformer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L89)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L120)
|
||||
|
||||
___
|
||||
|
||||
### receive
|
||||
|
||||
▸ **receive**(`return_id`, `received_items`, `refund_amount`, `allow_mismatch?`): `Promise`<`any`\>
|
||||
|
||||
Registers a previously requested return as received. This will create a
|
||||
refund to the customer. If the returned items don't match the requested
|
||||
items the return status will be updated to requires_action. This behaviour
|
||||
is useful in sitautions where a custom refund amount is requested, but the
|
||||
retuned items are not matching the requested items. Setting the
|
||||
allowMismatch argument to true, will process the return, ignoring any
|
||||
mismatches.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `return_id` | `string` | `undefined` | the orderId to return to |
|
||||
| `received_items` | `Item`[] | `undefined` | the items received after return. |
|
||||
| `refund_amount` | `undefined` \| `number` | `undefined` | the amount to return |
|
||||
| `allow_mismatch` | `bool` | `false` | whether to ignore return/received product mismatch |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:524](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L524)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Return`
|
||||
|
||||
Retrieves a return by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the return to retrieve |
|
||||
| `config` | `any` | the config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Return`
|
||||
|
||||
the return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:229](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L229)
|
||||
|
||||
___
|
||||
|
||||
### retrieveBySwap
|
||||
|
||||
▸ **retrieveBySwap**(`swapId`, `relations?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `any` | `undefined` |
|
||||
| `relations` | `any`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:248](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L248)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`returnId`, `update`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnId` | `any` |
|
||||
| `update` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:271](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L271)
|
||||
|
||||
___
|
||||
|
||||
### validateReturnLineItem\_
|
||||
|
||||
▸ **validateReturnLineItem_**(`item`, `quantity`, `additional`): `LineItem`
|
||||
|
||||
Checks that a given quantity of a line item can be returned. Fails if the
|
||||
item is undefined or if the returnable quantity of the item is lower, than
|
||||
the quantity that is requested to be returned.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `item` | `any` | the line item to check has sufficient returnable quantity. |
|
||||
| `quantity` | `number` | the quantity that is requested to be returned. |
|
||||
| `additional` | `any` | the quantity that is requested to be returned. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineItem`
|
||||
|
||||
a line item where the quantity is set to the requested
|
||||
return quantity.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:191](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L191)
|
||||
|
||||
___
|
||||
|
||||
### validateReturnStatuses\_
|
||||
|
||||
▸ **validateReturnStatuses_**(`order`): `void`
|
||||
|
||||
Checks that an order has the statuses necessary to complete a return.
|
||||
fulfillment_status cannot be not_fulfilled or returned.
|
||||
payment_status must be captured.
|
||||
|
||||
**`throws`** when statuses are not sufficient for returns.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to check statuses on |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L161)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/return.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L55)
|
||||
222
docs/content/references/services/classes/SearchService.md
Normal file
222
docs/content/references/services/classes/SearchService.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# Class: SearchService
|
||||
|
||||
Default class that implements SearchService but provides stuv implementation for all methods
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`SearchService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SearchService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
SearchService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L8)
|
||||
|
||||
## Properties
|
||||
|
||||
### isDefault
|
||||
|
||||
• **isDefault**: `boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L11)
|
||||
|
||||
___
|
||||
|
||||
### logger\_
|
||||
|
||||
• **logger\_**: `any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:13](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L13)
|
||||
|
||||
## Methods
|
||||
|
||||
### addDocuments
|
||||
|
||||
▸ **addDocuments**(`indexName`, `documents`, `type`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `documents` | `any` |
|
||||
| `type` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L28)
|
||||
|
||||
___
|
||||
|
||||
### createIndex
|
||||
|
||||
▸ **createIndex**(`indexName`, `options`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `options` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L16)
|
||||
|
||||
___
|
||||
|
||||
### deleteAllDocuments
|
||||
|
||||
▸ **deleteAllDocuments**(`indexName`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L46)
|
||||
|
||||
___
|
||||
|
||||
### deleteDocument
|
||||
|
||||
▸ **deleteDocument**(`indexName`, `document_id`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `document_id` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L40)
|
||||
|
||||
___
|
||||
|
||||
### getIndex
|
||||
|
||||
▸ **getIndex**(`indexName`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L22)
|
||||
|
||||
___
|
||||
|
||||
### replaceDocuments
|
||||
|
||||
▸ **replaceDocuments**(`indexName`, `documents`, `type`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `documents` | `any` |
|
||||
| `type` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L34)
|
||||
|
||||
___
|
||||
|
||||
### search
|
||||
|
||||
▸ **search**(`indexName`, `query`, `options`): `Object`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `query` | `any` |
|
||||
| `options` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `hits` | `never`[] |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L52)
|
||||
|
||||
___
|
||||
|
||||
### updateSettings
|
||||
|
||||
▸ **updateSettings**(`indexName`, `settings`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `any` |
|
||||
| `settings` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/search.js:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L59)
|
||||
@@ -0,0 +1,478 @@
|
||||
# Class: ShippingOptionService
|
||||
|
||||
Provides layer to manipulate profiles.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ShippingOptionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ShippingOptionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L9)
|
||||
|
||||
## Methods
|
||||
|
||||
### addRequirement
|
||||
|
||||
▸ **addRequirement**(`optionId`, `requirement`): `Promise`<`any`\>
|
||||
|
||||
Adds a requirement to a shipping option. Only 1 requirement of each type
|
||||
is allowed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the option to add the requirement to. |
|
||||
| `requirement` | `ShippingRequirement` | the requirement for the option. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:594](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L594)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`ShippingOption`\>
|
||||
|
||||
Creates a new shipping option. Used both for outbound and inbound shipping
|
||||
options. The difference is registered by the `is_return` field which
|
||||
defaults to false.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `ShippingOption` | the data to create shipping options |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:350](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L350)
|
||||
|
||||
___
|
||||
|
||||
### createShippingMethod
|
||||
|
||||
▸ **createShippingMethod**(`optionId`, `data`, `config`): `ShippingMethod`
|
||||
|
||||
Creates a shipping method for a given cart.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the option to use for the method. |
|
||||
| `data` | `any` | the optional provider data to use. |
|
||||
| `config` | `any` | the cart to create the shipping method for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ShippingMethod`
|
||||
|
||||
the resulting shipping method.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:231](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L231)
|
||||
|
||||
___
|
||||
|
||||
### decorate
|
||||
|
||||
▸ **decorate**(`optionId`, `fields?`, `expandFields?`): `ShippingOption`
|
||||
|
||||
Decorates a shipping option.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `optionId` | `ShippingOption` | `undefined` | the shipping option to decorate using optionId. |
|
||||
| `fields` | `string`[] | `[]` | the fields to include. |
|
||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ShippingOption`
|
||||
|
||||
the decorated ShippingOption.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:645](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L645)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`optionId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a profile with a given profile id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:566](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L566)
|
||||
|
||||
___
|
||||
|
||||
### deleteShippingMethods
|
||||
|
||||
▸ **deleteShippingMethods**(`shippingMethods`): `Promise`<`any`\>
|
||||
|
||||
Removes a given shipping method
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethods` | `any` | the shipping method to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:213](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L213)
|
||||
|
||||
___
|
||||
|
||||
### getPrice\_
|
||||
|
||||
▸ **getPrice_**(`option`, `data`, `cart`): `Promise`<`number`\>
|
||||
|
||||
Returns the amount to be paid for a shipping method. Will ask the
|
||||
fulfillment provider to calculate the price if the shipping option has the
|
||||
price type "calculated".
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `option` | `ShippingOption` | the shipping option to retrieve the price for. |
|
||||
| `data` | `ShippingData` | the shipping data to retrieve the price. |
|
||||
| `cart` | `any` | the context in which the price should be retrieved. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the price of the shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:697](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L697)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:123](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L123)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L135)
|
||||
|
||||
___
|
||||
|
||||
### removeRequirement
|
||||
|
||||
▸ **removeRequirement**(`requirementId`): `Promise`<`any`\>
|
||||
|
||||
Removes a requirement from a shipping option
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `requirementId` | `string` | the id of the requirement to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:620](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L620)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`optionId`, `options?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a profile by id.
|
||||
Throws in case of DB Error and if profile was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the profile to get. |
|
||||
| `options` | `any` | the options to get a profile |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the profile document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:149](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L149)
|
||||
|
||||
___
|
||||
|
||||
### setMetadata\_
|
||||
|
||||
▸ **setMetadata_**(`option`, `metadata`): `Promise`<`any`\>
|
||||
|
||||
Dedicated method to set metadata for a shipping option.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `option` | `any` | the option to set metadata for. |
|
||||
| `metadata` | `any` | object for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:664](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L664)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`optionId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a profile. Metadata updates and product updates should use
|
||||
dedicated methods, e.g. `setMetadata`, etc. The function
|
||||
will throw errors if metadata or product updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the option. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:464](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L464)
|
||||
|
||||
___
|
||||
|
||||
### updateShippingMethod
|
||||
|
||||
▸ **updateShippingMethod**(`id`, `update`): `Promise`<`ShippingMethod`\>
|
||||
|
||||
Updates a shipping method's associations. Useful when a cart is completed
|
||||
and its methods should be copied to an order/swap entity.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the shipping method to update |
|
||||
| `update` | `any` | the values to update the method with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethod`\>
|
||||
|
||||
the resulting shipping method
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:184](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L184)
|
||||
|
||||
___
|
||||
|
||||
### validateCartOption
|
||||
|
||||
▸ **validateCartOption**(`option`, `cart`): `ShippingOption`
|
||||
|
||||
Checks if a given option id is a valid option for a cart. If it is the
|
||||
option is returned with the correct price. Throws when region_ids do not
|
||||
match, or when the shipping option requirements are not satisfied.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `option` | `any` | the option object to check |
|
||||
| `cart` | `Cart` | the cart object to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ShippingOption`
|
||||
|
||||
the validated shipping option
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:309](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L309)
|
||||
|
||||
___
|
||||
|
||||
### validatePriceType\_
|
||||
|
||||
▸ **validatePriceType_**(`priceType`, `option`): `Promise`<`ShippingOptionPrice`\>
|
||||
|
||||
Validates a shipping option price
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceType` | `ShippingOptionPrice` | the price to validate |
|
||||
| `option` | `ShippingOption` | the option to validate against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOptionPrice`\>
|
||||
|
||||
the validated price
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:431](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L431)
|
||||
|
||||
___
|
||||
|
||||
### validateRequirement\_
|
||||
|
||||
▸ **validateRequirement_**(`requirement`, `optionId`): `ShippingRequirement`
|
||||
|
||||
Validates a requirement
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `requirement` | `ShippingRequirement` | the requirement to validate |
|
||||
| `optionId` | `string` | the id to validate the requirement |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ShippingRequirement`
|
||||
|
||||
a validated shipping requirement
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:63](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L63)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-option.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L38)
|
||||
@@ -0,0 +1,392 @@
|
||||
# Class: ShippingProfileService
|
||||
|
||||
Provides layer to manipulate profiles.
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`ShippingProfileService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ShippingProfileService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L12)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProduct
|
||||
|
||||
▸ **addProduct**(`profileId`, `productId`): `Promise`<`any`\>
|
||||
|
||||
Adds a product to a profile. The method is idempotent, so multiple calls
|
||||
with the same product variant will have the same result.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the profile to add the product to. |
|
||||
| `productId` | `string` | the product to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L343)
|
||||
|
||||
___
|
||||
|
||||
### addShippingOption
|
||||
|
||||
▸ **addShippingOption**(`profileId`, `optionId`): `Promise`<`any`\>
|
||||
|
||||
Adds a shipping option to the profile. The shipping option can be used to
|
||||
fulfill the products in the products field.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the profile to apply the shipping option to |
|
||||
| `optionId` | `string` | the option to add to the profile |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the model update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:361](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L361)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`profile`): `Promise`<`any`\>
|
||||
|
||||
Creates a new shipping profile.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profile` | `ShippingProfile` | the shipping profile to create from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:235](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L235)
|
||||
|
||||
___
|
||||
|
||||
### createDefault
|
||||
|
||||
▸ **createDefault**(): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Creates a default shipping profile, if this does not already exist.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the shipping profile
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:167](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L167)
|
||||
|
||||
___
|
||||
|
||||
### createGiftCardDefault
|
||||
|
||||
▸ **createGiftCardDefault**(): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Creates a default shipping profile, for gift cards if unless it already
|
||||
exists.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the shipping profile
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:209](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L209)
|
||||
|
||||
___
|
||||
|
||||
### decorate
|
||||
|
||||
▸ **decorate**(`profile`, `fields`, `expandFields?`): `Profile`
|
||||
|
||||
Decorates a profile.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `profile` | `Profile` | `undefined` | the profile to decorate. |
|
||||
| `fields` | `string`[] | `undefined` | the fields to include. |
|
||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Profile`
|
||||
|
||||
return the decorated profile.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:379](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L379)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`profileId`): `Promise`<`any`\>
|
||||
|
||||
Deletes a profile with a given profile id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:317](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L317)
|
||||
|
||||
___
|
||||
|
||||
### fetchCartOptions
|
||||
|
||||
▸ **fetchCartOptions**(`cart`): [`ShippingOption`]
|
||||
|
||||
Finds all the shipping profiles that cover the products in a cart, and
|
||||
validates all options that are available for the cart.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `Cart` | the cart object to find shipping options for |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ShippingOption`]
|
||||
|
||||
a list of the available shipping options
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:425](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L425)
|
||||
|
||||
___
|
||||
|
||||
### fetchOptionsByProductIds
|
||||
|
||||
▸ **fetchOptionsByProductIds**(`productIds`, `filter`): `Promise`<`any`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productIds` | `any` |
|
||||
| `filter` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:73](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L73)
|
||||
|
||||
___
|
||||
|
||||
### getProfilesInCart\_
|
||||
|
||||
▸ **getProfilesInCart_**(`cart`): [`string`]
|
||||
|
||||
Returns a list of all the productIds in the cart.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `Cart` | the cart to extract products from |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`string`]
|
||||
|
||||
a list of product ids
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:406](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L406)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:64](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L64)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`profileId`, `options?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a profile by id.
|
||||
Throws in case of DB Error and if profile was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile to get. |
|
||||
| `options` | `any` | options opf the query. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the profile document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L121)
|
||||
|
||||
___
|
||||
|
||||
### retrieveDefault
|
||||
|
||||
▸ **retrieveDefault**(): `Promise`<`any`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:151](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L151)
|
||||
|
||||
___
|
||||
|
||||
### retrieveGiftCardDefault
|
||||
|
||||
▸ **retrieveGiftCardDefault**(): `any`
|
||||
|
||||
Retrieves the default gift card profile
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
the shipping profile for gift cards
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:192](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L192)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`profileId`, `update`): `Promise`<`any`\>
|
||||
|
||||
Updates a profile. Metadata updates and product updates should use
|
||||
dedicated methods, e.g. `setMetadata`, `addProduct`, etc. The function
|
||||
will throw errors if metadata or product updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:263](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L263)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`ShippingProfileService`](ShippingProfileService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ShippingProfileService`](ShippingProfileService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/shipping-profile.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L41)
|
||||
216
docs/content/references/services/classes/StoreService.md
Normal file
216
docs/content/references/services/classes/StoreService.md
Normal file
@@ -0,0 +1,216 @@
|
||||
# Class: StoreService
|
||||
|
||||
Provides layer to manipulate store settings.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`StoreService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new StoreService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L10)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCurrency
|
||||
|
||||
▸ **addCurrency**(`code`): `Promise`<`any`\>
|
||||
|
||||
Add a currency to the store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | 3 character ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result after update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:203](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L203)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(): `Promise`<`Store`\>
|
||||
|
||||
Creates a store if it doesn't already exist.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
the store.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L52)
|
||||
|
||||
___
|
||||
|
||||
### decorate
|
||||
|
||||
▸ **decorate**(`store`, `fields`, `expandFields?`): `Store`
|
||||
|
||||
Decorates a store object.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `store` | `Store` | `undefined` | the store to decorate. |
|
||||
| `fields` | `string`[] | `undefined` | the fields to include. |
|
||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Store`
|
||||
|
||||
return the decorated Store.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:266](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L266)
|
||||
|
||||
___
|
||||
|
||||
### getDefaultCurrency\_
|
||||
|
||||
▸ **getDefaultCurrency_**(`code`): `Object`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `any` |
|
||||
| `name` | `any` |
|
||||
| `symbol` | `any` |
|
||||
| `symbol_native` | `any` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:92](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L92)
|
||||
|
||||
___
|
||||
|
||||
### removeCurrency
|
||||
|
||||
▸ **removeCurrency**(`code`): `Promise`<`any`\>
|
||||
|
||||
Removes a currency from the store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | 3 character ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result after update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:242](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L242)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`relations?`): `Promise`<`Store`\>
|
||||
|
||||
Retrieve the store settings. There is always a maximum of one store.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `relations` | `string`[] | `[]` | relations to fetch with store |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
the store
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L84)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`update`): `Promise`<`any`\>
|
||||
|
||||
Updates a store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `update` | `any` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:108](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L108)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`StoreService`](StoreService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`StoreService`](StoreService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/store.js:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L31)
|
||||
465
docs/content/references/services/classes/SwapService.md
Normal file
465
docs/content/references/services/classes/SwapService.md
Normal file
@@ -0,0 +1,465 @@
|
||||
# Class: SwapService
|
||||
|
||||
Handles swaps
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`SwapService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SwapService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:21](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L21)
|
||||
|
||||
## Properties
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `FULFILLMENT_CREATED` | `string` |
|
||||
| `PAYMENT_CAPTURED` | `string` |
|
||||
| `PAYMENT_CAPTURE_FAILED` | `string` |
|
||||
| `PAYMENT_COMPLETED` | `string` |
|
||||
| `PROCESS_REFUND_FAILED` | `string` |
|
||||
| `RECEIVED` | `string` |
|
||||
| `REFUND_PROCESSED` | `string` |
|
||||
| `SHIPMENT_CREATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L9)
|
||||
|
||||
## Methods
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`swapId`): `Promise`<`Swap`\>
|
||||
|
||||
Cancels a given swap if possible. A swap can only be canceled if all
|
||||
related returns, fulfillments, and payments have been canceled. If a swap
|
||||
is associated with a refund, it cannot be canceled.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the canceled swap.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:790](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L790)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentId`): `Swap`
|
||||
|
||||
Cancels a fulfillment (if related to a swap)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `string` | the ID of the fulfillment to cancel |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Swap`
|
||||
|
||||
updated swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:983](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L983)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`order`, `returnItems`, `additionalItems`, `returnShipping`, `custom?`): `Promise`<`Swap`\>
|
||||
|
||||
Creates a swap from an order, with given return items, additional items
|
||||
and an optional return shipping method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to base the swap off. |
|
||||
| `returnItems` | `ReturnItem`[] | the items to return in the swap. |
|
||||
| `additionalItems` | `undefined` \| `PreliminaryLineItem`[] | the items to send to the customer. |
|
||||
| `returnShipping` | `any` | an optional shipping method for returning the returnItems. |
|
||||
| `custom` | `any` | contains relevant custom information. This object may include no_notification which will disable sending notification when creating swap. If set, it overrules the attribute inherited from the order. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the newly created swap.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:313](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L313)
|
||||
|
||||
___
|
||||
|
||||
### createCart
|
||||
|
||||
▸ **createCart**(`swapId`, `customShippingOptions?`): `Promise`<`Swap`\>
|
||||
|
||||
Creates a cart from the given swap and order. The cart can be used to pay
|
||||
for differences associated with the swap. The swap represented by the
|
||||
swapId must belong to the order. Fails if there is already a cart on the
|
||||
swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `swapId` | `string` | `undefined` | the id of the swap to create the cart from |
|
||||
| `customShippingOptions` | `any`[] | `[]` | the shipping options |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap with its cart_id prop set to the id of
|
||||
the new cart.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:544](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L544)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`swapId`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Fulfills the addtional items associated with the swap. Will call the
|
||||
fulfillment providers associated with the shipping methods.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap to fulfill, |
|
||||
| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the updated swap with new status and fulfillments.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:848](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L848)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`swapId`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Marks a fulfillment as shipped and attaches tracking numbers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap that has been shipped. |
|
||||
| `fulfillmentId` | `string` | the id of the specific fulfillment that has been shipped |
|
||||
| `trackingLinks` | `undefined` \| `TrackingLink`[] | the tracking numbers associated with the shipment |
|
||||
| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the updated swap with new fulfillments and status.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:1016](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1016)
|
||||
|
||||
___
|
||||
|
||||
### deleteMetadata
|
||||
|
||||
▸ **deleteMetadata**(`swapId`, `key`): `Promise`<`any`\>
|
||||
|
||||
Dedicated method to delete metadata for a swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the order to delete metadata from. |
|
||||
| `key` | `string` | key for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:1089](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1089)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:238](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L238)
|
||||
|
||||
___
|
||||
|
||||
### processDifference
|
||||
|
||||
▸ **processDifference**(`swapId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `swapId` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:395](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L395)
|
||||
|
||||
___
|
||||
|
||||
### registerCartCompletion
|
||||
|
||||
▸ **registerCartCompletion**(`swapId`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | The id of the swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:659](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L659)
|
||||
|
||||
___
|
||||
|
||||
### registerReceived
|
||||
|
||||
▸ **registerReceived**(`id`): `Promise`<`Order`\>
|
||||
|
||||
Registers the swap return items as received so that they cannot be used
|
||||
as a part of other swaps/returns.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the order with the swap. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Order`\>
|
||||
|
||||
the resulting order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:1114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1114)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Retrieves a swap with the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the swap to retrieve |
|
||||
| `config` | `any` | the configuration to retrieve the swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:181](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L181)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCartId
|
||||
|
||||
▸ **retrieveByCartId**(`cartId`, `relations?`): `Promise`<`Swap`\>
|
||||
|
||||
Retrieves a swap based on its associated cart id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `cartId` | `string` | `undefined` | the cart id that the swap's cart has |
|
||||
| `relations` | `string`[] | `[]` | the relations to retrieve swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:216](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L216)
|
||||
|
||||
___
|
||||
|
||||
### transformQueryForCart\_
|
||||
|
||||
▸ **transformQueryForCart_**(`config`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `config` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L114)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`swapId`, `update`): `Promise`<`any`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `swapId` | `any` |
|
||||
| `update` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:511](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L511)
|
||||
|
||||
___
|
||||
|
||||
### validateReturnItems\_
|
||||
|
||||
▸ **validateReturnItems_**(`order`, `returnItems`): `ReturnItems`[]
|
||||
|
||||
Goes through a list of return items to ensure that they exist on the
|
||||
original order. If the item exists it is verified that the quantity to
|
||||
return is not higher than the original quantity ordered.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `OrderLike` | the order to return from |
|
||||
| `returnItems` | `ReturnItem`[] | the items to return |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ReturnItems`[]
|
||||
|
||||
the validated returnItems
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:269](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L269)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`SwapService`](SwapService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SwapService`](SwapService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/swap.js:86](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L86)
|
||||
@@ -0,0 +1,237 @@
|
||||
# Class: SystemPaymentProviderService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`SystemPaymentProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SystemPaymentProviderService**(`_`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L6)
|
||||
|
||||
## Properties
|
||||
|
||||
### identifier
|
||||
|
||||
▪ `Static` **identifier**: `string` = `"system"`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:4](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L4)
|
||||
|
||||
## Methods
|
||||
|
||||
### authorizePayment
|
||||
|
||||
▸ **authorizePayment**(`_`): `Promise`<{ `data`: {} = {}; `status`: `string` = "authorized" }\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `data`: {} = {}; `status`: `string` = "authorized" }\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L22)
|
||||
|
||||
___
|
||||
|
||||
### cancelPayment
|
||||
|
||||
▸ **cancelPayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L46)
|
||||
|
||||
___
|
||||
|
||||
### capturePayment
|
||||
|
||||
▸ **capturePayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L38)
|
||||
|
||||
___
|
||||
|
||||
### createPayment
|
||||
|
||||
▸ **createPayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L10)
|
||||
|
||||
___
|
||||
|
||||
### deletePayment
|
||||
|
||||
▸ **deletePayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L34)
|
||||
|
||||
___
|
||||
|
||||
### getPaymentData
|
||||
|
||||
▸ **getPaymentData**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:18](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L18)
|
||||
|
||||
___
|
||||
|
||||
### getStatus
|
||||
|
||||
▸ **getStatus**(`_`): `Promise`<`string`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L14)
|
||||
|
||||
___
|
||||
|
||||
### refundPayment
|
||||
|
||||
▸ **refundPayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L42)
|
||||
|
||||
___
|
||||
|
||||
### updatePayment
|
||||
|
||||
▸ **updatePayment**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L30)
|
||||
|
||||
___
|
||||
|
||||
### updatePaymentData
|
||||
|
||||
▸ **updatePaymentData**(`_`): `Promise`<{}\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{}\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/system-payment-provider.js:26](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L26)
|
||||
442
docs/content/references/services/classes/TaxProviderService.md
Normal file
442
docs/content/references/services/classes/TaxProviderService.md
Normal file
@@ -0,0 +1,442 @@
|
||||
# Class: TaxProviderService
|
||||
|
||||
Finds tax providers and assists in tax related operations.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`TaxProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TaxProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `AwilixContainer`<`any`\> |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L44)
|
||||
|
||||
## Properties
|
||||
|
||||
### container\_
|
||||
|
||||
• `Private` **container\_**: `AwilixContainer`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### redis\_
|
||||
|
||||
• `Private` **redis\_**: `Redis`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### smTaxLineRepo\_
|
||||
|
||||
• `Private` **smTaxLineRepo\_**: typeof `ShippingMethodTaxLineRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### taxLineRepo\_
|
||||
|
||||
• `Private` **taxLineRepo\_**: typeof `LineItemTaxLineRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderRepo\_
|
||||
|
||||
• `Private` **taxProviderRepo\_**: typeof `TaxProviderRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### taxRateService\_
|
||||
|
||||
• `Private` **taxRateService\_**: [`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Private` **transactionManager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:37](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L37)
|
||||
|
||||
## Methods
|
||||
|
||||
### clearTaxLines
|
||||
|
||||
▸ **clearTaxLines**(`cartId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cartId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### createShippingTaxLines
|
||||
|
||||
▸ **createShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Persists the tax lines relevant for a shipping method to the database. Used
|
||||
for return shipping methods.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to create tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the newly created tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:166](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L166)
|
||||
|
||||
___
|
||||
|
||||
### createTaxLines
|
||||
|
||||
▸ **createTaxLines**(`cartOrLineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Persists the tax lines relevant for an order to the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrLineItems` | `Cart` \| `LineItem`[] | the cart or line items to create tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the newly created tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L116)
|
||||
|
||||
___
|
||||
|
||||
### getCacheEntry
|
||||
|
||||
▸ `Private` **getCacheEntry**(`productId`, `regionId`): `Promise`<``null`` \| `TaxServiceRate`[]\>
|
||||
|
||||
Gets the cache results for a set of ids
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product id to cache |
|
||||
| `regionId` | `string` | the region id to cache |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `TaxServiceRate`[]\>
|
||||
|
||||
the cached result or null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:450](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L450)
|
||||
|
||||
___
|
||||
|
||||
### getCacheKey
|
||||
|
||||
▸ `Private` **getCacheKey**(`productId`, `regionId`): `string`
|
||||
|
||||
The cache key to get cache hits by.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product id to cache |
|
||||
| `regionId` | `string` | the region id to cache |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the cache key to use for the id set
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:419](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L419)
|
||||
|
||||
___
|
||||
|
||||
### getRegionRatesForProduct
|
||||
|
||||
▸ **getRegionRatesForProduct**(`productId`, `region`): `Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
Gets the tax rates configured for a product. The rates are cached between
|
||||
calls.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product id to get rates for |
|
||||
| `region` | `Region` | the region to get configured rates for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
the tax rates configured for the shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:374](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L374)
|
||||
|
||||
___
|
||||
|
||||
### getRegionRatesForShipping
|
||||
|
||||
▸ **getRegionRatesForShipping**(`optionId`, `region`): `Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
Gets the tax rates configured for a shipping option. The rates are cached
|
||||
between calls.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the option id of the shipping method. |
|
||||
| `region` | `Region` | the region to get configured rates for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
the tax rates configured for the shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:327](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L327)
|
||||
|
||||
___
|
||||
|
||||
### getShippingTaxLines
|
||||
|
||||
▸ **getShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<`ShippingMethodTaxLine`[]\>
|
||||
|
||||
Gets the relevant tax lines for a shipping method. Note: this method
|
||||
doesn't persist the tax lines. Use createShippingTaxLines if you wish to
|
||||
persist the tax lines to the DB layer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTaxLine`[]\>
|
||||
|
||||
the computed tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:185](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
### getTaxLines
|
||||
|
||||
▸ **getTaxLines**(`lineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Gets the relevant tax lines for an order or cart. If an order is provided
|
||||
the order's tax lines will be returned. If a cart is provided the tax lines
|
||||
will be computed from the tax rules and potentially a 3rd party tax plugin.
|
||||
Note: this method doesn't persist the tax lines. Use createTaxLines if you
|
||||
wish to persist the tax lines to the DB layer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItems` | `LineItem`[] | the cart or order to get tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the computed tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:237](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L237)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`TaxProvider`[]\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxProvider`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:70](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:471](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L471)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**(`region`): `ITaxService`
|
||||
|
||||
Retrieves the relevant tax provider for the given region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `region` | `Region` | the region to get tax provider for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ITaxService`
|
||||
|
||||
the region specific tax provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L80)
|
||||
|
||||
___
|
||||
|
||||
### setCache
|
||||
|
||||
▸ `Private` **setCache**(`productId`, `regionId`, `value`): `Promise`<`void`\>
|
||||
|
||||
Sets the cache results for a set of ids
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product id to cache |
|
||||
| `regionId` | `string` | the region id to cache |
|
||||
| `value` | `TaxServiceRate`[] | tax rates to cache |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
promise that resolves after the cache has been set
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L430)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-provider.ts:57](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L57)
|
||||
392
docs/content/references/services/classes/TaxRateService.md
Normal file
392
docs/content/references/services/classes/TaxRateService.md
Normal file
@@ -0,0 +1,392 @@
|
||||
# Class: TaxRateService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`TaxRateService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TaxRateService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L27)
|
||||
|
||||
## Properties
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:21](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Private` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### productTypeService\_
|
||||
|
||||
• `Private` **productTypeService\_**: [`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L23)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Private` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:24](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### taxRateRepository\_
|
||||
|
||||
• `Private` **taxRateRepository\_**: typeof `TaxRateRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L25)
|
||||
|
||||
## Methods
|
||||
|
||||
### addToProduct
|
||||
|
||||
▸ **addToProduct**(`id`, `productIds`, `replace?`): `Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `productIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:197](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L197)
|
||||
|
||||
___
|
||||
|
||||
### addToProductType
|
||||
|
||||
▸ **addToProductType**(`id`, `productTypeIds`, `replace?`): `Promise`<`ProductTypeTaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `productTypeIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductTypeTaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:233](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L233)
|
||||
|
||||
___
|
||||
|
||||
### addToShippingOption
|
||||
|
||||
▸ **addToShippingOption**(`id`, `optionIds`, `replace?`): `Promise`<`ShippingTaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `optionIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingTaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:273](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L273)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateTaxRateInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L135)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableTaxRateProps` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`TaxRate`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableTaxRateProps` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`TaxRate`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:73](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L73)
|
||||
|
||||
___
|
||||
|
||||
### listByProduct
|
||||
|
||||
▸ **listByProduct**(`productId`, `config`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productId` | `string` |
|
||||
| `config` | `TaxRateListByConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:321](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L321)
|
||||
|
||||
___
|
||||
|
||||
### listByShippingOption
|
||||
|
||||
▸ **listByShippingOption**(`shippingOptionId`, `config`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingOptionId` | `string` |
|
||||
| `config` | `TaxRateListByConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:332](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L332)
|
||||
|
||||
___
|
||||
|
||||
### removeFromProduct
|
||||
|
||||
▸ **removeFromProduct**(`id`, `productIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `productIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:143](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L143)
|
||||
|
||||
___
|
||||
|
||||
### removeFromProductType
|
||||
|
||||
▸ **removeFromProductType**(`id`, `typeIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `typeIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L161)
|
||||
|
||||
___
|
||||
|
||||
### removeFromShippingOption
|
||||
|
||||
▸ **removeFromShippingOption**(`id`, `optionIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `optionIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:179](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L179)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L84)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `data` | `UpdateTaxRateInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L120)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/tax-rate.ts:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L43)
|
||||
607
docs/content/references/services/classes/TotalsService.md
Normal file
607
docs/content/references/services/classes/TotalsService.md
Normal file
@@ -0,0 +1,607 @@
|
||||
# Class: TotalsService
|
||||
|
||||
A service that calculates total and subtotals for orders, carts etc..
|
||||
|
||||
**`implements`** {BaseService}
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`TotalsService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TotalsService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `TotalsServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:90](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L90)
|
||||
|
||||
## Properties
|
||||
|
||||
### taxCalculationStrategy\_
|
||||
|
||||
• `Private` **taxCalculationStrategy\_**: `ITaxCalculationStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L88)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Private` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:87](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L87)
|
||||
|
||||
## Methods
|
||||
|
||||
### calculateDiscount\_
|
||||
|
||||
▸ **calculateDiscount_**(`lineItem`, `variant`, `variantPrice`, `value`, `discountType`): `LineDiscount`
|
||||
|
||||
Calculates either fixed or percentage discount of a variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | id of line item |
|
||||
| `variant` | `string` | id of variant in line item |
|
||||
| `variantPrice` | `number` | price of the variant based on region |
|
||||
| `value` | `number` | discount value |
|
||||
| `discountType` | `DiscountRuleType` | the type of discount (fixed or percentage) |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscount`
|
||||
|
||||
triples of lineitem, variant and applied discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:545](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L545)
|
||||
|
||||
___
|
||||
|
||||
### getAllocationItemDiscounts
|
||||
|
||||
▸ **getAllocationItemDiscounts**(`discount`, `cart`): `LineDiscount`[]
|
||||
|
||||
If the rule of a discount has allocation="item", then we need
|
||||
to calculate discount on each item in the cart. Furthermore, we need to
|
||||
make sure to only apply the discount on valid variants. And finally we
|
||||
return ether an array of percentages discounts or fixed discounts
|
||||
alongside the variant on which the discount was applied.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discount` | `Discount` | the discount to which we do the calculation |
|
||||
| `cart` | `Cart` \| `Order` | the cart to calculate discounts for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscount`[]
|
||||
|
||||
array of triples of lineitem, variant and applied discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:587](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L587)
|
||||
|
||||
___
|
||||
|
||||
### getAllocationMap
|
||||
|
||||
▸ **getAllocationMap**(`orderOrCart`, `options?`): `LineAllocationsMap`
|
||||
|
||||
Gets a map of discounts and gift cards that apply to line items in an
|
||||
order. The function calculates the amount of a discount or gift card that
|
||||
applies to a specific line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderOrCart` | `Cart` \| `Order` | the order or cart to get an allocation map for |
|
||||
| `options` | `AllocationMapOptions` | controls what should be included in allocation map |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineAllocationsMap`
|
||||
|
||||
the allocation map for the line items in the cart or order.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:368](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L368)
|
||||
|
||||
___
|
||||
|
||||
### getCalculationContext
|
||||
|
||||
▸ **getCalculationContext**(`cartOrOrder`, `options?`): `TaxCalculationContext`
|
||||
|
||||
Prepares the calculation context for a tax total calculation.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get the calculation context for |
|
||||
| `options` | `CalculationContextOptions` | options to gather context by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`TaxCalculationContext`
|
||||
|
||||
the tax calculation context
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:892](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L892)
|
||||
|
||||
___
|
||||
|
||||
### getDiscountTotal
|
||||
|
||||
▸ **getDiscountTotal**(`cartOrOrder`): `number`
|
||||
|
||||
Calculates the total discount amount for each of the different supported
|
||||
discount types. If discounts aren't present or invalid returns 0.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to calculate discounts for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the total discounts amount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:858](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L858)
|
||||
|
||||
___
|
||||
|
||||
### getGiftCardTotal
|
||||
|
||||
▸ **getGiftCardTotal**(`cartOrOrder`): `number`
|
||||
|
||||
Gets the gift card amount on a cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get gift card amount for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the gift card amount applied to the cart or order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:830](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L830)
|
||||
|
||||
___
|
||||
|
||||
### getLineDiscounts
|
||||
|
||||
▸ **getLineDiscounts**(`cartOrOrder`, `discount`): `LineDiscountAmount`[]
|
||||
|
||||
Returns the discount amount allocated to the line items of an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get line discount allocations for |
|
||||
| `discount` | `Discount` | the discount to use as context for the calculation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscountAmount`[]
|
||||
|
||||
the allocations that the discount has on the items in the cart or
|
||||
order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:638](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L638)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemAdjustmentsTotal
|
||||
|
||||
▸ **getLineItemAdjustmentsTotal**(`cartOrOrder`): `number`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:615](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L615)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemDiscountAdjustment
|
||||
|
||||
▸ **getLineItemDiscountAdjustment**(`lineItem`, `discount`): `number`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `lineItem` | `LineItem` |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:600](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L600)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemRefund
|
||||
|
||||
▸ **getLineItemRefund**(`order`, `lineItem`): `number`
|
||||
|
||||
The amount that can be refunded for a given line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | order to use as context for the calculation |
|
||||
| `lineItem` | `LineItem` | the line item to calculate the refund amount for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the line item refund amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L460)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotal
|
||||
|
||||
▸ **getLineItemTotal**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`number`\>
|
||||
|
||||
Gets a total for a line item. The total can take gift cards, discounts and
|
||||
taxes into account. This can be controlled through the options.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | the line item to calculate a total for |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation |
|
||||
| `options` | `GetLineItemTotalOptions` | the options to use for the calculation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the line item total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:800](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L800)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotals
|
||||
|
||||
▸ **getLineItemTotals**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`LineItemTotals`\>
|
||||
|
||||
Breaks down the totals related to a line item; these are the subtotal, the
|
||||
amount of discount applied to the line item, the amount of a gift card
|
||||
applied to a line item and the amount of tax applied to a line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | the line item to calculate totals for |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation |
|
||||
| `options` | `LineItemTotalsOptions` | the options to evaluate the line item totals for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemTotals`\>
|
||||
|
||||
the breakdown of the line item totals
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:684](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L684)
|
||||
|
||||
___
|
||||
|
||||
### getPaidTotal
|
||||
|
||||
▸ **getPaidTotal**(`order`): `number`
|
||||
|
||||
Gets the total payments made on an order
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to calculate paid amount for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the total paid amount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:125](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L125)
|
||||
|
||||
___
|
||||
|
||||
### getRefundTotal
|
||||
|
||||
▸ **getRefundTotal**(`order`, `lineItems`): `number`
|
||||
|
||||
Calculates refund total of line items.
|
||||
If any of the items to return have been discounted, we need to
|
||||
apply the discount again before refunding them.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | cart or order to calculate subtotal for |
|
||||
| `lineItems` | `LineItem`[] | the line items to calculate refund total for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:504](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L504)
|
||||
|
||||
___
|
||||
|
||||
### getRefundedTotal
|
||||
|
||||
▸ **getRefundedTotal**(`order`): `number`
|
||||
|
||||
Gets the total refund amount for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get total refund amount for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the total refunded amount for an order.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:445](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L445)
|
||||
|
||||
___
|
||||
|
||||
### getShippingMethodTotals
|
||||
|
||||
▸ **getShippingMethodTotals**(`shippingMethod`, `cartOrOrder`, `opts?`): `Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
Gets the totals breakdown for a shipping method. Fetches tax lines if not
|
||||
already provided.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get totals breakdown for. |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the breakdown |
|
||||
| `opts` | `GetShippingMethodTotalsOptions` | options for what should be included |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
An object that breaks down the totals for the shipping method
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:159](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L159)
|
||||
|
||||
___
|
||||
|
||||
### getShippingTotal
|
||||
|
||||
▸ **getShippingTotal**(`cartOrOrder`): `number`
|
||||
|
||||
Calculates shipping total
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
shipping total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:267](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L267)
|
||||
|
||||
___
|
||||
|
||||
### getSubtotal
|
||||
|
||||
▸ **getSubtotal**(`cartOrOrder`, `opts?`): `number`
|
||||
|
||||
Calculates subtotal of a given cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for |
|
||||
| `opts` | `SubtotalOptions` | options |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:243](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L243)
|
||||
|
||||
___
|
||||
|
||||
### getSwapTotal
|
||||
|
||||
▸ **getSwapTotal**(`order`): `number`
|
||||
|
||||
The total paid for swaps. May be negative in case of negative swap
|
||||
difference.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to calculate swap total for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the swap total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:140](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L140)
|
||||
|
||||
___
|
||||
|
||||
### getTaxTotal
|
||||
|
||||
▸ **getTaxTotal**(`cartOrOrder`, `forceTaxes?`): `Promise`<``null`` \| `number`\>
|
||||
|
||||
Calculates tax total
|
||||
Currently based on the Danish tax system
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | `undefined` | cart or order to calculate tax total for |
|
||||
| `forceTaxes` | `boolean` | `false` | whether taxes should be calculated regardless of region settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `number`\>
|
||||
|
||||
tax total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:282](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L282)
|
||||
|
||||
___
|
||||
|
||||
### getTotal
|
||||
|
||||
▸ **getTotal**(`cartOrOrder`, `options?`): `Promise`<`number`\>
|
||||
|
||||
Calculates subtotal of a given cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Cart` \| `Order` | object to calculate total for |
|
||||
| `options` | `GetTotalsOptions` | options to calculate by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:106](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L106)
|
||||
|
||||
___
|
||||
|
||||
### rounded
|
||||
|
||||
▸ **rounded**(`value`): `number`
|
||||
|
||||
Rounds a number using Math.round.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `value` | `number` | the value to round |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the rounded value
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/totals.ts:922](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L922)
|
||||
@@ -0,0 +1,35 @@
|
||||
# Class: TransactionService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`TransactionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TransactionService**()
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/transaction.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/transaction.js#L5)
|
||||
|
||||
## Methods
|
||||
|
||||
### createSession
|
||||
|
||||
▸ **createSession**(): `Promise`<`ClientSession`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClientSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/transaction.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/transaction.js#L9)
|
||||
384
docs/content/references/services/classes/UserService.md
Normal file
384
docs/content/references/services/classes/UserService.md
Normal file
@@ -0,0 +1,384 @@
|
||||
# Class: UserService
|
||||
|
||||
Provides layer to manipulate users.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `"medusa-interfaces"`
|
||||
|
||||
↳ **`UserService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new UserService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `UserServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
BaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L36)
|
||||
|
||||
## Properties
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Private` **manager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:33](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Private` **transactionManager\_**: `EntityManager`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### userRepository\_
|
||||
|
||||
• `Private` **userRepository\_**: typeof `UserRepository`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `PASSWORD_RESET` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L27)
|
||||
|
||||
## Methods
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`user`, `password`): `Promise`<`User`\>
|
||||
|
||||
Creates a user with username being validated.
|
||||
Fails if email is not a valid format.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `user` | `CreateUserInput` | the user to create |
|
||||
| `password` | `string` | user's password to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L188)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`userId`): `Promise`<``null``\>
|
||||
|
||||
Deletes a user from a given user id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null``\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:257](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L257)
|
||||
|
||||
___
|
||||
|
||||
### generateResetPasswordToken
|
||||
|
||||
▸ **generateResetPasswordToken**(`userId`): `Promise`<`string`\>
|
||||
|
||||
Generate a JSON Web token, that will be sent to a user, that wishes to
|
||||
reset password.
|
||||
The token will be signed with the users current password hash as a secret
|
||||
a long side a payload with userId and the expiry time for the token, which
|
||||
is always 15 minutes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to reset password for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
the generated JSON web token
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:311](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L311)
|
||||
|
||||
___
|
||||
|
||||
### hashPassword\_
|
||||
|
||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||
|
||||
Hashes a password
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the value to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
hashed password
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:176](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L176)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`User`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableUserProps` | the query object for find |
|
||||
| `config` | `Object` | the configuration object for the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L88)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`userId`, `config?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by id.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to get. |
|
||||
| `config` | `FindConfig`<`User`\> | query configs |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:100](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByApiToken
|
||||
|
||||
▸ **retrieveByApiToken**(`apiToken`, `relations?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by api token.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `apiToken` | `string` | `undefined` | the token of the user to get. |
|
||||
| `relations` | `string`[] | `[]` | relations to include with the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:124](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L124)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByEmail
|
||||
|
||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by email.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user to get. |
|
||||
| `config` | `FindConfig`<`User`\> | query config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L152)
|
||||
|
||||
___
|
||||
|
||||
### setPassword\_
|
||||
|
||||
▸ **setPassword_**(`userId`, `password`): `Promise`<`User`\>
|
||||
|
||||
Sets a password for a user
|
||||
Fails if no user exists with userId and if the hashing of the new
|
||||
password does not work.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the userId to set password for |
|
||||
| `password` | `string` | the old password to set |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:282](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L282)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`userId`, `update`): `Promise`<`User`\>
|
||||
|
||||
Updates a user.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | id of the user to update |
|
||||
| `update` | `UpdateUserInput` | the values to be updated on the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:216](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L216)
|
||||
|
||||
___
|
||||
|
||||
### validateEmail\_
|
||||
|
||||
▸ **validateEmail_**(`email`): `string`
|
||||
|
||||
Used to validate user email.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | email to validate |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the validated email
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:70](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager`): [`UserService`](UserService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`UserService`](UserService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[services/user.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L49)
|
||||
Reference in New Issue
Block a user