-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add stays loyalty programmes resource (#937)
- Loading branch information
1 parent
a033b25
commit 6f6d178
Showing
7 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import nock from 'nock' | ||
import { Duffel } from '../../index' | ||
import { MOCK_LOYALTY_PROGRAMMES } from '../mocks' | ||
|
||
const duffel = new Duffel({ token: 'mockToken' }) | ||
describe('Stays/LoyaltyProgrammes', () => { | ||
afterEach(() => { | ||
nock.cleanAll() | ||
}) | ||
|
||
it('should send a get to /stays/loyalty_programmes when `list` is called', async () => { | ||
const mockResponse = { data: MOCK_LOYALTY_PROGRAMMES } | ||
|
||
nock(/(.*)/).get('/stays/loyalty_programmes').reply(200, mockResponse) | ||
|
||
const response = await duffel.stays.loyaltyProgrammes.list() | ||
|
||
expect(response.data).toEqual(mockResponse.data) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Client } from '../../Client' | ||
import { StaysLoyaltyProgramme } from '../StaysTypes' | ||
import { Resource } from '../../Resource' | ||
import { DuffelResponse } from '../../types' | ||
|
||
export class LoyaltyProgrammes extends Resource { | ||
/** | ||
* Endpoint path | ||
*/ | ||
path: string | ||
|
||
constructor(client: Client) { | ||
super(client) | ||
this.path = 'stays/loyalty_programmes' | ||
} | ||
|
||
/** | ||
* List all the loyalty programmes supported by Duffel Stays | ||
*/ | ||
public list = async (): Promise<DuffelResponse<StaysLoyaltyProgramme[]>> => | ||
this.request({ | ||
method: 'GET', | ||
path: this.path, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './LoyaltyProgrammes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters