recurly 2.20.0 → 2.20.2

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
  SHA256:
3
- metadata.gz: 76ffc24a326ee1c22ce5484b7077144a9824b7f73286f31e229ea2f91cd6fba0
4
- data.tar.gz: 5f5d614ff5665301e9506021a46571acd2b87f119599735639f035483c3c00d1
3
+ metadata.gz: 7b9df673d417f04fe0f5bed15fe3813eebcd79909b343c767e23b7c398ae8146
4
+ data.tar.gz: 20f3090cb3f98c01961ceeeb32062a70b7298bb76739a3590f1f45c3641a0302
5
5
  SHA512:
6
- metadata.gz: 0cf092352d0a7ae6d5ff08dde873cb012fbb246f921701dcefe1f097e4cb7e1d1ce8462ca7a7ae4e771918b45ade1d3415d21962219c0466e8c5b355b1892c03
7
- data.tar.gz: 254aa164e5abe43ab03cc050bb49d31358256040844134df93a356bf67ed65bc15c2f56e2efa959b2d2dafa7b932178d3602907f1d01a714f008c7681db6b932
6
+ metadata.gz: 1eeed62429b20bb43da5e7c255f492ba188bba4aab7b561f138fe517250a17151e1878abbabf7270d8b9ccac3c5209bfc2dc2d45e70d694a028fbed2f3071862
7
+ data.tar.gz: 1240588db91fd5c2f2b31c9acdc2aecc19e9b07e0aba7ecd39ac279edc44ff37369b303a0ced725c037520b7a09c69f48acce16875e4dfb9224c465d1f37693a
data/README.md CHANGED
@@ -14,7 +14,7 @@ Recurly is packaged as a Ruby gem. We recommend you install it with
14
14
  [Bundler](http://gembundler.com/) by adding the following line to your Gemfile:
15
15
 
16
16
  ``` ruby
17
- gem 'recurly', '~> 2.20.0'
17
+ gem 'recurly', '~> 2.20.2'
18
18
  ```
19
19
 
20
20
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -15,6 +15,7 @@ module Recurly
15
15
 
16
16
  define_attribute_methods %w(
17
17
  account
18
+ uuid
18
19
  external_id
19
20
  external_product_reference
20
21
  quantity
@@ -53,5 +54,9 @@ module Recurly
53
54
  def self.find_by_external_id(external_id)
54
55
  self.find("external-id-#{external_id}")
55
56
  end
57
+
58
+ def self.find_by_uuid(uuid)
59
+ self.find("uuid-#{uuid}")
60
+ end
56
61
  end
57
62
  end
@@ -249,6 +249,25 @@ module Recurly
249
249
  )
250
250
  end
251
251
 
252
+ # Refunds the invoice for a specific percentage.
253
+ #
254
+ # @return [Invoice, false] Invoice if successful, false if the invoice isn't
255
+ # refundable.
256
+ # @raise [Error] If the refund fails.
257
+ # @param percentage [Integer, nil] The percentage to refund from the invoice.
258
+ # @param refund_method ["credit_first", "transaction_first", "all_transaction", "all_credit"] The method used to refund.
259
+ # @param external_refund [true, false] Designates that the refund transactions created are manual.
260
+ # @param credit_customer_notes [String] Adds notes to refund credit invoice.
261
+ # @param payment_method [String] Creates the manual transactions with this payment method. Allowed if *external_refund* is true.
262
+ # @param description [String] Sets this value as the *transaction_note* on the manual transactions created. Allowed if *external_refund* is true.
263
+ # @param refunded_at [DateTime] Sets this value as the *collected_at* on the manual transactions created. Allowed if *external_refund* is true.
264
+ def refund_percentage(percentage = nil, refund_method = 'credit_first', options = {})
265
+ return false unless link? :refund
266
+ self.class.from_response(
267
+ follow_link :refund, :body => refund_percentage_to_xml(percentage, refund_method, options)
268
+ )
269
+ end
270
+
252
271
  def xml_keys
253
272
  super - ['currency']
254
273
  end
@@ -285,6 +304,16 @@ module Recurly
285
304
  builder.to_s
286
305
  end
287
306
 
307
+ def refund_percentage_to_xml(percentage = nil, refund_method = nil, options = {})
308
+ builder = XML.new("<invoice/>")
309
+ builder.add_element 'refund_method', refund_method
310
+ builder.add_element 'percentage', percentage
311
+ options.each do |k, v|
312
+ builder.add_element k.to_s, v
313
+ end
314
+ builder.to_s
315
+ end
316
+
288
317
  def refund_line_items_to_xml(line_items = nil, refund_method = nil, options = {})
289
318
  builder = XML.new("<invoice/>")
290
319
  builder.add_element 'refund_method', refund_method
@@ -296,8 +325,10 @@ module Recurly
296
325
  line_items.each do |line_item|
297
326
  adj_node = node.add_element 'adjustment'
298
327
  adj_node.add_element 'uuid', line_item[:adjustment].uuid
299
- adj_node.add_element 'quantity', line_item[:quantity]
328
+ adj_node.add_element 'quantity', line_item[:quantity] if line_item.key?(:quantity)
300
329
  adj_node.add_element('quantity_decimal', line_item[:quantity_decimal]) if line_item.key?(:quantity_decimal)
330
+ adj_node.add_element 'percentage', line_item[:percentage] if line_item.key?(:percentage)
331
+ adj_node.add_element 'amount_in_cents', line_item[:amount_in_cents] if line_item.key?(:amount_in_cents)
301
332
  adj_node.add_element 'prorate', line_item[:prorate]
302
333
  end
303
334
  builder.to_s
@@ -1,6 +1,6 @@
1
1
  module Recurly
2
2
  module Version
3
- VERSION = "2.20.0"
3
+ VERSION = "2.20.2"
4
4
 
5
5
  class << self
6
6
  def inspect
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.0
4
+ version: 2.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri