recurly 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of recurly might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bb9d947bf4ade1ba41d01af854492a0aaed2c14
4
- data.tar.gz: 932f32fbeb55ffe0a0283329b41233884ebbba42
3
+ metadata.gz: 8056fc6015345ded3d9c2baa486fba05eb194007
4
+ data.tar.gz: a5ea96ebc7a49118092a9da20d2ec62c67f37fe6
5
5
  SHA512:
6
- metadata.gz: 11495e4a90f61e568b5b4fda91a19b874d22fae871fc18ff0116907f3999bd29263104394267958c32cd79b331e3d1449050397edb698f87b7c46dfe7575a913
7
- data.tar.gz: 874619eb79b2875b69efe9dcac271c1b1a9ae625da96d9ac7979727ccf9ab9793408dfebd74a031c72b2e76e64eb6de1b5824562316cc0f03bfbe3a6412c33ad
6
+ metadata.gz: d44276b4d6a7ca35e8a8eb5d8e9070eb31047d9f79f3638d620e78867d124d4d8f6ad3147f78e9fa2bedd89cc8564f4d86717d4c7bf87091f0df1d2d7d688bac
7
+ data.tar.gz: 778377d64a1572a29a6ac9f62d1624a302b03e0e3da2bb2760d2367495c4ae87134920cfa7eaf80eda2f806699423fc08706fc5185ea5d2713eb2bef9fab7f44
data/README.md CHANGED
@@ -12,7 +12,7 @@ Recurly is packaged as a Ruby gem. We recommend you install it with
12
12
  [Bundler](http://gembundler.com/) by adding the following line to your Gemfile:
13
13
 
14
14
  ``` ruby
15
- gem 'recurly', '~> 2.3.4'
15
+ gem 'recurly', '~> 2.3.5'
16
16
  ```
17
17
 
18
18
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -34,6 +34,7 @@ module Recurly
34
34
  start_date
35
35
  end_date
36
36
  created_at
37
+ quantity_remaining
37
38
  )
38
39
  alias to_param uuid
39
40
 
@@ -35,6 +35,7 @@ module Recurly
35
35
  currency
36
36
  created_at
37
37
  closed_at
38
+ amount_remaining_in_cents
38
39
  line_items
39
40
  transactions
40
41
  )
@@ -64,12 +65,58 @@ module Recurly
64
65
  self.class.find to_param, :format => 'pdf'
65
66
  end
66
67
 
68
+ # Refunds specific line items on the invoice.
69
+ #
70
+ # @return [Invoice, false] A new refund invoice, false if the invoice isn't
71
+ # refundable.
72
+ # @raise [Error] If the refund fails.
73
+ # @param line_items [Array, nil] An array of line items to refund.
74
+ def refund line_items = nil
75
+ return false unless link? :refund
76
+ refund = self.class.from_response(
77
+ follow_link :refund, :body => refund_line_items_to_xml(line_items)
78
+ )
79
+ refund
80
+ end
81
+
82
+ # Refunds the invoice for a specific amount.
83
+ #
84
+ # @return [Invoice, false] A new refund invoice, false if the invoice isn't
85
+ # refundable.
86
+ # @raise [Error] If the refund fails.
87
+ # @param amount_in_cents [Integer, nil] The amount (in cents) to refund.
88
+ def refund_amount amount_in_cents = nil
89
+ return false unless link? :refund
90
+ refund = self.class.from_response(
91
+ follow_link :refund, :body => refund_amount_to_xml(amount_in_cents)
92
+ )
93
+ refund
94
+ end
95
+
67
96
  private
68
97
 
69
98
  def initialize attributes = {}
70
99
  super({ :currency => Recurly.default_currency }.merge attributes)
71
100
  end
72
101
 
102
+ def refund_amount_to_xml amount_in_cents=nil
103
+ builder = XML.new("<invoice/>")
104
+ builder.add_element 'amount_in_cents', amount_in_cents
105
+ builder.to_s
106
+ end
107
+
108
+ def refund_line_items_to_xml line_items = []
109
+ builder = XML.new("<invoice/>")
110
+ node = builder.add_element 'line_items'
111
+ line_items.each do |line_item|
112
+ adj_node = node.add_element 'adjustment'
113
+ adj_node.add_element 'uuid', line_item[:adjustment].uuid
114
+ adj_node.add_element 'quantity', line_item[:quantity]
115
+ adj_node.add_element 'prorate', line_item[:prorate]
116
+ end
117
+ builder.to_s
118
+ end
119
+
73
120
  # Invoices are only writeable through {Account} instances.
74
121
  embedded! true
75
122
  undef save
@@ -2,7 +2,7 @@ module Recurly
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- PATCH = 4
5
+ PATCH = 5
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
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.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-03 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake