recurly 2.20.0 → 2.20.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76ffc24a326ee1c22ce5484b7077144a9824b7f73286f31e229ea2f91cd6fba0
4
- data.tar.gz: 5f5d614ff5665301e9506021a46571acd2b87f119599735639f035483c3c00d1
3
+ metadata.gz: d29c25aaafb1e7cde4ff0c6c3511bf672c10d5664b1223ccdb522cfed3b3a2de
4
+ data.tar.gz: ecd2e55f489d5ee557b5a2b0bc21cb88f19195b9815c046a36e90f66cbae5a20
5
5
  SHA512:
6
- metadata.gz: 0cf092352d0a7ae6d5ff08dde873cb012fbb246f921701dcefe1f097e4cb7e1d1ce8462ca7a7ae4e771918b45ade1d3415d21962219c0466e8c5b355b1892c03
7
- data.tar.gz: 254aa164e5abe43ab03cc050bb49d31358256040844134df93a356bf67ed65bc15c2f56e2efa959b2d2dafa7b932178d3602907f1d01a714f008c7681db6b932
6
+ metadata.gz: 014674a8200bbc58eba2a0238062da93c6f822b394e09d5031802504c9115efae0f380b7ca6ec3ff27a4c57b58f83656e8a823bd882c9ef4ecfe4fb38b3888bd
7
+ data.tar.gz: 332d7c771d10ceed0353a44c19f370235c8ea261f611803d56d3a914edfa47d05fc012d4e9ece51369bbeb82a558c0c1ee3b5fb9f113a628f06272de97ef2918
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.1'
18
18
  ```
19
19
 
20
20
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -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.1"
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.1
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-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri