RegionService
Provides layer to manipulate regions.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.UPDATED
stringRequiredDefault: "region.updated"
Events.CREATED
stringRequiredDefault: "region.created"
Events.DELETED
stringRequiredDefault: "region.deleted"
featureFlagRouter_
FlagRouterRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type Parameters
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredcreate
Creates a region.
Parameters
data
CreateRegionInputRequiredReturns
update
Updates a region
Parameters
regionId
stringRequiredupdate
UpdateRegionInputRequiredReturns
validateFields
Validates fields for creation and updates. If the region already exists the id can be passed to check that country updates are allowed.
Type Parameters
T
UpdateRegionInput | CreateRegionInputRequiredParameters
regionData
Omit<T, "metadata" | "currency_code">Requiredid
T extends UpdateRegionInput ? string : undefinedReturns
validateTaxRate
Validates a tax rate. Will throw if the tax rate is not between 0 and 1.
Parameters
taxRate
numberRequiredReturns
void
voidRequiredThrows
if the tax rate isn't number between 0-100
validateCurrency
Validates a currency code. Will throw if the currency code doesn't exist.
Parameters
currencyCode
stringRequiredReturns
Promise
Promise<void>RequiredThrows
if the provided currency code is invalid
validateCountry
Validates a country code. Will normalize the code before checking for existence.
Parameters
code
stringRequiredregionId
stringRequiredReturns
retrieveByCountryCode
Retrieve a region by country code.
Parameters
code
stringRequiredDefault: {}
Returns
retrieveByName
Retrieves a region by name.
Parameters
name
stringRequiredReturns
retrieve
Retrieves a region by its id.
Parameters
regionId
stringRequiredDefault: {}
Returns
list
Lists all regions based on a query
Parameters
Default: {}
Returns
listAndCount
Lists all regions based on a query and returns them along with count
Parameters
Default: {}
Returns
delete
Deletes a region.
Parameters
regionId
stringRequiredReturns
Promise
Promise<void>RequiredaddCountry
Adds a country to the region.
Parameters
regionId
stringRequiredcode
stringRequiredReturns
removeCountry
Removes a country from a Region.
Parameters
regionId
stringRequiredcode
stringRequiredReturns
addPaymentProvider
Adds a payment provider that is available in the region. Fails if the provider doesn't exist.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
addFulfillmentProvider
Adds a fulfillment provider that is available in the region. Fails if the provider doesn't exist.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
removePaymentProvider
Removes a payment provider from a region. Is idempotent.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
removeFulfillmentProvider
Removes a fulfillment provider from a region. Is idempotent.
Parameters
regionId
stringRequiredproviderId
stringRequired