diff --git a/dist/endpoints/contacts.js b/dist/endpoints/contacts.js index a828cde..20122fe 100644 --- a/dist/endpoints/contacts.js +++ b/dist/endpoints/contacts.js @@ -57,6 +57,16 @@ var Contacts = function Contacts() { return (0, _errorHandler2.default)(error); }); }, + getContactByEmail: function getContactByEmail(email) { + var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + + return api.get('contacts/v1/contact/email/' + email + '/profile', parameters).then(function (response) { + return (0, _responseHandler2.default)(response); + }).catch(function (error) { + return (0, _errorHandler2.default)(error); + }); + }, createContact: function createContact(properties) { var mappedProperties = this.mapProperties(properties); diff --git a/src/endpoints/contacts.js b/src/endpoints/contacts.js index 2f1cb14..d5c60eb 100644 --- a/src/endpoints/contacts.js +++ b/src/endpoints/contacts.js @@ -31,6 +31,12 @@ const Contacts = (api = null) => { .then(response => responseHandler(response)) .catch(error => errorHandler(error)) }, + getContactByEmail(email, parameters = {}) { + + return api.get(`contacts/v1/contact/email/${email}/profile`, parameters) + .then(response => responseHandler(response)) + .catch(error => errorHandler(error)) + }, createContact(properties) { let mappedProperties = this.mapProperties(properties) diff --git a/test/contacts.js b/test/contacts.js index 944425c..bd482f6 100644 --- a/test/contacts.js +++ b/test/contacts.js @@ -22,7 +22,12 @@ describe('Contacts', () => { before(() => { - api.contacts.getAll() + api.contacts.getAll({ + count: 1, + property: [ + 'email', 'firstname', 'lastname', + ], + }) .then(response => response.data.contacts[0]) .then(contactData => { testContact = contactData @@ -45,6 +50,21 @@ describe('Contacts', () => { expect(response.data.properties.lastname.value).to.be.equal(lastname.value) }) }) + + it('Should return a single contact, by email address', () => { + + let { firstname, lastname, email } = testContact.properties + + return api.contacts.getContactByEmail(email.value) + .then(response => { + expect(response.status).to.equal(200) + expect(response.data).to.be.a('object') + expect(response.data.vid).to.be.a('number') + expect(response.data.properties.firstname.value).to.be.equal(firstname.value) + expect(response.data.properties.lastname.value).to.be.equal(lastname.value) + expect(response.data.properties.email.value).to.be.equal(email.value) + }) + }) }) describe('Create or update a contact', () => {