Skip to content

Commit 54c6638

Browse files
authored
Merge pull request #10 from samudary/fix/batch-url
Fix batch request URL
2 parents 96b44db + ad8a52b commit 54c6638

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

lib/subscribers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104
batches.forEach((batch, batchIndex) => {
105105
request.post(
106106
{
107-
url: `${this.accountId}/subscribers/batches`,
107+
url: `${helpers.baseUrl}${this.accountId}/subscribers/batches`,
108108
headers,
109109
json: true,
110110
body: {

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = '0.2.0';
1+
module.exports = '0.2.1';

spec/lib/subscribers_spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,45 @@ describe('Subscribers with callback', () => {
119119
});
120120
});
121121

122+
describe('batch request URL', () => {
123+
const payload = {
124+
batches: [{
125+
subscribers: new Array(1)
126+
}]
127+
};
128+
129+
beforeEach(() => {
130+
sinon.stub(request, 'post')
131+
.yields(null, { statusCode: 201 }, {});
132+
spyOn(request, 'post').and.callThrough();
133+
});
134+
135+
afterEach(() => {
136+
request.post.restore();
137+
});
138+
139+
it('should set the correct request URL', (done) => {
140+
client.updateBatchSubscribers(payload, (errors, responses, bodies) => {
141+
expect(errors).toBe(null);
142+
expect(responses.length).toBe(1);
143+
expect(responses[0].statusCode).toBe(201);
144+
expect(bodies).toEqual([{}]);
145+
});
146+
done();
147+
148+
expect(request.post).toHaveBeenCalledWith({
149+
url: 'https://api.getdrip.com/v2/9999999/subscribers/batches',
150+
headers: client.requestHeaders(),
151+
json: true,
152+
body: {
153+
batches: [{
154+
subscribers: [undefined]
155+
}]
156+
}
157+
}, jasmine.any(Function));
158+
});
159+
});
160+
122161
describe('Subscribers with promise', () => {
123162
const expectedResponse = {
124163
statusCode: 200,

0 commit comments

Comments
 (0)