recurly 2.15.0 → 2.15.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
  SHA1:
3
- metadata.gz: 79a20ab75b4ef516202e7be58e66ae30cd07d3e4
4
- data.tar.gz: 1ed091b912940dfa9868139668b6f2d8b2c290d2
3
+ metadata.gz: '08185bb7912acbdca11fd008efc46dd66b287aed'
4
+ data.tar.gz: 41cae4eb087ce6c6abe567f4be13bc6603d4b9a3
5
5
  SHA512:
6
- metadata.gz: a3b448e8c15ee9731c1f20209645f14937c3deb9baf7a950ccc57f9c90c83dfe5263c66ca120686912f97d4006562bc45cc392a476e51ea908c622970b0920ad
7
- data.tar.gz: 821dcb4d1ec270a673ccd781312445e478520dd2994895435c71cb5d743eb30f2bfa9e9c010ab6765eb34412956f0b90d73840aa5324a3d1e9b26cb59239edb3
6
+ metadata.gz: 248ce1ee1bab0b1e38971837e0e4519aad201af96f6f13e2d3aa1ede337c73076701855fc7ab8e1523110d4fb6106ea2ec03cc703f7d4c658c63173eb23f31d2
7
+ data.tar.gz: 4818d9d58d4beea331f53923f2ac3f37583fa404a827d0ff33a409b79149a12849668628d68514e57b2c9aadabc184280068e044e04906cc8551b243d0cfb153
data/README.md CHANGED
@@ -156,27 +156,3 @@ If you plan on submitting a patch, please write tests for it (we use
156
156
  [MiniTest::Spec](http://bfts.rubyforge.org/minitest/MiniTest/Expectations.html)).
157
157
 
158
158
  If everything looks good, submit a pull request on GitHub and we'll bring in your changes.
159
-
160
- ## License
161
-
162
- (The MIT License.)
163
-
164
- © 2009–2017 Recurly Inc.
165
-
166
- Permission is hereby granted, free of charge, to any person obtaining a copy
167
- of this software and associated documentation files (the "Software"), to deal
168
- in the Software without restriction, including without limitation the rights
169
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
170
- copies of the Software, and to permit persons to whom the Software is
171
- furnished to do so, subject to the following conditions:
172
-
173
- The above copyright notice and this permission notice shall be included in all
174
- copies or substantial portions of the Software.
175
-
176
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
179
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
180
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
181
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
182
- SOFTWARE.
data/lib/recurly.rb CHANGED
@@ -4,6 +4,7 @@ module Recurly
4
4
  require 'recurly/helper'
5
5
  require 'recurly/api'
6
6
  require 'recurly/resource'
7
+ require 'recurly/shipping_address'
7
8
  require 'recurly/billing_info'
8
9
  require 'recurly/account'
9
10
  require 'recurly/account_balance'
@@ -23,7 +24,6 @@ module Recurly
23
24
  require 'recurly/measured_unit'
24
25
  require 'recurly/plan'
25
26
  require 'recurly/redemption'
26
- require 'recurly/shipping_address'
27
27
  require 'recurly/subscription'
28
28
  require 'recurly/subscription_add_on'
29
29
  require 'recurly/transaction'
@@ -73,6 +73,8 @@ module Recurly
73
73
  has_future_subscription
74
74
  has_canceled_subscription
75
75
  has_past_due_invoice
76
+ has_paused_subscription
77
+ preferred_locale
76
78
  )
77
79
  alias to_param account_code
78
80
 
@@ -21,6 +21,9 @@ module Recurly
21
21
  # @return [Pager<Adjustment>, []]
22
22
  has_many :credit_adjustments, class_name: :Adjustment, readonly: true
23
23
 
24
+ # @return [ShippingAddress, nil]
25
+ has_one :shipping_address, class_name: :ShippingAddress, readonly: false
26
+
24
27
  define_attribute_methods %w(
25
28
  uuid
26
29
  state
@@ -50,6 +53,7 @@ module Recurly
50
53
  proration_rate
51
54
  credit_reason_code
52
55
  original_adjustment_uuid
56
+ shipping_address_id
53
57
  )
54
58
  alias to_param uuid
55
59
 
data/lib/recurly/api.rb CHANGED
@@ -17,7 +17,7 @@ module Recurly
17
17
  @@base_uri = "https://api.recurly.com/v2/"
18
18
  @@valid_domains = [".recurly.com"]
19
19
 
20
- RECURLY_API_VERSION = '2.10'
20
+ RECURLY_API_VERSION = '2.11'
21
21
 
22
22
  FORMATS = Helper.hash_with_indifferent_read_access(
23
23
  'pdf' => 'application/pdf',
@@ -32,7 +32,7 @@ module Recurly
32
32
  # @return [Pager<Redemption>, []]
33
33
  has_many :redemptions
34
34
 
35
- # @return [Pager<ShippingAddress>, [ShippingAddress], []]
35
+ # @return [ShippingAddress, nil]
36
36
  has_one :shipping_address, class_name: :ShippingAddress, readonly: true
37
37
 
38
38
  # @return [Pager<Invoice>, []]
@@ -19,18 +19,42 @@ module Recurly
19
19
  # in the same way you would when creating a {Subscription} with a new account.
20
20
  #
21
21
  # You can also pass in adjustments and invoicing data to be passed to the invoice.
22
+ #
23
+ # There are multiple ways to set the shipping addresses:
24
+ # 1. Use {Purchase#shipping_address_id} If you want to apply an existing shipping
25
+ # address to all subscriptions and adjustments in this purchase.
26
+ # 2. Add multiple shipping addresses to {Account#shipping_addresses}. The last
27
+ # address in the list will apply to all subscriptions and adjustments
28
+ # in this purchase.
29
+ # 3. Use {Subscription#shipping_address_id} or {Subscription#shipping_address}
30
+ # to set a shipping address for only the subscription.
31
+ # 4. Use {Adjustment#shipping_address_id} or {Adjustment#shipping_address}
32
+ # to set a shipping address for only the adjustment.
33
+ #
22
34
  # @example
23
35
  # require 'securerandom'
24
36
  #
25
- # purchase = Recurly::Purchase.new({
37
+ # purchase = Recurly::Purchase.new(
26
38
  # currency: 'USD',
27
39
  # collection_method: :automatic,
28
40
  # account: {
29
41
  # account_code: SecureRandom.uuid,
42
+ # shipping_addresses: [
43
+ # {
44
+ # first_name: 'Benjamin',
45
+ # last_name: 'Du Monde',
46
+ # address1: '400 Dolores St.',
47
+ # city: 'San Francisco',
48
+ # state: 'CA',
49
+ # zip: '94110',
50
+ # country: 'US',
51
+ # nickname: 'Home'
52
+ # }
53
+ # ],
30
54
  # billing_info: {
31
55
  # first_name: 'Benjamin',
32
56
  # last_name: 'Du Monde',
33
- # address1: '400 Alabama St',
57
+ # address1: '400 Alabama St.',
34
58
  # city: 'San Francisco',
35
59
  # state: 'CA',
36
60
  # zip: '94110',
@@ -54,7 +78,7 @@ module Recurly
54
78
  # revenue_schedule_type: :at_invoice
55
79
  # }
56
80
  # ]
57
- # })
81
+ # )
58
82
  #
59
83
  # begin
60
84
  # preview_invoice = Recurly::Purchase.preview!(purchase)
@@ -98,6 +122,7 @@ module Recurly
98
122
  terms_and_conditions
99
123
  customer_notes
100
124
  vat_reverse_charge_notes
125
+ shipping_address_id
101
126
  )
102
127
 
103
128
  class << self
@@ -80,6 +80,8 @@ module Recurly
80
80
  no_billing_info_reason
81
81
  imported_trial
82
82
  credit_customer_notes
83
+ remaining_pause_cycles
84
+ paused_at
83
85
  )
