Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Commit fe0b780

Browse files
committed
feat: implement getBrands method
1 parent 99bbf24 commit fe0b780

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

src/operations/profiles/profile-operation.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ProfileResponse,
77
RegisterProfileResponse,
88
ProfileRegistrationResponse,
9+
Brand,
910
} from './types'
1011
import { Decode, DecodeArray } from '../../decorators'
1112
import { AmazonMarketplaceAdvertisingCountryCodeType } from '../commons/types'
@@ -80,4 +81,16 @@ export class ProfileOperation extends Operation {
8081
registerBrand,
8182
)
8283
}
84+
85+
/**
86+
* Gets an array of Brand data objects for the Brand associated with the profile ID passed in the header.
87+
* For more information about Brands, see Brand Services.
88+
*
89+
* @returns
90+
* @memberof ProfileOperation
91+
*/
92+
@DecodeArray(Brand)
93+
public getBrands() {
94+
return this.client.get<Brand[]>(`${this.version}/brands`)
95+
}
8396
}

src/operations/profiles/types.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,15 @@ describe('ProfileRegistrationResponse', () => {
7777
expect(isRight(res)).toBeFalsy()
7878
})
7979
})
80+
81+
describe('Brand', () => {
82+
it('should pass', () => {
83+
const res = t.Brand.decode({
84+
brandId: 'string',
85+
brandEntityId: 'string',
86+
brandRegistryName: 'string',
87+
})
88+
89+
expect(isRight(res)).toBeTruthy()
90+
})
91+
})

src/operations/profiles/types.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,21 @@ export const RegisterProfileResponse = t.intersection([
156156
])
157157

158158
export type RegisterProfileResponse = t.TypeOf<typeof RegisterProfileResponse>
159+
160+
export const Brand = t.strict({
161+
/**
162+
* The Brand identifier.
163+
*/
164+
brandId: t.string,
165+
166+
/**
167+
* The Brand entity identifier.
168+
*/
169+
brandEntityId: t.string,
170+
171+
/**
172+
* The Brand name.
173+
*/
174+
brandRegistryName: t.string,
175+
})
176+
export type Brand = t.TypeOf<typeof Brand>

test/operations/profiles/profile-operation.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,17 @@ describe('ProfileOperation', () => {
8080
expect(res.code).toBe(RegisterProfileResponseStatusEnum.SUCCESS)
8181
})
8282
})
83+
84+
/**
85+
* TODO: Need check again on Production API. Sandbox API return an error:
86+
* ResourceNotFoundError: Could not find resource for full path: https://advertising-api-test.amazon.com/v2/brands
87+
*/
88+
describe.skip('getBrands', () => {
89+
it(`should return an array of brands`, async () => {
90+
const [brand] = await profileOperation.getBrands()
91+
92+
expect(brand.brandId).toBe('2973802954634317')
93+
expect(brand.brandRegistryName).toBe('yay')
94+
})
95+
})
8396
})

0 commit comments

Comments
 (0)