hipchat-api 1.0.3 → 1.0.4
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/.travis.yml +2 -1
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/hipchat-api.gemspec +2 -4
- data/lib/hipchat-api.rb +50 -50
- data/lib/hipchat-api/version.rb +1 -1
- data/spec/hipchat-api_spec.rb +62 -57
- data/spec/spec_helper.rb +0 -1
- metadata +8 -8
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -38,7 +38,7 @@ rooms_create(name, owner_user_id, privacy = 'public', topic = '', guest_access =
|
|
38
38
|
rooms_delete(room_id)
|
39
39
|
rooms_list
|
40
40
|
rooms_history(room_id, date, timezone)
|
41
|
-
rooms_message(room_id, from, message, notify = 0, color = 'yellow')
|
41
|
+
rooms_message(room_id, from, message, notify = 0, color = 'yellow', message_format = 'html')
|
42
42
|
rooms_show(room_id)
|
43
43
|
```
|
44
44
|
|
data/hipchat-api.gemspec
CHANGED
@@ -20,11 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_dependency('httparty')
|
23
|
-
|
23
|
+
|
24
24
|
s.add_development_dependency('fakeweb')
|
25
|
-
s.add_development_dependency('mocha')
|
25
|
+
s.add_development_dependency('mocha', '~> 0.11.4')
|
26
26
|
s.add_development_dependency('rspec', '~> 2.7.0')
|
27
27
|
s.add_development_dependency('rake')
|
28
28
|
end
|
29
|
-
|
30
|
-
|
data/lib/hipchat-api.rb
CHANGED
@@ -4,10 +4,10 @@ require 'hipchat-api/version'
|
|
4
4
|
module HipChat
|
5
5
|
class API
|
6
6
|
include HTTParty
|
7
|
-
|
7
|
+
|
8
8
|
# Default timeout of 3 seconds
|
9
9
|
DEFAULT_TIMEOUT = 3
|
10
|
-
|
10
|
+
|
11
11
|
# Default headers for HTTP requests
|
12
12
|
DEFAULT_HEADERS = {
|
13
13
|
'User-Agent' => "HipChat gem #{VERSION}",
|
@@ -25,7 +25,7 @@ module HipChat
|
|
25
25
|
|
26
26
|
# HipChat access token
|
27
27
|
attr_accessor :token
|
28
|
-
|
28
|
+
|
29
29
|
# Create a new instance of the +HipChat::API+ for interacting with HipChat
|
30
30
|
#
|
31
31
|
# @param token [String] HipChat access token
|
@@ -34,16 +34,16 @@ module HipChat
|
|
34
34
|
@token = token
|
35
35
|
@hipchat_api_url = hipchat_api_url
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Turn on HTTParty debugging
|
39
|
-
#
|
39
|
+
#
|
40
40
|
# @param location [Object] Output "sink" for HTTP debugging
|
41
41
|
def debug(location = $stderr)
|
42
42
|
self.class.debug_output(location)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Set new HTTP headers for requests
|
46
|
-
#
|
46
|
+
#
|
47
47
|
# @param http_headers [Hash] HTTP headers
|
48
48
|
def set_http_headers(http_headers = {})
|
49
49
|
http_headers.merge!(DEFAULT_HEADERS)
|
@@ -56,31 +56,31 @@ module HipChat
|
|
56
56
|
def set_timeout(timeout)
|
57
57
|
self.class.default_timeout(timeout)
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
# Creates a new room.
|
61
|
-
#
|
61
|
+
#
|
62
62
|
# @param name [String] Name of the room.
|
63
63
|
# @param owner_user_id [int] User ID of the room's owner.
|
64
64
|
# @param privacy [String, 'public'] Privacy setting for room.
|
65
65
|
# @param topic [String, ''] Room topic.
|
66
66
|
# @param guest_access [int, 0] Whether or not to enable guest access for this room. 0 = false, 1 = true. (default: 0).
|
67
67
|
#
|
68
|
-
# @see https://www.hipchat.com/docs/api/method/rooms/create
|
68
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/create
|
69
69
|
def rooms_create(name, owner_user_id, privacy = 'public', topic = '', guest_access = 0)
|
70
|
-
self.class.post(hipchat_api_url_for('rooms/create'), :body => {:auth_token => @token, :name => name, :owner_user_id => owner_user_id,
|
70
|
+
self.class.post(hipchat_api_url_for('rooms/create'), :body => {:auth_token => @token, :name => name, :owner_user_id => owner_user_id,
|
71
71
|
:topic => topic, :privacy => privacy, :guest_access => guest_access})
|
72
72
|
end
|
73
|
-
|
74
|
-
# Deletes a room and kicks the current participants.
|
75
|
-
#
|
73
|
+
|
74
|
+
# Deletes a room and kicks the current participants.
|
75
|
+
#
|
76
76
|
# @param room_id [int] ID of the room
|
77
77
|
#
|
78
78
|
# @see https://www.hipchat.com/docs/api/method/rooms/delete
|
79
79
|
def rooms_delete(room_id)
|
80
|
-
self.class.post(hipchat_api_url_for('rooms/delete'), :body => {:auth_token => @token, :room_id => room_id})
|
80
|
+
self.class.post(hipchat_api_url_for('rooms/delete'), :body => {:auth_token => @token, :room_id => room_id})
|
81
81
|
end
|
82
82
|
|
83
|
-
# Fetch chat history for this room.
|
83
|
+
# Fetch chat history for this room.
|
84
84
|
#
|
85
85
|
# @param room_id [int] ID of the room.
|
86
86
|
# @param date [String] Either the date to fetch history for in YYYY-MM-DD format, or "recent" to fetch the latest 50 messages.
|
@@ -88,74 +88,74 @@ module HipChat
|
|
88
88
|
#
|
89
89
|
# @see https://www.hipchat.com/docs/api/method/rooms/history
|
90
90
|
def rooms_history(room_id, date, timezone)
|
91
|
-
self.class.get(hipchat_api_url_for('rooms/history'), :query => {:auth_token => @token, :room_id => room_id, :date => date,
|
91
|
+
self.class.get(hipchat_api_url_for('rooms/history'), :query => {:auth_token => @token, :room_id => room_id, :date => date,
|
92
92
|
:timezone => timezone})
|
93
93
|
end
|
94
94
|
|
95
|
-
# List rooms for this group.
|
96
|
-
#
|
95
|
+
# List rooms for this group.
|
96
|
+
#
|
97
97
|
# @see https://www.hipchat.com/docs/api/method/rooms/list
|
98
98
|
def rooms_list
|
99
99
|
self.class.get(hipchat_api_url_for('rooms/list'), :query => {:auth_token => @token})
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
# Send a message to a room.
|
103
|
-
#
|
103
|
+
#
|
104
104
|
# @param room_id [int] ID of the room.
|
105
105
|
# @param from [String] Name the message will appear be sent from. Must be less than 15 characters long. May contain letters, numbers, -, _, and spaces.
|
106
|
-
# @param message [String] The message body. Must be valid XHTML. HTML entities must be escaped (e.g.: & instead of &). May contain basic tags: a, b, i, strong, em, br, img, pre, code. 5000 characters max.
|
106
|
+
# @param message [String] The message body. Must be valid XHTML. HTML entities must be escaped (e.g.: & instead of &). May contain basic tags: a, b, i, strong, em, br, img, pre, code. 5000 characters max.
|
107
107
|
# @param notify [int] Boolean flag of whether or not this message should trigger a notification for people in the room (based on their individual notification preferences). 0 = false, 1 = true. (default: 0)
|
108
|
-
# @param color [String] Background color for message. One of "yellow", "red", "green", "purple", or "random". (default: yellow)
|
108
|
+
# @param color [String] Background color for message. One of "yellow", "red", "green", "purple", or "random". (default: yellow)
|
109
109
|
# @param message_format [String] Determines how the message is treated by HipChat's server and rendered inside HipChat applications. One of "html" or "text". (default: html)
|
110
110
|
# @see https://www.hipchat.com/docs/api/method/rooms/message
|
111
111
|
def rooms_message(room_id, from, message, notify = 0, color = 'yellow', message_format = 'html')
|
112
|
-
self.class.post(hipchat_api_url_for('rooms/message'), :body => {:auth_token => @token, :room_id => room_id, :from => from,
|
112
|
+
self.class.post(hipchat_api_url_for('rooms/message'), :body => {:auth_token => @token, :room_id => room_id, :from => from,
|
113
113
|
:message => message, :notify => notify, :color => color, :message_format => message_format})
|
114
114
|
end
|
115
115
|
|
116
116
|
# Get room details.
|
117
|
-
#
|
117
|
+
#
|
118
118
|
# @param room_id [int] ID of the room.
|
119
119
|
#
|
120
120
|
# @see https://www.hipchat.com/docs/api/method/rooms/show
|
121
121
|
def rooms_show(room_id)
|
122
122
|
self.class.get(hipchat_api_url_for('rooms/show'), :query => {:auth_token => @token, :room_id => room_id})
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
# Create a new user in your group.
|
126
|
-
#
|
126
|
+
#
|
127
127
|
# @param email [String] User's email.
|
128
|
-
# @param name [String] User's full name.
|
129
|
-
# @param title [String] User's title.
|
130
|
-
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
131
|
-
# @param password [String, nil] User's password. If not provided, a randomly generated password will be returned.
|
132
|
-
# @param timezone [String, 'UTC'] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
128
|
+
# @param name [String] User's full name.
|
129
|
+
# @param title [String] User's title.
|
130
|
+
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
131
|
+
# @param password [String, nil] User's password. If not provided, a randomly generated password will be returned.
|
132
|
+
# @param timezone [String, 'UTC'] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
133
133
|
#
|
134
134
|
# @see https://www.hipchat.com/docs/api/method/users/create
|
135
135
|
def users_create(email, name, title, is_group_admin = 0, password = nil, timezone = 'UTC')
|
136
|
-
self.class.post(hipchat_api_url_for('users/create'), :body => {:auth_token => @token, :email => email, :name => name, :title => title,
|
137
|
-
:is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject
|
136
|
+
self.class.post(hipchat_api_url_for('users/create'), :body => {:auth_token => @token, :email => email, :name => name, :title => title,
|
137
|
+
:is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject{|key, value| value.nil?})
|
138
138
|
end
|
139
139
|
|
140
|
-
# Delete a user.
|
141
|
-
#
|
142
|
-
# @param user_id [String] ID or email address of the user.
|
140
|
+
# Delete a user.
|
141
|
+
#
|
142
|
+
# @param user_id [String] ID or email address of the user.
|
143
143
|
#
|
144
144
|
# @see https://www.hipchat.com/docs/api/method/users/delete
|
145
145
|
def users_delete(user_id)
|
146
146
|
self.class.post(hipchat_api_url_for('users/delete'), :body => {:auth_token => @token, :user_id => user_id})
|
147
147
|
end
|
148
148
|
|
149
|
-
# List all users in the group.
|
149
|
+
# List all users in the group.
|
150
150
|
#
|
151
151
|
# @see https://www.hipchat.com/docs/api/method/users/list
|
152
152
|
def users_list
|
153
153
|
self.class.get(hipchat_api_url_for('users/list'), :query => {:auth_token => @token})
|
154
154
|
end
|
155
155
|
|
156
|
-
# Get a user's details.
|
157
|
-
#
|
158
|
-
# @param user_id [String] ID or email address of the user.
|
156
|
+
# Get a user's details.
|
157
|
+
#
|
158
|
+
# @param user_id [String] ID or email address of the user.
|
159
159
|
#
|
160
160
|
# @see https://www.hipchat.com/docs/api/method/users/show
|
161
161
|
def users_show(user_id)
|
@@ -163,22 +163,22 @@ module HipChat
|
|
163
163
|
end
|
164
164
|
|
165
165
|
# Update a user.
|
166
|
-
#
|
166
|
+
#
|
167
167
|
# @param email [String] User's email.
|
168
|
-
# @param name [String] User's full name.
|
169
|
-
# @param title [String] User's title.
|
170
|
-
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
168
|
+
# @param name [String] User's full name.
|
169
|
+
# @param title [String] User's title.
|
170
|
+
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
171
171
|
# @param password [String, nil] User's password.
|
172
|
-
# @param timezone [String, nil] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
172
|
+
# @param timezone [String, nil] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
173
173
|
#
|
174
174
|
# @see https://www.hipchat.com/docs/api/method/users/update
|
175
175
|
def users_update(user_id, email = nil, name = nil, title = nil, is_group_admin = nil, password = nil, timezone = nil)
|
176
|
-
self.class.post(hipchat_api_url_for('users/update'), :body => {:auth_token => @token, :user_id => user_id, :email => email,
|
177
|
-
:name => name, :title => title, :is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject
|
176
|
+
self.class.post(hipchat_api_url_for('users/update'), :body => {:auth_token => @token, :user_id => user_id, :email => email,
|
177
|
+
:name => name, :title => title, :is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject{|key, value| value.nil?})
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
private
|
181
|
-
|
181
|
+
|
182
182
|
# Create a URL appropriate for accessing the HipChat API with a given API method.
|
183
183
|
#
|
184
184
|
# @param method [String] HipChat API method
|
@@ -188,4 +188,4 @@ module HipChat
|
|
188
188
|
"#{@hipchat_api_url}/#{method}"
|
189
189
|
end
|
190
190
|
end
|
191
|
-
end
|
191
|
+
end
|
data/lib/hipchat-api/version.rb
CHANGED
data/spec/hipchat-api_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'fakeweb'
|
3
|
+
require 'mocha'
|
3
4
|
|
4
5
|
describe "HipChat::API" do
|
5
6
|
before(:each) do
|
@@ -11,34 +12,34 @@ describe "HipChat::API" do
|
|
11
12
|
after(:each) do
|
12
13
|
FakeWeb.allow_net_connect = true
|
13
14
|
end
|
14
|
-
|
15
|
+
|
15
16
|
it "should be the correct version" do
|
16
|
-
HipChat::API::VERSION.should == '1.0.
|
17
|
+
HipChat::API::VERSION.should == '1.0.4'
|
17
18
|
end
|
18
|
-
|
19
|
-
it "should create a new instance with the correct parameters" do
|
19
|
+
|
20
|
+
it "should create a new instance with the correct parameters" do
|
20
21
|
@hipchat_api.token.should be == 'token'
|
21
22
|
@hipchat_api.hipchat_api_url.should == HipChat::API::HIPCHAT_API_URL
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
it "should allow http headers to be set" do
|
25
26
|
@hipchat_api.expects(:headers).at_least_once
|
26
|
-
|
27
|
+
|
27
28
|
@hipchat_api.set_http_headers({'Accept' => 'application/json'})
|
28
29
|
end
|
29
|
-
|
30
|
+
|
30
31
|
it "should allow a timeout to be set" do
|
31
32
|
@hipchat_api.expects(:default_timeout).at_least_once
|
32
|
-
|
33
|
+
|
33
34
|
@hipchat_api.set_timeout(10)
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
it "should allow you to create a room" do
|
37
|
-
FakeWeb.register_uri(:post,
|
38
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/create|,
|
39
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_create_response.json'),
|
38
|
+
FakeWeb.register_uri(:post,
|
39
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/create|,
|
40
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_create_response.json'),
|
40
41
|
:content_type => "application/json")
|
41
|
-
|
42
|
+
|
42
43
|
rooms_create_response = @hipchat_api.rooms_create('Development', 5)
|
43
44
|
rooms_create_response.should_not be nil
|
44
45
|
rooms_create_response['room']['name'].should == 'Development'
|
@@ -46,110 +47,114 @@ describe "HipChat::API" do
|
|
46
47
|
end
|
47
48
|
|
48
49
|
it "should allow you to delete a room" do
|
49
|
-
FakeWeb.register_uri(:post,
|
50
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/delete|,
|
51
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_delete_response.json'),
|
50
|
+
FakeWeb.register_uri(:post,
|
51
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/delete|,
|
52
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_delete_response.json'),
|
52
53
|
:content_type => "application/json")
|
53
|
-
|
54
|
+
|
54
55
|
rooms_delete_response = @hipchat_api.rooms_delete(5)
|
55
56
|
rooms_delete_response.should_not be nil
|
56
57
|
rooms_delete_response['deleted'].should be true
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
it "should return a list of rooms" do
|
60
|
-
FakeWeb.register_uri(:get,
|
61
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/list|,
|
62
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_list_response.json'),
|
61
|
+
FakeWeb.register_uri(:get,
|
62
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/list|,
|
63
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_list_response.json'),
|
63
64
|
:content_type => "application/json")
|
64
|
-
|
65
|
+
|
65
66
|
rooms_list_response = @hipchat_api.rooms_list
|
66
67
|
rooms_list_response.should_not be nil
|
67
68
|
rooms_list_response['rooms'].size.should be 2
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
it "should return the correct room informaton for a room_id" do
|
71
|
-
FakeWeb.register_uri(:get,
|
72
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/show|,
|
73
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_show_response.json'),
|
72
|
+
FakeWeb.register_uri(:get,
|
73
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/show|,
|
74
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_show_response.json'),
|
74
75
|
:content_type => "application/json")
|
75
|
-
|
76
|
+
|
76
77
|
rooms_show_response = @hipchat_api.rooms_show(7)
|
77
78
|
rooms_show_response.should_not be nil
|
78
79
|
rooms_show_response['room']['topic'].should == 'Chef is so awesome.'
|
79
80
|
end
|
80
81
|
|
81
82
|
it "should send a message" do
|
82
|
-
FakeWeb.register_uri(:post,
|
83
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/message|,
|
84
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_message_response.json'),
|
83
|
+
FakeWeb.register_uri(:post,
|
84
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/message|,
|
85
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_message_response.json'),
|
85
86
|
:content_type => "application/json")
|
86
|
-
|
87
|
+
|
87
88
|
rooms_message_response = @hipchat_api.rooms_message(10, 'Alerts', 'A new user signed up')
|
88
89
|
rooms_message_response.should_not be nil
|
89
90
|
rooms_message_response['status'].should == 'sent'
|
90
91
|
end
|
91
92
|
|
92
93
|
it "should return a history of messages" do
|
93
|
-
FakeWeb.register_uri(:get,
|
94
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/history|,
|
95
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_history_response.json'),
|
94
|
+
FakeWeb.register_uri(:get,
|
95
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/rooms/history|,
|
96
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'rooms_history_response.json'),
|
96
97
|
:content_type => "application/json")
|
97
|
-
|
98
|
+
|
98
99
|
rooms_history_response = @hipchat_api.rooms_history(10, '2010-11-19', 'PST')
|
99
100
|
rooms_history_response.should_not be nil
|
100
101
|
rooms_history_response['messages'].size.should be 3
|
101
102
|
end
|
102
103
|
|
103
104
|
it "should create a user" do
|
104
|
-
FakeWeb.register_uri(:post,
|
105
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/users/create|,
|
106
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_create_response.json'),
|
105
|
+
FakeWeb.register_uri(:post,
|
106
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/users/create|,
|
107
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_create_response.json'),
|
107
108
|
:content_type => "application/json")
|
108
|
-
|
109
|
-
users_create_response = @hipchat_api.users_create('new@company.com', 'New Guy', 'intern')
|
109
|
+
|
110
|
+
users_create_response = @hipchat_api.users_create('new@company.com', 'New Guy', 'intern', is_group_admin = 0, 'changeme')
|
110
111
|
users_create_response.should_not be nil
|
111
112
|
users_create_response['user']['name'].should == 'New Guy'
|
113
|
+
|
114
|
+
# Make sure the new user's password was sent
|
115
|
+
FakeWeb.last_request.body.should_not be_nil
|
116
|
+
FakeWeb.last_request.body.should match 'changeme'
|
112
117
|
end
|
113
118
|
|
114
119
|
it "should delete a user" do
|
115
|
-
FakeWeb.register_uri(:post,
|
116
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/users/delete|,
|
117
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_delete_response.json'),
|
120
|
+
FakeWeb.register_uri(:post,
|
121
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/users/delete|,
|
122
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_delete_response.json'),
|
118
123
|
:content_type => "application/json")
|
119
|
-
|
124
|
+
|
120
125
|
users_delete_response = @hipchat_api.users_delete(5)
|
121
126
|
users_delete_response.should_not be nil
|
122
127
|
users_delete_response['deleted'].should be true
|
123
128
|
end
|
124
129
|
|
125
130
|
it "should return a list of users" do
|
126
|
-
FakeWeb.register_uri(:get,
|
127
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/users/list|,
|
128
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_list_response.json'),
|
131
|
+
FakeWeb.register_uri(:get,
|
132
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/users/list|,
|
133
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_list_response.json'),
|
129
134
|
:content_type => "application/json")
|
130
|
-
|
135
|
+
|
131
136
|
users_list_response = @hipchat_api.users_list
|
132
137
|
users_list_response.should_not be nil
|
133
138
|
users_list_response['users'].size.should be 3
|
134
139
|
end
|
135
140
|
|
136
141
|
it "should show the details for a user" do
|
137
|
-
FakeWeb.register_uri(:get,
|
138
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/users/show|,
|
139
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_show_response.json'),
|
142
|
+
FakeWeb.register_uri(:get,
|
143
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/users/show|,
|
144
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_show_response.json'),
|
140
145
|
:content_type => "application/json")
|
141
|
-
|
146
|
+
|
142
147
|
users_show_response = @hipchat_api.users_show(5)
|
143
148
|
users_show_response.should_not be nil
|
144
149
|
users_show_response['user']['name'].should == 'Garret Heaton'
|
145
150
|
end
|
146
|
-
|
151
|
+
|
147
152
|
it "should update a user" do
|
148
|
-
FakeWeb.register_uri(:post,
|
149
|
-
%r|#{HipChat::API::HIPCHAT_API_URL}/users/update|,
|
150
|
-
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_update_response.json'),
|
153
|
+
FakeWeb.register_uri(:post,
|
154
|
+
%r|#{HipChat::API::HIPCHAT_API_URL}/users/update|,
|
155
|
+
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'users_update_response.json'),
|
151
156
|
:content_type => "application/json")
|
152
|
-
|
157
|
+
|
153
158
|
users_update_response = @hipchat_api.users_update(5, 'new-email-address@hipchat.com')
|
154
159
|
users_update_response.should_not be nil
|
155
160
|
users_update_response['user']['email'].should == 'new-email-address@hipchat.com'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -48,17 +48,17 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 0.11.4
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.11.4
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
segments:
|
140
140
|
- 0
|
141
|
-
hash:
|
141
|
+
hash: 1264281140319170135
|
142
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
143
|
none: false
|
144
144
|
requirements:
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
segments:
|
149
149
|
- 0
|
150
|
-
hash:
|
150
|
+
hash: 1264281140319170135
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project: hipchat-api
|
153
153
|
rubygems_version: 1.8.23
|