spire_io 1.2 → 1.2.1
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/spire/api/application.rb +31 -0
- data/lib/spire/api/subscription.rb +7 -8
- metadata +4 -3
@@ -188,6 +188,16 @@ class Spire
|
|
188
188
|
}
|
189
189
|
end
|
190
190
|
|
191
|
+
define_request(:reset_member_password) do |email|
|
192
|
+
url = @resources["members"]["url"]
|
193
|
+
{
|
194
|
+
:method => :post,
|
195
|
+
:url => url,
|
196
|
+
:query => { :email => email },
|
197
|
+
:body => ""
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
191
201
|
#Authenticates with the application using basic auth
|
192
202
|
def authenticate(login, password)
|
193
203
|
response = request(:authenticate, {:login => login, :password => password})
|
@@ -206,6 +216,18 @@ class Spire
|
|
206
216
|
API::Member.new(@spire, response.data)
|
207
217
|
end
|
208
218
|
|
219
|
+
#If you do not give a new password, you will get back an authenticated member but have to change
|
220
|
+
#the password at a later time (using the returned capability)
|
221
|
+
def reset_password(reset_key, new_password = nil)
|
222
|
+
hsh = {:reset_key => reset_key}
|
223
|
+
hsh[:password] = new_password if new_password
|
224
|
+
response = request(:authenticate_with_post, hsh)
|
225
|
+
unless response.status == 201
|
226
|
+
raise "Error reseting password for application #{self.name}: (#{response.status}) #{response.body}"
|
227
|
+
end
|
228
|
+
API::Member.new(@spire, response.data)
|
229
|
+
end
|
230
|
+
|
209
231
|
def create_member(member_data)
|
210
232
|
response = request(:create_member, member_data)
|
211
233
|
unless response.status == 201
|
@@ -214,6 +236,15 @@ class Spire
|
|
214
236
|
API::Member.new(@spire, response.data)
|
215
237
|
end
|
216
238
|
|
239
|
+
#Resets a members password based on email
|
240
|
+
def request_member_password_reset(email)
|
241
|
+
response = request(:reset_member_password, email)
|
242
|
+
unless response.status == 202
|
243
|
+
raise "Error reseting password for email #{email} in app #{self.name}: (#{response.status}) #{response.body}"
|
244
|
+
end
|
245
|
+
true
|
246
|
+
end
|
247
|
+
|
217
248
|
def members
|
218
249
|
@members || members!
|
219
250
|
end
|
@@ -3,7 +3,7 @@ class Spire
|
|
3
3
|
|
4
4
|
class Subscription < Resource
|
5
5
|
|
6
|
-
|
6
|
+
attr_accessor :last
|
7
7
|
def resource_name
|
8
8
|
"subscription"
|
9
9
|
end
|
@@ -14,9 +14,12 @@ class Spire
|
|
14
14
|
:url => @url,
|
15
15
|
:query => {
|
16
16
|
"timeout" => options[:timeout],
|
17
|
+
"limit" => options[:limit],
|
18
|
+
"min_timestamp" => options[:min_timestamp],
|
19
|
+
"max_timestamp" => options[:max_timestamp],
|
20
|
+
"delay" => options[:delay],
|
17
21
|
"last" => options[:last],
|
18
|
-
"order-by" => options[:order_by]
|
19
|
-
"delay" => options[:delay]
|
22
|
+
"order-by" => options[:order_by]
|
20
23
|
},
|
21
24
|
:headers => {
|
22
25
|
"Authorization" => "Capability #{@capabilities["events"]}",
|
@@ -50,10 +53,6 @@ class Spire
|
|
50
53
|
end
|
51
54
|
|
52
55
|
def retrieve_events(options={})
|
53
|
-
options[:last] ||= "0"
|
54
|
-
options[:delay] ||= 0
|
55
|
-
options[:order_by] ||= "desc"
|
56
|
-
|
57
56
|
response = request(:events, options)
|
58
57
|
unless response.status == 200
|
59
58
|
raise "Error retrieving messages from #{self.class.name}: (#{response.status}) #{response.body}"
|
@@ -91,7 +90,7 @@ class Spire
|
|
91
90
|
|
92
91
|
def long_poll(options={})
|
93
92
|
options[:timeout] ||= 30
|
94
|
-
options[:last] = @last
|
93
|
+
options[:last] = @last if @last
|
95
94
|
retrieve_events(options)
|
96
95
|
end
|
97
96
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spire_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Dan Yoder
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2012-05-
|
20
|
+
date: 2012-05-22 00:00:00 -07:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|