processout 2.0.0 → 2.1.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: 63e1163e73bcea9ce6653eba757252dafedca08f
4
- data.tar.gz: 36553ed290dab6dedd47e7a5863b6f4e0722d687
3
+ metadata.gz: 1dfc5c9143608ff2b9a9e47e25041fe53dd3315d
4
+ data.tar.gz: 4c5818c8200cf39015db82492096c4ff675f1bbb
5
5
  SHA512:
6
- metadata.gz: aad70b245a3d7d82da6777f23863a81cfa2468c08b64a729c7d4ebeda8320881b724635ec5edcc0f44b797687798fb4a1784fb8d387a4b590e082726481b2e57
7
- data.tar.gz: 6c55f645cb87d5433f5a26184d912a7606a3dcc2775aa6d7390d45e30537ae5a6a5169a6052a1fe407ccfe914ac659cc81564f1ab81a093315562835bfa6d696
6
+ metadata.gz: c96b4796d8d8236ce7df7836b4990b5759dae5c0db3ef8e6eaac5bb254eff48583efd1f001b07097a6b175247885101c0fcfd1197dcbb50e01c93ff6a5c460bc
7
+ data.tar.gz: ace0dc350ffe37846d1a2131c3a12d341bbf5e44bafb36e9199ae6f6c57a77102d162b7dc38a8b48aac4ddb2d8b86f17aaf06c20be0846f670586dcb320201e5
@@ -223,15 +223,45 @@ module ProcessOut
223
223
  self
224
224
  end
225
225
 
226
- # Apply a new addon to the given subscription ID.
226
+ # Get the addons applied to the subscription.
227
227
  # Params:
228
228
  # +subscription_id+:: ID of the subscription
229
229
  # +options+:: +Hash+ of options
230
- def apply(subscription_id, options = {})
230
+ def fetch_subscription_addons(subscription_id, options = {})
231
231
  self.prefill(options)
232
232
 
233
233
  request = Request.new(@client)
234
234
  path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons"
