-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: customer app endpoints, types and errors (#18)
- Loading branch information
Showing
27 changed files
with
1,031 additions
and
38 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,13 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/contests', | ||
|
||
create: aifiMethod({ | ||
method: 'POST', | ||
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,23 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/customers', | ||
|
||
create: aifiMethod({ | ||
method: 'POST', | ||
path: '', | ||
}), | ||
|
||
retrieve: aifiMethod({ | ||
method: 'GET', | ||
path: '/me', | ||
}), | ||
|
||
update: aifiMethod({ | ||
method: 'PATCH', | ||
path: '/me', | ||
}), | ||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/entry-codes', | ||
|
||
create: aifiMethod({ | ||
method: 'POST', | ||
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,33 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/orders', | ||
|
||
list: aifiMethod({ | ||
method: 'GET', | ||
path: '', | ||
}), | ||
|
||
retrieve: aifiMethod({ | ||
method: 'GET', | ||
path: '/{orderId}', | ||
}), | ||
|
||
payment: aifiMethod({ | ||
method: 'POST', | ||
path: '/{orderId}/payment', | ||
}), | ||
|
||
listDrafts: aifiMethod({ | ||
method: 'GET', | ||
path: 'draft', | ||
}), | ||
|
||
retreiveDraft: aifiMethod({ | ||
method: 'POST', | ||
path: '/draft/{draftOrderID}', | ||
}), | ||
}); |
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,23 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/password-reset', | ||
|
||
reset: aifiMethod({ | ||
method: 'POST', | ||
path: '', | ||
}), | ||
|
||
set: aifiMethod({ | ||
method: 'PATCH', | ||
path: '', | ||
}), | ||
|
||
verify: aifiMethod({ | ||
method: 'POST', | ||
path: '/verify', | ||
}), | ||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/payments', | ||
|
||
create: aifiMethod({ | ||
method: 'GET', | ||
path: '/methods/initialize', | ||
}), | ||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/products', | ||
|
||
search: aifiMethod({ | ||
method: 'GET', | ||
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,23 @@ | ||
'use strict'; | ||
|
||
const AifiResource = require('../../AifiResource'); | ||
const aifiMethod = AifiResource.method; | ||
|
||
module.exports = AifiResource.extend({ | ||
path: 'customer/v2/sessions', | ||
|
||
login: aifiMethod({ | ||
method: 'POST', | ||
path: '', | ||
}), | ||
|
||
logout: aifiMethod({ | ||
method: 'DELETE', | ||
path: '/{customerId}', | ||
}), | ||
|
||
refresh: aifiMethod({ | ||
method: 'POST', | ||
path: '/refresh', | ||
}), | ||
}); |
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,30 @@ | ||
'use strict'; | ||
|
||
const aifi = require('../../../testUtils').getSpyableAifi(); | ||
|
||
const expect = require('chai').expect; | ||
|
||
describe('Customer', () => { | ||
describe('Contests Resource', () => { | ||
describe('create', () => { | ||
it('Sends the correct request', () => { | ||
aifi.customer.contests.create({ | ||
productId: '1', | ||
quantity: 1, | ||
items: [], | ||
}); | ||
expect(aifi.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/api/customer/v2/contests', | ||
headers: {}, | ||
data: { | ||
productId: '1', | ||
quantity: 1, | ||
items: [], | ||
}, | ||
settings: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
declare module 'aifi' { | ||
namespace Aifi { | ||
namespace Customer { | ||
interface ContestCreateParams { | ||
/** | ||
* The order id to be contested | ||
*/ | ||
orderId: string; | ||
|
||
/** | ||
* The customer's email address. | ||
*/ | ||
message: string; | ||
|
||
/** | ||
* Items array | ||
*/ | ||
items: Aifi.Models.ContestItem[]; | ||
} | ||
|
||
class ContestsResource { | ||
/** | ||
* Retrieves an auth token. | ||
*/ | ||
create( | ||
params: ContestCreateParams, | ||
options?: RequestOptions | ||
): Promise< | ||
Aifi.Response<Aifi.Models.ContestItem[] | Aifi.Models.Error> | ||
>; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.