Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/v2/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface OrdersMetaResponse {
export interface OrderFeatures {
moto: boolean
ecom: boolean
paylater: boolean
}
Comment thread
denis-shtupa-unzer marked this conversation as resolved.

export interface FeaturesResponse {
Expand All @@ -49,7 +50,7 @@ export interface FeaturesResponse {
msg?: string
}

export type KeypairProductType = 'ECOM' | 'MOTO' | 'POS'
export type KeypairProductType = 'ECOM' | 'MOTO' | 'POS' | 'PAYLATER'

export interface KeypairsQuery {
type?: KeypairProductType
Expand Down
7 changes: 4 additions & 3 deletions test/orders_v2/features.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ describe('v2: orders: can get features', () => {
msg: 'Success',
results: [{
moto: true,
ecom: false
ecom: false,
paylater: false
}]
}
]
Expand Down Expand Up @@ -77,10 +78,10 @@ describe('v2: orders: can get features', () => {
const { data, msg } = await ordersV2.features()
expect(data).toEqual({
msg: 'Success',
results: [{ moto: true, ecom: false }]
results: [{ moto: true, ecom: false, paylater: false }]
})
expect(msg).toBe('Success')
expect(data.results?.[0]).toEqual({ moto: true, ecom: false })
expect(data.results?.[0]).toEqual({ moto: true, ecom: false, paylater: false })
})

it('rejects on status codes that are not 200', async () => {
Expand Down
55 changes: 55 additions & 0 deletions test/orders_v2/keypairs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,59 @@ describe('v2: orders: can get keypairs', () => {
name: 'OrderKeypairsFetchFailed'
})
})

it('can get PAYLATER keypairs', async () => {
const paylaterKeypair = {
...keypair,
alias: 'PAYLATER key',
productType: 'PAYLATER'
}

if (process.env.SYSTEM_TEST !== 'true') {
mock.onPost('https://api.tillhub.com/api/v0/users/login').reply(() => {
return [
200,
{
token: '',
user: {
id: '123',
legacy_id: legacyId
}
}
]
})

mock.onGet(`https://api.tillhub.com/api/v2/orders/${legacyId}/keypairs?type=PAYLATER`).reply(() => {
return [
200,
{
count: 1,
msg: 'Success',
results: [paylaterKeypair]
}
]
})
}

const options = {
credentials: {
username: user.username,
password: user.password
},
base: process.env.TILLHUB_BASE
}

const th = new TillhubClient()

th.init(options)
await th.auth.loginUsername({
username: user.username,
password: user.password
})

const { data, msg, metadata } = await th.ordersV2().keypairs({ type: 'PAYLATER' })
expect(data).toEqual([paylaterKeypair])
expect(msg).toBe('Success')
expect(metadata.count).toBe(1)
})
})