intercom 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/intercom.rb
CHANGED
@@ -52,6 +52,10 @@ module Intercom
|
|
52
52
|
Intercom::Request.post(url_for_path(path), payload_hash).execute
|
53
53
|
end
|
54
54
|
|
55
|
+
def self.delete(path, payload_hash)
|
56
|
+
Intercom::Request.delete(url_for_path(path), payload_hash).execute
|
57
|
+
end
|
58
|
+
|
55
59
|
def self.put(path, payload_hash)
|
56
60
|
Intercom::Request.put(url_for_path(path), payload_hash).execute
|
57
61
|
end
|
data/lib/intercom/request.rb
CHANGED
@@ -28,6 +28,11 @@ module Intercom
|
|
28
28
|
new(uri, method_with_body(Net::HTTP::Post, uri, form_data))
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.delete(url, params)
|
32
|
+
uri = URI.parse(url)
|
33
|
+
new(uri, Net::HTTP::Delete.new(append_query_string_to_url(uri.path, params), default_headers))
|
34
|
+
end
|
35
|
+
|
31
36
|
def self.put(url, form_data)
|
32
37
|
uri = URI.parse(url)
|
33
38
|
new(uri, method_with_body(Net::HTTP::Put, uri, form_data))
|
data/lib/intercom/user.rb
CHANGED
@@ -82,6 +82,19 @@ module Intercom
|
|
82
82
|
UserCollectionProxy.new
|
83
83
|
end
|
84
84
|
|
85
|
+
# Deletes a user record on your application.
|
86
|
+
#
|
87
|
+
# Calls DELETE https://api.intercom.io/v1/users
|
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.delete("users", params)
|
95
|
+
User.from_api(response)
|
96
|
+
end
|
97
|
+
|
85
98
|
# instance method alternative to #create
|
86
99
|
# @return [User]
|
87
100
|
def save
|
data/lib/intercom/version.rb
CHANGED
@@ -97,6 +97,11 @@ describe "Intercom::User" do
|
|
97
97
|
user.save
|
98
98
|
end
|
99
99
|
|
100
|
+
it "deletes a user" do
|
101
|
+
Intercom.expects(:delete).with("users", {"email" => "jo@example.com", "user_id" => "i-1224242"}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
|
102
|
+
Intercom::User.delete("email" => "jo@example.com", "user_id" => "i-1224242")
|
103
|
+
end
|
104
|
+
|
100
105
|
it "can use User.create for convenience" do
|
101
106
|
Intercom.expects(:post).with("users", {"email" => "jo@example.com", "user_id" => "i-1224242"}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
|
102
107
|
user = Intercom::User.create("email" => "jo@example.com", :user_id => "i-1224242")
|
data/spec/unit/intercom_spec.rb
CHANGED
@@ -47,9 +47,6 @@ describe Intercom do
|
|
47
47
|
it "checks for email or user id" do
|
48
48
|
proc { Intercom.check_required_params("else") }.must_raise ArgumentError, "Expected params Hash, got String"
|
49
49
|
proc { Intercom.check_required_params(:something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
|
50
|
-
proc { Intercom.get("messages", :something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
|
51
|
-
proc { Intercom.put("messages", :something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
|
52
|
-
proc { Intercom.post("messages", :something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
|
53
50
|
Intercom.check_required_params(:email => "bob@example.com", :something => "else")
|
54
51
|
Intercom.check_required_params("email" => "bob@example.com", :something => "else")
|
55
52
|
Intercom.check_required_params(:user_id => "123")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|