Skip to main content

Class: RegionService

Provides layer to manipulate regions.

Hierarchy

  • "medusa-interfaces"

    RegionService

Constructors

constructor

new RegionService(__namedParameters)

Parameters

NameType
__namedParametersObject

Overrides

BaseService.constructor

Defined in

services/region.js:16

Properties

Events

Static Events: Object

Type declaration

NameType
CREATEDstring
DELETEDstring
UPDATEDstring

Defined in

services/region.js:10

Methods

addCountry

addCountry(regionId, code): Promise<any>

Adds a country to the region.

Parameters

NameTypeDescription
regionIdstringthe region to add a country to
codestringa 2 digit alphanumeric ISO country code.

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:460


addFulfillmentProvider

addFulfillmentProvider(regionId, providerId): Promise<any>

Adds a fulfillment provider that is available in the region. Fails if the provider doesn't exist.

Parameters

NameTypeDescription
regionIdstringthe region to add the provider to
providerIdstringthe provider to add to the region

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:580


addPaymentProvider

addPaymentProvider(regionId, providerId): Promise<any>

Adds a payment provider that is available in the region. Fails if the provider doesn't exist.

Parameters

NameTypeDescription
regionIdstringthe region to add the provider to
providerIdstringthe provider to add to the region

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:533


create

create(regionObject): Region

Creates a region.

Parameters

NameTypeDescription
regionObjectRegionthe unvalidated region

Returns

Region

the newly created region

Defined in

services/region.js:95


delete

delete(regionId): Promise<any>

Deletes a region.

Parameters

NameTypeDescription
regionIdstringthe region to delete

Returns

Promise<any>

the result of the delete operation

Defined in

services/region.js:430


list

list(selector?, config?): Promise<any>

Lists all regions based on a query

Parameters

NameTypeDescription
selectoranyquery object for find
configanyconfiguration settings

Returns

Promise<any>

result of the find operation

Defined in

services/region.js:418


removeCountry

removeCountry(regionId, code): Promise<any>

Removes a country from a Region

Parameters

NameTypeDescription
regionIdstringthe region to remove from
codestringa 2 digit alphanumeric ISO country code to remove

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:497


removeFulfillmentProvider

removeFulfillmentProvider(regionId, providerId): Promise<any>

Removes a fulfillment provider from a region. Is idempotent.

Parameters

NameTypeDescription
regionIdstringthe region to remove the provider from
providerIdstringthe provider to remove from the region

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:658


removePaymentProvider

removePaymentProvider(regionId, providerId): Promise<any>

Removes a payment provider from a region. Is idempotent.

Parameters

NameTypeDescription
regionIdstringthe region to remove the provider from
providerIdstringthe provider to remove from the region

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:624


retrieve

retrieve(regionId, config?): Region

Retrieves a region by its id.

Parameters

NameTypeDescription
regionIdstringthe id of the region to retrieve
configanyconfiguration settings

Returns

Region

the region

Defined in

services/region.js:394


retrieveByCountryCode

retrieveByCountryCode(code, config?): Promise<Region>

Parameters

NameType
codeany
configObject

Returns

Promise<Region>

Defined in

services/region.js:360


update

update(regionId, update): Promise<any>

Updates a region

Parameters

NameTypeDescription
regionIdstringthe region to update
updateanythe data to update the region with

Returns

Promise<any>

the result of the update operation

Defined in

services/region.js:153


validateCountry_

validateCountry_(code, regionId): Promise<any>

Validates a country code. Will normalize the code before checking for existence.

Parameters

NameTypeDescription
codestringa 2 digit alphanumeric ISO country code
regionIdstringthe id of the current region to check against

Returns

Promise<any>

Defined in

services/region.js:323


validateCurrency_

validateCurrency_(currencyCode): Promise<void>

Validates a currency code. Will throw if the currency code doesn't exist.

Parameters

NameTypeDescription
currencyCodestringan ISO currency code

Returns

Promise<void>

Defined in

services/region.js:302


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

NameTypeDefault valueDescription
regionanyundefinedthe region data to validate
idnull | stringundefinedoptional id of the region to check against

Returns

any

the validated region data

Defined in

services/region.js:213


validateTaxRate_

validateTaxRate_(taxRate): void

Validates a tax rate. Will throw if the tax rate is not between 0 and 1.

Parameters

NameTypeDescription
taxRatenumbera number representing the tax rate of the region

Returns

void

Defined in

services/region.js:289


withTransaction

withTransaction(transactionManager): RegionService

Parameters

NameType
transactionManagerany

Returns

RegionService

Defined in

services/region.js:65