Skip to content

Commit d71acf6

Browse files
committed
Adding user delete method
1 parent a4edecc commit d71acf6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/intercom/user.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ def self.all
8282
UserCollectionProxy.new
8383
end
8484

85+
# Deletes a user record on your application.
86+
#
87+
# Calls POST https://api.intercom.io/v1/users/destroy
88+
#
89+
# returns Intercom::User object representing the user just before deletion.
90+
#
91+
# This operation is not idempotent.
92+
# @return [User]
93+
def self.delete(params)
94+
response = Intercom.post("users/destroy", params)
95+
User.from_api(response)
96+
end
97+
8598
# instance method alternative to #create
8699
# @return [User]
87100
def save

spec/unit/intercom/user_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
user.save
9898
end
9999

100+
it "deletes a user" do
101+
Intercom.expects(:post).with("users/destroy", {"email" => "jo@example.com", "user_id" => "i-1224242"}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
102+
user = Intercom::User.delete("email" => "jo@example.com", :user_id => "i-1224242")
103+
end
104+
100105
it "can use User.create for convenience" do
101106
Intercom.expects(:post).with("users", {"email" => "jo@example.com", "user_id" => "i-1224242"}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
102107
user = Intercom::User.create("email" => "jo@example.com", :user_id => "i-1224242")

0 commit comments

Comments
 (0)