Skip to content

Commit a1bbff4

Browse files
marsadleMarkus Muehlberger
andauthored
Add ability to archive/unarchive contacts (#551)
Co-authored-by: Markus Muehlberger <[email protected]>
1 parent 1aa86b0 commit a1bbff4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/intercom/service/contact.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ def merge(lead, user)
3333
user.from_response(response)
3434
end
3535

36+
def archive(contact)
37+
@client.post("/#{collection_name}/#{contact.id}/archive", {})
38+
contact
39+
end
40+
41+
def unarchive(contact)
42+
@client.post("/#{collection_name}/#{contact.id}/unarchive", {})
43+
contact
44+
end
45+
3646
private def raise_invalid_merge_error
3747
raise Intercom::InvalidMergeError, 'Merging can only be performed on a lead into a user'
3848
end

spec/unit/intercom/contact_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@
248248
client.contacts.delete(contact)
249249
end
250250

251+
it 'archives a contact' do
252+
contact = Intercom::Contact.new('id' => '1')
253+
client.expects(:post).with('/contacts/1/archive', {})
254+
client.contacts.archive(contact)
255+
end
256+
257+
it 'unarchives a contact' do
258+
contact = Intercom::Contact.new('id' => '1')
259+
client.expects(:post).with('/contacts/1/unarchive', {})
260+
client.contacts.unarchive(contact)
261+
end
262+
251263
describe 'merging' do
252264
let(:lead) { Intercom::Contact.from_api(external_id: 'contact_id', role: 'lead') }
253265
let(:user) { Intercom::Contact.from_api(id: 'external_id', role: 'user') }

0 commit comments

Comments
 (0)