Skip to content

Commit

Permalink
[sc-62681] SDK Unmerge Support - Node (#106)
Browse files Browse the repository at this point in the history
* Support unmerge endpoint.

* Update docs.
  • Loading branch information
jessicahearn authored Oct 24, 2024
1 parent 66af6d7 commit 39d441b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ ChartMogul.Customer.merge(config, {
'from': {'customer_uuid': 'cus_5915ee5a-babd-406b-b8ce-d207133fb4cb'},
'into': {'customer_uuid': 'cus_2123290f-09c8-4628-a205-db5596bd58f7'}
})
ChartMogul.Customer.unmerge(config, {
'customer_uuid': 'cus_cd9e5f29-6299-40e5-b343-0bd1ed228b4f',
'data_source_uuid': 'ds_788ec6ae-dd51-11ee-bd46-a3ec952dc041',
'external_id': 'cus_O075O8NH0LrtG8',
'move_to_new_customer': []
})

ChartMogul.Customer.contacts(config, customerUuid, { per_page: 10, cursor: 'cursor==' })
ChartMogul.Customer.createContact(config, customerUuid, data)
Expand Down
2 changes: 2 additions & 0 deletions lib/chartmogul/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Customer.modify = Resource._method('PATCH', '/v1/customers/{customerUuid}');

Customer.merge = Resource._method('POST', '/v1/customers/merges');

Customer.unmerge = Resource._method('POST', '/v1/customers/unmerges');

Customer.connectSubscriptions = Resource._method('POST', '/v1/customers/{customerUuid}/connect_subscriptions');

module.exports = Customer;
21 changes: 21 additions & 0 deletions test/chartmogul/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,27 @@ describe('Enrichment#Customer', () => {
});
});

it('should unmerge customers', () => {
/* eslint-disable camelcase */
const postBody = {
customer_uuid: 'cus_cd9e5f29-6299-40e5-b343-0bd1ed228b4f',
data_source_uuid: 'ds_788ec6ae-dd51-11ee-bd46-a3ec952dc041',
external_id: 'cus_O075O8NH0LrtG8',
move_to_new_customer: []
};
/* eslint-enable camelcase */

nock(config.API_BASE)
.post('/v1/customers/unmerges', postBody)
.reply(202, {});

return Customer.unmerge(config, postBody)
.then(res => {
expect(202);
expect(res).to.be.instanceof(Object);
});
});

it('should connect subscriptions', () => {
const customerUuid = 'cus_7e4e5c3d-832c-4fa4-bf77-6fdc8c6e14bc';
/* eslint-disable camelcase */
Expand Down

0 comments on commit 39d441b

Please sign in to comment.