-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for cursor pagination to supported endpoints (#81)
Signed-off-by: Bruno Vieira <[email protected]>
- Loading branch information
Bruno Vieira
authored
Oct 24, 2023
1 parent
e6be205
commit 153a885
Showing
17 changed files
with
723 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog], | ||
and this project adheres to [Semantic Versioning]. | ||
|
||
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ | ||
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html | ||
|
||
## [2.1.2] - 2023-10-05 | ||
|
||
### Added | ||
- Support for cursor based pagination to `.all()` endpoints. |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -71,7 +71,7 @@ describe('Contact', () => { | |
customer_external_id: 'external_001', | ||
email: '[email protected]' | ||
}], | ||
cursor: 'MjAyMy0wMy0xM1QxMjowMTozMi44MDYxODYwMDArMDk6MDAmY29uXzAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA==', | ||
cursor: 'MjAyMy0wMy0xM1QxMjowMTozMi44MD==', | ||
has_more: false | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
@@ -80,8 +80,8 @@ describe('Contact', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res).to.have.property('cursor'); | ||
expect(res).to.have.property('has_more'); | ||
expect(res.cursor).to.eql('MjAyMy0wMy0xM1QxMjowMTozMi44MD=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
|
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 |
---|---|---|
|
@@ -42,12 +42,44 @@ describe('Customer', () => { | |
}); | ||
}); | ||
|
||
it('should get all customers', () => { | ||
it('should get all customers with old pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
customers: [{ | ||
entries: [{ | ||
uuid: 'cus_7e4e5c3d-832c-4fa4-bf77-6fdc8c6e14bc', | ||
external_id: 'cus_0001', | ||
name: 'Adam Smith', | ||
company: '', | ||
email: '[email protected]', | ||
city: 'New York', | ||
state: '', | ||
country: 'US', | ||
zip: '', | ||
data_source_uuid: 'ds_e243129a-12c0-4e29-8f54-07da7905fbd1' | ||
}], | ||
current_page: 1, | ||
total_pages: 1, | ||
page: 1 | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.all(config) | ||
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.page).to.eql(1); | ||
expect(res.total_pages).to.eql(1); | ||
}); | ||
}); | ||
|
||
it('should get all customers with new pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
entries: [{ | ||
uuid: 'cus_7e4e5c3d-832c-4fa4-bf77-6fdc8c6e14bc', | ||
external_id: 'cus_0001', | ||
name: 'Adam Smith', | ||
|
@@ -58,14 +90,18 @@ describe('Customer', () => { | |
country: 'US', | ||
zip: '', | ||
data_source_uuid: 'ds_e243129a-12c0-4e29-8f54-07da7905fbd1' | ||
}] | ||
}], | ||
cursor: 'MjAyMy0wMy0xM1QxMjowMTozMi44MD==', | ||
has_more: false | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.all(config) | ||
.then(res => { | ||
expect(res).to.have.property('customers'); | ||
expect(res.customers).to.be.instanceof(Array); | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql('MjAyMy0wMy0xM1QxMjowMTozMi44MD=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
|
@@ -145,7 +181,7 @@ describe('Customer', () => { | |
customer_external_id: 'external_001', | ||
email: '[email protected]' | ||
}], | ||
cursor: 'MjAyMy0wMy0xM1QxMjowMTozMi44MDYxODYwMDArMDk6MDAmY29uXzAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA==', | ||
cursor: 'MjAyMy0wMy0xM1QxMjowMTozMi44MD==', | ||
has_more: false | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
@@ -154,6 +190,8 @@ describe('Customer', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql('MjAyMy0wMy0xM1QxMjowMTozMi44MD=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
}); | ||
|
@@ -201,7 +239,7 @@ describe('Enrichment#Customer', () => { | |
}); | ||
}); | ||
|
||
it('should get all customers', () => { | ||
it('should get all customers with old pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
|
@@ -217,10 +255,31 @@ describe('Enrichment#Customer', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.page).to.eql(1); | ||
}); | ||
}); | ||
|
||
it('should search for a customer', () => { | ||
it('should get all customers with new pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
entries: [], | ||
has_more: false, | ||
cursor: null | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.all(config) | ||
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql(null); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
it('should search for a customer with old pagination', () => { | ||
const email = '[email protected]'; | ||
|
||
nock(config.API_BASE) | ||
|
@@ -243,6 +302,34 @@ describe('Enrichment#Customer', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.page).to.eql(1); | ||
}); | ||
}); | ||
|
||
it('should search for a customer with new pagination', () => { | ||
const email = '[email protected]'; | ||
|
||
nock(config.API_BASE) | ||
.get('/v1/customers/search') | ||
.query({ | ||
}) | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
entries: [], | ||
has_more: false, | ||
cursor: 'JjI3MjI4NTM==' | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.search(config, { | ||
}) | ||
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql('JjI3MjI4NTM=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
|
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 |
---|---|---|
|
@@ -48,7 +48,7 @@ describe('DeprecatedEnrichment#Customer', () => { | |
}); | ||
}); | ||
|
||
it('should get all customers', () => { | ||
it('should get all customers with old pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
|
@@ -64,10 +64,31 @@ describe('DeprecatedEnrichment#Customer', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.page).to.eql(1); | ||
}); | ||
}); | ||
|
||
it('should search for a customer', () => { | ||
it('should get all customers with new pagination', () => { | ||
nock(config.API_BASE) | ||
.get('/v1/customers') | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
entries: [], | ||
has_more: false, | ||
cursor: 'cursor==' | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.all(config) | ||
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql('cursor=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
it('should search for a customer with old pagination', () => { | ||
const email = '[email protected]'; | ||
|
||
nock(config.API_BASE) | ||
|
@@ -90,6 +111,34 @@ describe('DeprecatedEnrichment#Customer', () => { | |
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.page).to.eql(1); | ||
}); | ||
}); | ||
|
||
it('should search for a customer with new pagination', () => { | ||
const email = '[email protected]'; | ||
|
||
nock(config.API_BASE) | ||
.get('/v1/customers/search') | ||
.query({ | ||
}) | ||
.reply(200, { | ||
/* eslint-disable camelcase */ | ||
entries: [], | ||
has_more: false, | ||
cursor: 'cursor==' | ||
/* eslint-enable camelcase */ | ||
}); | ||
|
||
return Customer.search(config, { | ||
}) | ||
.then(res => { | ||
expect(res).to.have.property('entries'); | ||
expect(res.entries).to.be.instanceof(Array); | ||
expect(res.cursor).to.eql('cursor=='); | ||
expect(res.has_more).to.eql(false); | ||
}); | ||
}); | ||
|
||
|
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
Oops, something went wrong.