235
+ data = {
236
+
237
+ }
238
+
239
+ response = Response.new(request.get(path, data, options))
240
+ return_values = Array.new
241
+
242
+ a = Array.new
243
+ body = response.body
244
+ for v in body['addons']
245
+ tmp = Addon.new(@client)
246
+ tmp.fill_with_data(v)
247
+ a.push(tmp)
248
+ end
249
+
250
+ return_values.push(a)
251
+
252
+
253
+
254
+ return_values[0]
255
+ end
256
+
257
+ # Create a new addon to the given subscription ID.
258
+ # Params:
259
+ # +options+:: +Hash+ of options
260
+ def create(options = {})
261
+ self.prefill(options)
262
+
263
+ request = Request.new(@client)
264
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons"
235
265
  data = {
236
266
  "plan_id" => @plan_id,
237
267
  "type" => @type,
@@ -322,16 +352,14 @@ module ProcessOut
322
352
  return_values[0]
323
353
  end
324
354
 
325
- # Remove an addon applied to a subscription.
355
+ # Delete an addon applied to a subscription.
326
356
  # Params:
327
- # +subscription_id+:: ID of the subscription on which the addon was applied
328
- # +addon_id+:: ID of the addon
329
357
  # +options+:: +Hash+ of options
330
- def remove(subscription_id, addon_id, options = {})
358
+ def delete(options = {})
331
359
  self.prefill(options)
332
360
 
333
361
  request = Request.new(@client)
334
- path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons/" + CGI.escape(addon_id) + ""
362
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons/" + CGI.escape(@id) + ""
335
363
  data = {
336
364
  "prorate" => options.fetch(:prorate, nil),
337
365
  "proration_date" => options.fetch(:proration_date, nil),
@@ -259,19 +259,18 @@ module ProcessOut
259
259
 
260
260
  # Create a new authorization request for the given customer ID.
261
261
  # Params:
262
- # +customer_id+:: ID of the customer
263
262
  # +options+:: +Hash+ of options
264
- def create(customer_id, options = {})
263
+ def create(options = {})
265
264
  self.prefill(options)
266
265
 
267
266
  request = Request.new(@client)
268
267
  path = "/authorization-requests"
269
268
  data = {
269
+ "customer_id" => @customer_id,
270
270
  "name" => @name,
271
271
  "currency" => @currency,
272
272
  "return_url" => @return_url,
273
- "cancel_url" => @cancel_url,
274
- "customer_id" => customer_id
273
+ "cancel_url" => @cancel_url
275
274
  }
276
275
 
277
276
  response = Response.new(request.post(path, data, options))
@@ -223,15 +223,45 @@ module ProcessOut
223
223
  self
224
224
  end
225
225
 
226
- # Apply a new discount to the given subscription ID.
226
+ # Get the discounts applied to the subscription.
227
227
  # Params:
228
228
  # +subscription_id+:: ID of the subscription
229
229
  # +options+:: +Hash+ of options
230
- def apply(subscription_id, options = {})
230
+ def fetch_subscription_discounts(subscription_id, options = {})
231
231
  self.prefill(options)
232
232
 
233
233
  request = Request.new(@client)
234
234
  path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
235
+ data = {
236
+
237
+ }
238
+
239
+ response = Response.new(request.get(path, data, options))
240
+ return_values = Array.new
241
+
242
+ a = Array.new
243
+ body = response.body
244
+ for v in body['discounts']
245
+ tmp = Discount.new(@client)
246
+ tmp.fill_with_data(v)
247
+ a.push(tmp)
248
+ end
249
+
250
+ return_values.push(a)
251
+
252
+
253
+
254
+ return_values[0]
255
+ end
256
+
257
+ # Create a new discount for the given subscription ID.
258
+ # Params:
259
+ # +options+:: +Hash+ of options
260
+ def create(options = {})
261
+ self.prefill(options)
262
+
263
+ request = Request.new(@client)
264
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts"
235
265
  data = {
236
266
  "coupon_id" => @coupon_id,
237
267
  "name" => @name,
@@ -283,16 +313,14 @@ module ProcessOut
283
313
  return_values[0]
284
314
  end
285
315
 
286
- # Remove a discount applied to a subscription.
316
+ # Delete a discount applied to a subscription.
287
317
  # Params:
288
- # +subscription_id+:: ID of the subscription on which the discount was applied
289
- # +discount_id+:: ID of the discount
290
318
  # +options+:: +Hash+ of options
291
- def remove(subscription_id, discount_id, options = {})
319
+ def delete(options = {})
292
320
  self.prefill(options)
293
321
 
294
322
  request = Request.new(@client)
295
- path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts/" + CGI.escape(discount_id) + ""
323
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts/" + CGI.escape(@id) + ""
296
324
  data = {
297
325
 
298
326
  }
@@ -159,6 +159,37 @@ module ProcessOut
159
159
  self
160
160
  end
161
161
 
162
+ # Get the transaction's refunds.
163
+ # Params:
164
+ # +transaction_id+:: ID of the transaction
165
+ # +options+:: +Hash+ of options
166
+ def fetch_transaction_refunds(transaction_id, options = {})
167
+ self.prefill(options)
168
+
169
+ request = Request.new(@client)
170
+ path = "/transactions/" + CGI.escape(transaction_id) + "/refunds"
171
+ data = {
172
+
173
+ }
174
+
175
+ response = Response.new(request.get(path, data, options))
176
+ return_values = Array.new
177
+
178
+ a = Array.new
179
+ body = response.body
180
+ for v in body['refunds']
181
+ tmp = Refund.new(@client)
182
+ tmp.fill_with_data(v)
183
+ a.push(tmp)
184
+ end
185
+
186
+ return_values.push(a)
187
+
188
+
189
+
190
+ return_values[0]
191
+ end
192
+
162
193
  # Find a transaction's refund by its ID.
163
194
  # Params:
164
195
  # +transaction_id+:: ID of the transaction on which the refund was applied
@@ -188,15 +219,14 @@ module ProcessOut
188
219
  return_values[0]
189
220
  end
190
221
 
191
- # Apply a refund to a transaction.
222
+ # Create a refund for a transaction.
192
223
  # Params:
193
- # +transaction_id+:: ID of the transaction
194
224
  # +options+:: +Hash+ of options
195
- def apply(transaction_id, options = {})
225
+ def create(options = {})
196
226
  self.prefill(options)
197
227
 
198
228
  request = Request.new(@client)
199
- path = "/transactions/" + CGI.escape(transaction_id) + "/refunds"
229
+ path = "/transactions/" + CGI.escape(@transaction_id) + "/refunds"
200
230
  data = {
201
231
  "amount" => @amount,
202
232
  "metadata" => @metadata,
@@ -548,11 +548,11 @@ module ProcessOut
548
548
  return_values[0]
549
549
  end
550
550
 
551
- # Remove an addon applied to a subscription.
551
+ # Delete an addon applied to a subscription.
552
552
  # Params:
553
553
  # +addon_id+:: ID of the addon or plan to be removed from the subscription
554
554
  # +options+:: +Hash+ of options
555
- def remove_addon(addon_id, options = {})
555
+ def delete_addon(addon_id, options = {})
556
556
  self.prefill(options)
557
557
 
558
558
  request = Request.new(@client)
@@ -651,11 +651,11 @@ module ProcessOut
651
651
  return_values[0]
652
652
  end
653
653
 
654
- # Remove a discount applied to a subscription.
654
+ # Delete a discount applied to a subscription.
655
655
  # Params:
656
656
  # +discount_id+:: ID of the discount or coupon to be removed from the subscription
657
657
  # +options+:: +Hash+ of options
658
- def remove_discount(discount_id, options = {})
658
+ def delete_discount(discount_id, options = {})
659
659
  self.prefill(options)
660
660
 
661
661
  request = Request.new(@client)
@@ -735,9 +735,8 @@ module ProcessOut
735
735
 
736
736
  # Create a new subscription for the given customer.
737
737
  # Params:
738
- # +customer_id+:: ID of the customer
739
738
  # +options+:: +Hash+ of options
740
- def create(customer_id, options = {})
739
+ def create(options = {})
741
740
  self.prefill(options)
742
741
 
743
742
  request = Request.new(@client)
@@ -751,11 +750,11 @@ module ProcessOut
751
750
  "metadata" => @metadata,
752
751
  "interval" => @interval,
753
752
  "trial_end_at" => @trial_end_at,
753
+ "customer_id" => @customer_id,
754
754
  "return_url" => @return_url,
755
755
  "cancel_url" => @cancel_url,
756
756
  "source" => options.fetch(:source, nil),
757
- "coupon_id" => options.fetch(:coupon_id, nil),
758
- "customer_id" => customer_id
757
+ "coupon_id" => options.fetch(:coupon_id, nil)
759
758
  }
760
759
 
761
760
  response = Response.new(request.post(path, data, options))
@@ -838,17 +837,16 @@ module ProcessOut
838
837
 
839
838
  # Cancel a subscription. The reason may be provided as well.
840
839
  # Params:
841
- # +cancellation_reason+:: Cancellation reason
842
840
  # +options+:: +Hash+ of options
843
- def cancel(cancellation_reason, options = {})
841
+ def cancel(options = {})
844
842
  self.prefill(options)
845
843
 
846
844
  request = Request.new(@client)
847
845
  path = "/subscriptions/" + CGI.escape(@id) + ""
848
846
  data = {
849
847
  "cancel_at" => @cancel_at,
850
- "cancel_at_end" => options.fetch(:cancel_at_end, nil),
851
- "cancellation_reason" => cancellation_reason
848
+ "cancellation_reason" => @cancellation_reason,
849
+ "cancel_at_end" => options.fetch(:cancel_at_end, nil)
852
850
  }
853
851
 
854
852
  response = Response.new(request.delete(path, data, options))
@@ -203,16 +203,15 @@ module ProcessOut
203
203
  self
204
204
  end
205
205
 
206
- # Find a customer's token by its ID.
206
+ # Get the customer's tokens.
207
207
  # Params:
208
208
  # +customer_id+:: ID of the customer
209
- # +token_id+:: ID of the token
210
209
  # +options+:: +Hash+ of options
211
- def find(customer_id, token_id, options = {})
210
+ def fetch_customer_tokens(customer_id, options = {})
212
211
  self.prefill(options)
213
212
 
214
213
  request = Request.new(@client)
215
- path = "/customers/" + CGI.escape(customer_id) + "/tokens/" + CGI.escape(token_id) + ""
214
+ path = "/customers/" + CGI.escape(customer_id) + "/tokens"
216
215
  data = {
217
216
 
218
217
  }
@@ -220,65 +219,64 @@ module ProcessOut
220
219
  response = Response.new(request.get(path, data, options))
221
220
  return_values = Array.new
222
221
 
222
+ a = Array.new
223
223
  body = response.body
224
- body = body["token"]
225
-
226
-
227
- obj = Token.new(@client)
228
- return_values.push(obj.fill_with_data(body))
224
+ for v in body['tokens']
225
+ tmp = Token.new(@client)
226
+ tmp.fill_with_data(v)
227
+ a.push(tmp)
228
+ end
229
+
230
+ return_values.push(a)
229
231
 
230
232
 
231
233
 
232
234
  return_values[0]
233
235
  end
234
236
 
235
- # Create a new token for the given customer ID.
237
+ # Find a customer's token by its ID.
236
238
  # Params:
237
239
  # +customer_id+:: ID of the customer
238
- # +source+:: Source used to create the token (most likely a card token generated by ProcessOut.js)
240
+ # +token_id+:: ID of the token
239
241
  # +options+:: +Hash+ of options
240
- def create(customer_id, source, options = {})
242
+ def find(customer_id, token_id, options = {})
241
243
  self.prefill(options)
242
244
 
243
245
  request = Request.new(@client)
244
- path = "/customers/" + CGI.escape(customer_id) + "/tokens"
246
+ path = "/customers/" + CGI.escape(customer_id) + "/tokens/" + CGI.escape(token_id) + ""
245
247
  data = {
246
- "metadata" => @metadata,
247
- "settings" => options.fetch(:settings, nil),
248
- "target" => options.fetch(:target, nil),
249
- "source" => source
248
+
250
249
  }
251
250
 
252
- response = Response.new(request.post(path, data, options))
251
+ response = Response.new(request.get(path, data, options))
253
252
  return_values = Array.new
254
253
 
255
254
  body = response.body
256
255
  body = body["token"]
257
256
 
258
257
 
259
- return_values.push(self.fill_with_data(body))
258
+ obj = Token.new(@client)
259
+ return_values.push(obj.fill_with_data(body))
260
260
 
261
261
 
262
262
 
263
263
  return_values[0]
264
264
  end
265
265
 
266
- # Create a new token for the given customer ID from an authorization request
266
+ # Create a new token for the given customer ID.
267
267
  # Params:
268
- # +customer_id+:: ID of the customer
269
- # +source+:: Source used to create the token (most likely a card token generated by ProcessOut.js)
270
- # +target+:: Authorization request ID
271
268
  # +options+:: +Hash+ of options
272
- def create_from_request(customer_id, source, target, options = {})
269
+ def create(options = {})
273
270
  self.prefill(options)
274
271
 
275
272
  request = Request.new(@client)
276
- path = "/customers/" + CGI.escape(customer_id) + "/tokens"
273
+ path = "/customers/" + CGI.escape(@customer_id) + "/tokens"
277
274
  data = {
278
275
  "metadata" => @metadata,
276
+ "source" => options.fetch(:source, nil),
279
277
  "settings" => options.fetch(:settings, nil),
280
- "source" => source,
281
- "target" => target
278
+ "target" => options.fetch(:target, nil),
279
+ "set_default" => options.fetch(:set_default, nil)
282
280
  }
283
281
 
284
282
  response = Response.new(request.post(path, data, options))
@@ -1,3 +1,3 @@
1
1
  module ProcessOut
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel HUEZ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler