Skip to content

Commit

Permalink
feat: add Selling Partner API regions
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarvovk authored and moltar committed Feb 17, 2021
1 parent 340594f commit 19b88dd
Show file tree
Hide file tree
Showing 26 changed files with 308 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/amazon-marketplace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AmazonMarketplaceAdvertisingRegion } from './amazon-marketplace-advertising-region'
import { AmazonSellingPartnerApiRegion } from './amazon-selling-partner-api-region'

/**
* Amazon Marketplace country code enum.
Expand Down Expand Up @@ -147,6 +148,13 @@ export interface AmazonAdvertisingBidLimits {
readonly max: number
}

export interface AmazonSellingPartner {
/**
* Amazon Selling Partner API Region
*/
readonly region: AmazonSellingPartnerApiRegion
}

export interface AmazonMarketplace {
/**
* Amazon Marketplace ID.
Expand Down Expand Up @@ -210,6 +218,11 @@ export interface AmazonMarketplace {
* [Amazon Advertising](https://advertising.amazon.com/API/docs/v2/guides/supported_features).
*/
readonly advertising?: AmazonMarketplaceAdvertising

/**
* [Amazon Selling Partner API](https://developer.amazonservices.com/).
*/
readonly sellingPartner?: AmazonSellingPartner
}

export class AmazonMarketplace implements AmazonMarketplace {
Expand Down
28 changes: 28 additions & 0 deletions src/amazon-selling-partner-api-region.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface AmazonSellingPartnerApiRegion {
/**
* Region code.
*/
code: string

/**
* Region name.
*/
name: string

/**
* Access endpoint URI.
*/
endpoint: string

/**
* AWS region.
*/
awsRegion: string
}

export class AmazonSellingPartnerApiRegion implements AmazonSellingPartnerApiRegion {
constructor(data: AmazonSellingPartnerApiRegion) {
Object.assign(this, data)
Object.freeze(this)
}
}
4 changes: 4 additions & 0 deletions src/marketplaces/ae.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const AE = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.AE,
Expand All @@ -29,4 +30,7 @@ export const AE = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.ASIA_DUBAI,
},
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/au.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const AU = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.AU,
Expand All @@ -29,4 +30,7 @@ export const AU = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.AUSTRALIA_SYDNEY,
},
sellingPartner: {
region: sellingPartnerRegions.FE,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const BR = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.BR,
Expand All @@ -29,4 +30,7 @@ export const BR = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.AMERICA_SAO_PAULO,
},
sellingPartner: {
region: sellingPartnerRegions.NA,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

/**
* Canada
Expand All @@ -32,4 +33,7 @@ export const CA = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.AMERICA_LOS_ANGELES,
},
sellingPartner: {
region: sellingPartnerRegions.NA,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { europeanAdvertisingFactory } from '../european-advertising-factory'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const DE = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.DE,
Expand All @@ -14,4 +15,7 @@ export const DE = new AmazonMarketplace({
uri: 'https://www.amazon.de',
webServiceUri: 'https://mws-eu.amazonservices.com',
advertising: europeanAdvertisingFactory(AmazonMarketplaceAdvertisingCountryCode.DE),
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { europeanAdvertisingFactory } from '../european-advertising-factory'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const ES = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.ES,
Expand All @@ -14,4 +15,7 @@ export const ES = new AmazonMarketplace({
uri: 'https://www.amazon.es',
webServiceUri: 'https://mws-eu.amazonservices.com',
advertising: europeanAdvertisingFactory(AmazonMarketplaceAdvertisingCountryCode.ES),
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { europeanAdvertisingFactory } from '../european-advertising-factory'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const FR = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.FR,
Expand All @@ -14,4 +15,7 @@ export const FR = new AmazonMarketplace({
uri: 'https://www.amazon.fr',
webServiceUri: 'https://mws-eu.amazonservices.com',
advertising: europeanAdvertisingFactory(AmazonMarketplaceAdvertisingCountryCode.FR),
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/gb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'
import { DE } from './de'

if (!DE.advertising) {
Expand Down Expand Up @@ -34,4 +35,7 @@ export const GB = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.EUROPE_LONDON,
},
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AmazonMarketplaceAdvertisingCurrency,
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const IN = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.IN,
Expand All @@ -11,4 +12,7 @@ export const IN = new AmazonMarketplace({
name: 'India',
uri: 'https://www.amazon.in',
webServiceUri: 'https://mws.amazonservices.in',
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { europeanAdvertisingFactory } from '../european-advertising-factory'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const IT = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.IT,
Expand All @@ -14,4 +15,7 @@ export const IT = new AmazonMarketplace({
uri: 'https://www.amazon.it',
webServiceUri: 'https://mws-eu.amazonservices.com',
advertising: europeanAdvertisingFactory(AmazonMarketplaceAdvertisingCountryCode.DE),
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/jp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const JP = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.JP,
Expand All @@ -29,4 +30,7 @@ export const JP = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.ASIA_TOKYO,
},
sellingPartner: {
region: sellingPartnerRegions.FE,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/mx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const MX = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.MX,
Expand All @@ -29,4 +30,7 @@ export const MX = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.AMERICA_LOS_ANGELES,
},
sellingPartner: {
region: sellingPartnerRegions.NA,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { europeanAdvertisingFactory } from '../european-advertising-factory'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'
import { DE } from './de'

export const NL = new AmazonMarketplace({
Expand All @@ -15,4 +16,7 @@ export const NL = new AmazonMarketplace({
uri: 'https://www.amazon.nl',
webServiceUri: DE.webServiceUri,
advertising: europeanAdvertisingFactory(AmazonMarketplaceAdvertisingCountryCode.NL),
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AmazonMarketplaceAdvertisingCurrency,
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const PL = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.PL,
Expand All @@ -11,4 +12,7 @@ export const PL = new AmazonMarketplace({
name: 'Poland',
uri: 'https://www.amazon.pl',
webServiceUri: 'https://mws-eu.amazonservices.com',
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/se.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AmazonMarketplaceAdvertisingCurrency,
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const SE = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.SE,
Expand All @@ -11,4 +12,7 @@ export const SE = new AmazonMarketplace({
name: 'Sweden',
uri: 'https://www.amazon.se',
webServiceUri: 'https://mws-eu.amazonservices.com',
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/sg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AmazonMarketplaceAdvertisingCurrency,
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const SG = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.SG,
Expand All @@ -11,4 +12,7 @@ export const SG = new AmazonMarketplace({
name: 'Singapore',
uri: 'https://www.amazon.sg',
webServiceUri: 'https://mws-fe.amazonservices.com',
sellingPartner: {
region: sellingPartnerRegions.FE,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AmazonMarketplaceAdvertisingCurrency,
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const TR = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.TR,
Expand All @@ -11,4 +12,7 @@ export const TR = new AmazonMarketplace({
name: 'Turkey',
uri: 'https://www.amazon.com.tr',
webServiceUri: 'https://mws-eu.amazonservices.com',
sellingPartner: {
region: sellingPartnerRegions.EU,
},
})
4 changes: 4 additions & 0 deletions src/marketplaces/us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AmazonMarketplaceCountryCode,
} from '../amazon-marketplace'
import { marketplaceAdvertisingRegions } from '../marketplace-advertising-regions'
import { sellingPartnerRegions } from '../selling-partner-api-regions/index'

export const US = new AmazonMarketplace({
countryCode: AmazonMarketplaceCountryCode.US,
Expand All @@ -29,4 +30,7 @@ export const US = new AmazonMarketplace({
},
timeZone: AmazonMarketplaceAdvertisingTimeZone.AMERICA_LOS_ANGELES,
},
sellingPartner: {
region: sellingPartnerRegions.NA,
},
})
8 changes: 8 additions & 0 deletions src/selling-partner-api-regions/eu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AmazonSellingPartnerApiRegion } from '../amazon-selling-partner-api-region'

export const EU = new AmazonSellingPartnerApiRegion({
code: 'EU',
endpoint: 'https://sellingpartnerapi-eu.amazon.com',
name: 'Europe',
awsRegion: 'eu-west-1',
})
8 changes: 8 additions & 0 deletions src/selling-partner-api-regions/fe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AmazonSellingPartnerApiRegion } from '../amazon-selling-partner-api-region'

export const FE = new AmazonSellingPartnerApiRegion({
code: 'FE',
endpoint: 'https://sellingpartnerapi-fe.amazon.com',
name: 'Far East',
awsRegion: 'us-west-2',
})
9 changes: 9 additions & 0 deletions src/selling-partner-api-regions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EU } from './eu'
import { FE } from './fe'
import { NA } from './na'

export const sellingPartnerRegions = {
EU,
FE,
NA,
} as const
8 changes: 8 additions & 0 deletions src/selling-partner-api-regions/na.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AmazonSellingPartnerApiRegion } from '../amazon-selling-partner-api-region'

export const NA = new AmazonSellingPartnerApiRegion({
code: 'NA',
endpoint: 'https://sellingpartnerapi-na.amazon.com',
name: 'North America',
awsRegion: 'us-east-1',
})
Loading

0 comments on commit 19b88dd

Please sign in to comment.