Skip to content

Commit

Permalink
feat: add header X-Meli-Session-Id
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagostinho-meli committed Dec 4, 2024
1 parent 7bc9189 commit 218fce6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Add `X-Expand-Response-Nodes` header to request options
- Add `X-Card-Validation` header to request options
- Add `X-Meli-Session-Id` header to request options

## VERSION 2.0.15

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export declare type Options = {
plataformId?: string;
integratorId?: string;
corporationId?: string;
meliSessionId?: string;
expandResponseNodes?: string;
cardValidation?: string;
};
Expand Down
1 change: 1 addition & 0 deletions src/utils/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class AppConfig {
CORPORATION_ID: 'X-Corporation-Id',
INTEGRATOR_ID: 'X-Integrator-Id',
PLATFORM_ID: 'X-Platform-Id',
MELI_SESSION_ID: 'X-Meli-Session-Id',
EXPAND_RESPONSE_NODES: 'X-Expand-Response-Nodes',
CARD_VALIDATION: 'X-Card-Validation',
};
Expand Down
2 changes: 2 additions & 0 deletions src/utils/restClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class RestClient {
corporationId,
integratorId,
plataformId,
meliSessionId,
expandResponseNodes,
cardValidation,
...customConfig
Expand All @@ -81,6 +82,7 @@ class RestClient {
...(corporationId ? { [AppConfig.Headers.CORPORATION_ID]: corporationId } : {}),
...(integratorId ? { [AppConfig.Headers.INTEGRATOR_ID]: integratorId } : {}),
...(plataformId ? { [AppConfig.Headers.PLATFORM_ID]: plataformId } : {}),
...(meliSessionId ? { [AppConfig.Headers.MELI_SESSION_ID]: meliSessionId } : {}),
...(expandResponseNodes ? { [AppConfig.Headers.EXPAND_RESPONSE_NODES]: expandResponseNodes } : {}),
...(cardValidation ? { [AppConfig.Headers.CARD_VALIDATION]: cardValidation } : {}),
};
Expand Down
2 changes: 2 additions & 0 deletions src/utils/restClient/restClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('RestClient', () => {
headers: customHeaders,
expandResponseNodes: 'gateway.reference',
cardValidation: 'card_validation',
meliSessionId: 'device_id',
});

expect(fetch).toHaveBeenCalledWith(expect.any(String), {
Expand All @@ -118,6 +119,7 @@ describe('RestClient', () => {
'User-Agent': expect.any(String),
'X-Product-Id': expect.any(String),
'X-Tracking-Id': expect.any(String),
'X-Meli-Session-Id': 'device_id',
'X-Expand-Response-Nodes': 'gateway.reference',
'X-Card-Validation': 'card_validation',
},
Expand Down

0 comments on commit 218fce6

Please sign in to comment.