84
86
  alias to_param uuid
85
87
 
@@ -220,8 +222,8 @@ module Recurly
220
222
 
221
223
  # Update the notes sections of the subscription
222
224
  #
225
+ # @param notes [Hash] should be the notes parameters you wish to update
223
226
  # @return [true, false] +true+ when successful, +false+ when unable to
224
- # @params notes [Hash] should be the notes parameters you wish to update
225
227
  def update_notes(notes)
226
228
  return false unless link? :notes
227
229
  self.attributes = notes
@@ -229,6 +231,40 @@ module Recurly
229
231
  true
230
232
  end
231
233
 
234
+ # Pauses a subscription or cancels a scheduled pause.
235
+ #
236
+ # * For an active subscription without a pause scheduled already,
237
+ # this will schedule a pause period to begin at the next renewal
238
+ # date for the specified number of billing cycles (remaining_pause_cycles).
239
+ # * When a scheduled pause already exists, this will update the remaining
240
+ # pause cycles with the new value sent. When zero (0) remaining_pause_cycles
241
+ # is sent for a subscription with a scheduled pause, the pause will be canceled.
242
+ # * For a paused subscription, the remaining_pause_cycles will adjust the
243
+ # length of the current pause period. Sending zero (0) in the remaining_pause_cycles
244
+ # field will cause the subscription to be resumed at the next renewal date.
245
+ #
246
+ # @param remaining_pause_cycles [Integer] The number of billing cycles that the subscription will be paused.
247
+ # @return true
248
+ def pause(remaining_pause_cycles)
249
+ builder = XML.new("<subscription/>")
250
+ builder.add_element('remaining_pause_cycles', remaining_pause_cycles)
251
+ reload API.put("#{uri}/pause", builder.to_s)
252
+ true
253
+ end
254
+
255
+ # Resumes a paused subscription.
256
+ #
257
+ # For a paused subscription, this will immediately resume the subscription
258
+ # from the pause, produce an invoice, and return the newly resumed subscription.
259
+ # Any at-renewal subscription changes will be immediately applied
260
+ # when the subscription resumes.
261
+ #
262
+ # @return true
263
+ def resume
264
+ reload API.put("#{uri}/resume")
265
+ true
266
+ end
267
+
232
268
  # Overrides the behavior of `update_attributes` in Resource class so ensure
