Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: http client factory
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 12, 2020
1 parent 91cca19 commit 8ee0dc9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 35 deletions.
22 changes: 17 additions & 5 deletions test/integration/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { amazonMarketplaces } from '@scaleleap/amazon-marketplaces'
import { BaseConfig } from '@scaleleap/config'

import { HttpClient } from '../../src'

export class Config extends BaseConfig {
public readonly AWS_ACCESS_KEY_ID = this.get('AWS_ACCESS_KEY_ID').required().asString()
private readonly AWS_ACCESS_KEY_ID = this.get('AWS_ACCESS_KEY_ID').required().asString()

private readonly MWS_AUTH_TOKEN = this.get('MWS_AUTH_TOKEN').required().asString()

public readonly MWS_AUTH_TOKEN = this.get('MWS_AUTH_TOKEN').required().asString()
private readonly SECRET_KEY = this.get('SECRET_KEY').required().asString()

public readonly SECRET_KEY = this.get('SECRET_KEY').required().asString()
private readonly SELLER_ID = this.get('SELLER_ID').required().asString()

public readonly SELLER_ID = this.get('SELLER_ID').required().asString()
public createHttpClient() {
return new HttpClient({
marketplace: amazonMarketplaces.CA,
awsAccessKeyId: this.AWS_ACCESS_KEY_ID,
mwsAuthToken: this.MWS_AUTH_TOKEN,
secretKey: this.SECRET_KEY,
sellerId: this.SELLER_ID,
})
}
}
12 changes: 2 additions & 10 deletions test/integration/orders.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { amazonMarketplaces } from '@scaleleap/amazon-marketplaces'

import { HttpClient, Orders } from '../../src'
import { Orders } from '../../src'
import { Config } from './config'
import { itci } from './it'

const config = new Config()

const httpClient = new HttpClient({
marketplace: amazonMarketplaces.CA,
awsAccessKeyId: config.AWS_ACCESS_KEY_ID,
mwsAuthToken: config.MWS_AUTH_TOKEN,
secretKey: config.SECRET_KEY,
sellerId: config.SELLER_ID,
})
const httpClient = new Config().createHttpClient()

/* eslint-disable jest/no-standalone-expect */
describe(`${Orders.name}`, () => {
Expand Down
12 changes: 2 additions & 10 deletions test/integration/products.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { amazonMarketplaces } from '@scaleleap/amazon-marketplaces'

import { HttpClient, Products } from '../../src'
import { Products } from '../../src'
import { Config } from './config'
import { itci } from './it'

const config = new Config()

const httpClient = new HttpClient({
marketplace: amazonMarketplaces.CA,
awsAccessKeyId: config.AWS_ACCESS_KEY_ID,
mwsAuthToken: config.MWS_AUTH_TOKEN,
secretKey: config.SECRET_KEY,
sellerId: config.SELLER_ID,
})
const httpClient = new Config().createHttpClient()

/* eslint-disable jest/no-standalone-expect */
describe(`products`, () => {
Expand Down
12 changes: 2 additions & 10 deletions test/integration/sellers.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { amazonMarketplaces } from '@scaleleap/amazon-marketplaces'

import { HttpClient, Sellers } from '../../src'
import { Sellers } from '../../src'
import { Config } from './config'
import { itci } from './it'

const config = new Config()

const httpClient = new HttpClient({
marketplace: amazonMarketplaces.CA,
awsAccessKeyId: config.AWS_ACCESS_KEY_ID,
mwsAuthToken: config.MWS_AUTH_TOKEN,
secretKey: config.SECRET_KEY,
sellerId: config.SELLER_ID,
})
const httpClient = new Config().createHttpClient()

/* eslint-disable jest/no-standalone-expect */
describe(`${Sellers.name}`, () => {
Expand Down

0 comments on commit 8ee0dc9

Please sign in to comment.