RegionService
Provides layer to manipulate regions.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>featureFlagRouter_
FlagRouterRequiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "region.created"
Events.DELETED
stringRequiredDefault: "region.deleted"
Events.UPDATED
stringRequiredDefault: "region.updated"
Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
addCountry
Adds a country to the region.
Parameters
regionId
stringRequiredcode
stringRequiredReturns
addFulfillmentProvider
Adds a fulfillment provider that is available in the region. Fails if the provider doesn't exist.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
addPaymentProvider
Adds a payment provider that is available in the region. Fails if the provider doesn't exist.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
atomicPhase_
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
delete
Deletes a region.
Parameters
regionId
stringRequiredReturns
Promise
Promise<void>Requiredlist
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
removeCountry
Removes a country from a Region.
Parameters
regionId
stringRequiredcode
stringRequiredReturns
removeFulfillmentProvider
Removes a fulfillment provider from a region. Is idempotent.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
removePaymentProvider
Removes a payment provider from a region. Is idempotent.
Parameters
regionId
stringRequiredproviderId
stringRequiredReturns
retrieve
Retrieves a region by its id.
Parameters
regionId
stringRequiredDefault: {}
Returns
retrieveByCountryCode
Retrieve a region by country code.
Parameters
code
stringRequiredDefault: {}
Returns
retrieveByName
Retrieves a region by name.
Parameters
name
stringRequiredReturns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanupdate
Updates a region
Parameters
regionId
stringRequiredupdate
UpdateRegionInputRequiredReturns
validateCountry
Validates a country code. Will normalize the code before checking for existence.
Parameters
code
stringRequiredregionId
stringRequiredReturns
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
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
voidThrows
if the tax rate isn't number between 0-100
withTransaction
Parameters
transactionManager
EntityManagerReturns
RegionService
objectRequired