233
269
  # all attributes are marked as dirty if the plan code changes
234
270
  def update_attributes attributes = {}
@@ -2,7 +2,7 @@ module Recurly
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 15
5
- PATCH = 0
5
+ PATCH = 1
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
data/lib/recurly/xml.rb CHANGED
@@ -84,17 +84,36 @@ module Recurly
84
84
  end
85
85
 
86
86
  if defined? Nokogiri
87
- if RUBY_VERSION < "2.1.0"
88
- raise <<-MSG
87
+ insecure_noko_msg = <<-MSG
89
88
 
90
- You are attempting to use an insecure version of
91
- nokogiri on an insecure version of ruby. Please see
92
- the documentation on supported versions for more information:
93
- https://github.com/recurly/recurly-client-ruby#supported-versions
89
+ You are attempting to use an insecure version of
90
+ nokogiri on an insecure version of ruby. Please see
91
+ the documentation on supported versions for more information:
92
+ https://github.com/recurly/recurly-client-ruby#supported-versions
94
93
 
95
- MSG
94
+ MSG
95
+ if RUBY_VERSION < "2.1.0"
96
+ raise insecure_noko_msg
96
97
  else
97
98
  require 'recurly/xml/nokogiri'
99
+ version = Gem::Version.new(Nokogiri::VERSION)
100
+
101
+ if version.segments.length == 3
102
+ major, minor, patch = version.segments
103
+ else
104
+ major, minor, patch, _pre = version.segments
105
+ end
106
+
107
+ # Only warning users for now
108
+ if minor < 6
109
+ puts insecure_noko_msg
110
+ elsif minor == 6 && patch < 8
111
+ puts insecure_noko_msg
112
+ elsif minor == 7 && patch < 2
113
+ puts insecure_noko_msg
114
+ elsif minor == 8 && patch < 2
115
+ puts insecure_noko_msg
116
+ end
98
117
  end
99
118
  else
100
119
  require 'recurly/xml/rexml'
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.15.0
4
+ version: 2.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.1
19
+ version: 1.8.2
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.7.1
26
+ version: 1.8.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement