tierion 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f55bc79b03b76dea30f01803ea139dee262fee6d
4
- data.tar.gz: 10250a419d07b51a09a12a0740c360019ea3d30a
3
+ metadata.gz: 3baabdab2723d5c5045caefc1a2885150a81c046
4
+ data.tar.gz: d1134857a1b20f63f542bf334f492a8156f1e4c5
5
5
  SHA512:
6
- metadata.gz: 702bc8b1cb1243dac2cc37d6082731bd03c645c134954258ff5ee821c474042c78953a2e8a26f2b08695084766540de8c82d23fa9b7481e503ee9f3880d89ead
7
- data.tar.gz: dbce99a7106c62aacec621af5b4ab7f8918143fd0e2db99aab662fb70b442e9f3052304c2bdcf00ac411fc9aa1d995b6f509a91d13d239236a160603a608fdb2
6
+ metadata.gz: 7e310003bb0fdc70343713f3e863d6560f6216c185639845b2e960ed8b5fc6b8dbe1bfa2821d638af0c6f59444ab42e1c8d5c8d20c510739acba4538a836a443
7
+ data.tar.gz: 5d0237fbb735050f1ac8d39aa632af3b9ffc43df44cf39decf2acd90d7b38a85e38c1c7fb9f2dbab06032ab43b448e0d269626417cdf9a99704dbf1b8d10bb6d
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.3.0 (8/9/2016)
4
+
5
+ - Updated blockchain subscription CRUD methods to support labels and retrieving all subscriptions with `Client#get_block_subscriptions`. You can now have multiple subscription callback endpoints, each with a unique ID.
6
+
3
7
  ## v1.2.0 (8/8/2016)
4
8
 
5
9
  - Added `Client#receipt_from_id_and_hash` convenience method
data/README.md CHANGED
@@ -227,13 +227,17 @@ web page.
227
227
 
228
228
  ### Block Subscriptions
229
229
 
230
- You can also create, retrieve, update, and delete 'block subscriptions'.
231
-
230
+ You can also create, retrieve, update, and delete 'block subscriptions'
231
+ and assign each of them an optional label.
232
232
 
233
233
  ```
234
234
  > t = Tierion::HashApi::Client.new
235
235
  => #<Tierion::HashApi::Client ... >
236
236
 
237
+ # returns and Array of all subscriptions
238
+ > t.get_block_subscriptions
239
+ => [{ ... }, { ... }]
240
+
237
241
  # takes a callback URL to receive payload, returns an ID
238
242
  > t.create_block_subscription('https://www.rempe.us/foo')
239
243
  => {:id=>"57a67d59fb16c5bc06f8d4e5"}
@@ -122,17 +122,17 @@ module Tierion
122
122
  @expires_at >= Time.now.utc
123
123
  end
124
124
 
125
- def create_block_subscription(callback_url)
125
+ # Returns a hash of all subscriptions, with :id, :callbackUrl, :label
126
+ def get_block_subscriptions
126
127
  auth_refresh unless logged_in?
127
128
  options = {
128
- body: { 'callbackUrl' => callback_url },
129
129
  headers: { 'Authorization' => "Bearer #{@access_token}" }
130
130
  }
131
- response = self.class.post('/blocksubscriptions', options)
131
+ response = self.class.get("/blocksubscriptions", options)
132
132
 
133
133
  if response.success?
134
134
  parsed = response.parsed_response
135
- Hashie.symbolize_keys!(parsed)
135
+ parsed = parsed.collect{ |s| Hashie.symbolize_keys!(s) }
136
136
  return parsed
137
137
  else
138
138
  raise_error(response)
@@ -155,12 +155,36 @@ module Tierion
155
155
  end
156
156
  end
157
157
 
158
- def update_block_subscription(id, callback_url)
158
+ def create_block_subscription(callback_url, label = nil)
159
159
  auth_refresh unless logged_in?
160
160
  options = {
161
161
  body: { 'callbackUrl' => callback_url },
162
162
  headers: { 'Authorization' => "Bearer #{@access_token}" }
163
163
  }
164
+ options[:body]['label'] = label unless label.blank?
165
+ response = self.class.post('/blocksubscriptions', options)
166
+
167
+ if response.success?
168
+ parsed = response.parsed_response
169
+ Hashie.symbolize_keys!(parsed)
170
+ return parsed
171
+ else
172
+ raise_error(response)
173
+ end
174
+ end
175
+
176
+ def update_block_subscription(id, callback_url = nil, label = nil)
177
+ if callback_url.blank? && label.blank?
178
+ raise ArgumentError, 'callback_url and label cannot both be blank'
179
+ end
180
+
181
+ auth_refresh unless logged_in?
182
+ options = {
183
+ body: {},
184
+ headers: { 'Authorization' => "Bearer #{@access_token}" }
185
+ }
186
+ options[:body].merge!({ 'callbackUrl' => callback_url }) if callback_url.present?
187
+ options[:body].merge!({ 'label' => label }) if label.present?
164
188
  response = self.class.put("/blocksubscriptions/#{id}", options)
165
189
 
166
190
  if response.success?
@@ -1,3 +1,3 @@
1
1
  module Tierion
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tierion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Rempe
@@ -30,7 +30,7 @@ cert_chain:
30
30
  zieXiXZSAojfFx9g91fKdIrlPbInHU/BaCxXSLBwvOM0drE+c2ue9X8gB55XAhzX
31
31
  37oBiw==
32
32
  -----END CERTIFICATE-----
33
- date: 2016-08-08 00:00:00.000000000 Z
33
+ date: 2016-08-09 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: httparty
metadata.gz.sig CHANGED
Binary file