Skip to content

Commit

Permalink
fix(segment): require limit param in listContacts
Browse files Browse the repository at this point in the history
The parameter is required in the API and should be so in the SDK as
well.
  • Loading branch information
jpersson committed Nov 12, 2015
1 parent a5f7c3c commit 1424bc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ In the example above, the API will be called with `customerId = 20234245`.

suiteAPI.segment.listContacts(payload);

##### List contacts
##### List segments

suiteAPI.segment.listSegments(payload);

Expand Down
2 changes: 1 addition & 1 deletion api/endpoints/segment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ util.inherits(Segment, Base);
_.extend(Segment.prototype, {

listContacts: function(payload, options) {
return this._requireParameters(payload, ['segment_id']).then(function() {
return this._requireParameters(payload, ['segment_id', 'limit']).then(function() {
var url = util.format('/filter/%s/contacts', payload.segment_id);
logger.log('segment_list_contacts');

Expand Down
9 changes: 6 additions & 3 deletions api/endpoints/segment/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ describe('SuiteAPI Segment endpoint', function() {

describe('#listContacts', function() {
testApiMethod(SegmentAPI, 'listContacts').withArgs({
segment_id: 10
}).shouldGetResultFromEndpoint('/filter/10/contacts');
segment_id: 10,
limit: 100
}).shouldGetResultFromEndpoint('/filter/10/contacts/?limit=100');

testApiMethod(SegmentAPI, 'listContacts').withArgs({
segment_id: 10,
limit: 100,
offset: 0
}).shouldGetResultFromEndpoint('/filter/10/contacts/?limit=100&offset=0');

testApiMethod(SegmentAPI, 'listContacts').withArgs({}).shouldThrowMissingParameterError('segment_id');
testApiMethod(SegmentAPI, 'listContacts').withArgs({ limit: 100 }).shouldThrowMissingParameterError('segment_id');

testApiMethod(SegmentAPI, 'listContacts').withArgs({ segment_id: 10 }).shouldThrowMissingParameterError('limit');
});

});

0 comments on commit 1424bc6

Please sign in to comment.