recurly 2.14.1 → 2.15.0
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 +5 -5
- data/README.md +1 -1
- data/lib/recurly.rb +0 -18
- data/lib/recurly/gift_card.rb +1 -0
- data/lib/recurly/invoice.rb +4 -4
- data/lib/recurly/resource.rb +13 -3
- data/lib/recurly/resource/pager.rb +62 -3
- data/lib/recurly/version.rb +2 -2
- data/lib/recurly/webhook.rb +4 -1
- data/lib/recurly/webhook/gift_card_notification.rb +8 -0
- data/lib/recurly/webhook/purchased_gift_card_notification.rb +7 -0
- data/lib/recurly/webhook/redeemed_gift_card_notification.rb +7 -0
- data/lib/recurly/webhook/updated_balance_gift_card_notification.rb +7 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79a20ab75b4ef516202e7be58e66ae30cd07d3e4
|
4
|
+
data.tar.gz: 1ed091b912940dfa9868139668b6f2d8b2c290d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3b448e8c15ee9731c1f20209645f14937c3deb9baf7a950ccc57f9c90c83dfe5263c66ca120686912f97d4006562bc45cc392a476e51ea908c622970b0920ad
|
7
|
+
data.tar.gz: 821dcb4d1ec270a673ccd781312445e478520dd2994895435c71cb5d743eb30f2bfa9e9c010ab6765eb34412956f0b90d73840aa5324a3d1e9b26cb59239edb3
|
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.
|
17
|
+
gem 'recurly', '~> 2.15.0'
|
18
18
|
```
|
19
19
|
|
20
20
|
Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
|
data/lib/recurly.rb
CHANGED
@@ -89,8 +89,6 @@ module Recurly
|
|
89
89
|
end
|
90
90
|
|
91
91
|
# Assigns a logger to log requests/responses and more.
|
92
|
-
# The logger can only be set if the environment variable
|
93
|
-
# `RECURLY_INSECURE_DEBUG` equals `true`.
|
94
92
|
#
|
95
93
|
# @return [Logger, nil]
|
96
94
|
# @example
|
@@ -102,22 +100,6 @@ module Recurly
|
|
102
100
|
# Recurly.logger = nil # Or Recurly.logger = Logger.new nil
|
103
101
|
attr_accessor :logger
|
104
102
|
|
105
|
-
def logger=(logger)
|
106
|
-
if ENV['RECURLY_INSECURE_DEBUG'].to_s.downcase == 'true'
|
107
|
-
@logger = logger
|
108
|
-
puts <<-MSG
|
109
|
-
[WARNING] Recurly logger enabled. The logger has the potential to leak
|
110
|
-
PII and should never be used in production environments.
|
111
|
-
MSG
|
112
|
-
else
|
113
|
-
puts <<-MSG
|
114
|
-
[WARNING] Recurly logger has been disabled. If you wish to use it,
|
115
|
-
only do so in a non-production environment and make sure
|
116
|
-
the `RECURLY_INSECURE_DEBUG` environment variable is set to `true`.
|
117
|
-
MSG
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
103
|
# Convenience logging method includes a Logger#progname dynamically.
|
122
104
|
# @return [true, nil]
|
123
105
|
def log level, message
|
data/lib/recurly/gift_card.rb
CHANGED
data/lib/recurly/invoice.rb
CHANGED
@@ -164,28 +164,28 @@ module Recurly
|
|
164
164
|
|
165
165
|
# Refunds specific line items on the invoice.
|
166
166
|
#
|
167
|
-
# @return [
|
167
|
+
# @return [Invoice, false] Invoice if successful, false if the invoice isn't
|
168
168
|
# refundable.
|
169
169
|
# @raise [Error] If the refund fails.
|
170
170
|
# @param line_items [Array, nil] An array of line items to refund.
|
171
171
|
# @param refund_method ["credit_first", "transaction_first"] The method used to refund.
|
172
172
|
def refund(line_items = nil, refund_method = 'credit_first')
|
173
173
|
return false unless link? :refund
|
174
|
-
|
174
|
+
self.class.from_response(
|
175
175
|
follow_link :refund, :body => refund_line_items_to_xml(line_items, refund_method)
|
176
176
|
)
|
177
177
|
end
|
178
178
|
|
179
179
|
# Refunds the invoice for a specific amount.
|
180
180
|
#
|
181
|
-
# @return [Invoice, false]
|
181
|
+
# @return [Invoice, false] Invoice if successful, false if the invoice isn't
|
182
182
|
# refundable.
|
183
183
|
# @raise [Error] If the refund fails.
|
184
184
|
# @param amount_in_cents [Integer, nil] The amount (in cents) to refund.
|
185
185
|
# @param refund_method ["credit_first", "transaction_first"] The method used to refund.
|
186
186
|
def refund_amount amount_in_cents = nil, refund_method = 'credit_first'
|
187
187
|
return false unless link? :refund
|
188
|
-
|
188
|
+
self.class.from_response(
|
189
189
|
follow_link :refund, :body => refund_amount_to_xml(amount_in_cents, refund_method)
|
190
190
|
)
|
191
191
|
end
|
data/lib/recurly/resource.rb
CHANGED
@@ -285,14 +285,24 @@ module Recurly
|
|
285
285
|
|
286
286
|
# Iterates through every record by automatically paging.
|
287
287
|
#
|
288
|
+
# @option options [Hash] Optional hash to pass to Pager#paginate
|
289
|
+
#
|
288
290
|
# @return [nil]
|
289
291
|
# @param [Integer] per_page The number of records returned per request.
|
290
292
|
# @yield [record]
|
291
|
-
# @see Pager#
|
293
|
+
# @see Pager#paginate
|
292
294
|
# @example
|
293
295
|
# Recurly::Account.find_each { |a| p a }
|
294
|
-
|
295
|
-
|
296
|
+
# @example With sorting and filter
|
297
|
+
# opts = {
|
298
|
+
# begin_time: DateTime.new(2016,1,1),
|
299
|
+
# sort: :updated_at
|
300
|
+
# }
|
301
|
+
# Recurly::Account.find_each(opts) do |a|
|
302
|
+
# puts a.inspect
|
303
|
+
# end
|
304
|
+
def find_each(options = {}, &block)
|
305
|
+
paginate(options).find_each(&block)
|
296
306
|
end
|
297
307
|
|
298
308
|
# @return [Integer] The total record count of the resource in question.
|
@@ -20,6 +20,34 @@ module Recurly
|
|
20
20
|
#
|
21
21
|
# account.transactions.new(attributes) # or #create, or #create!
|
22
22
|
# # => #<Recurly::Transaction ...>
|
23
|
+
#
|
24
|
+
# account.transactions.find_each do |transaction|
|
25
|
+
# puts transaction
|
26
|
+
# end
|
27
|
+
# @example Iterate through a page of invoices at a time
|
28
|
+
# opts = {
|
29
|
+
# order: :desc,
|
30
|
+
# state: :collected
|
31
|
+
# }
|
32
|
+
# invoices = Recurly::Invoice.paginate(opts)
|
33
|
+
# begin
|
34
|
+
# invoices.each do |invoice|
|
35
|
+
# puts invoice.invoice_number
|
36
|
+
# end
|
37
|
+
# puts "fetching next page..."
|
38
|
+
# end while invoices.next
|
39
|
+
# @example Passing sorting and filtering parameters
|
40
|
+
# opts = {
|
41
|
+
# begin_time: DateTime.new(2016,1,1),
|
42
|
+
# end_time: DateTime.new(2017,1,1),
|
43
|
+
# sort: :updated_at,
|
44
|
+
# order: :desc,
|
45
|
+
# state: :collected
|
46
|
+
# }
|
47
|
+
# Recurly::Invoice.find_each(opts) do |invoice|
|
48
|
+
# puts invoice
|
49
|
+
# end
|
50
|
+
#
|
23
51
|
class Pager
|
24
52
|
include Enumerable
|
25
53
|
|
@@ -68,6 +96,13 @@ module Recurly
|
|
68
96
|
@collection = nil
|
69
97
|
end
|
70
98
|
|
99
|
+
# This will tell you if there are any associated resources
|
100
|
+
# on the server by checking the presence of a link in the xml
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# # if <invoices href="..." /> is present, will return true
|
104
|
+
# account.invoices.any?
|
105
|
+
# #=> true
|
71
106
|
# @return [Boolean] whether or not the xml element is present
|
72
107
|
def any?
|
73
108
|
!@uri.nil?
|
@@ -78,6 +113,17 @@ module Recurly
|
|
78
113
|
@uri ||= resource_class.collection_path
|
79
114
|
end
|
80
115
|
|
116
|
+
# Calls the server to get the count of server side resources.
|
117
|
+
#
|
118
|
+
# @example Count collected invoices in 2016
|
119
|
+
# opts = {
|
120
|
+
# begin_time: DateTime.new(2016,1,1),
|
121
|
+
# end_time: DateTime.new(2017,1,1),
|
122
|
+
# state: :collected
|
123
|
+
# }
|
124
|
+
# count = Recurly::Invoice.paginate(opts).count
|
125
|
+
# #=> 42
|
126
|
+
#
|
81
127
|
# @return [Integer] The total record count of the resource in question.
|
82
128
|
# @see Resource.count
|
83
129
|
def count
|
@@ -127,12 +173,25 @@ module Recurly
|
|
127
173
|
end
|
128
174
|
alias reload load!
|
129
175
|
|
176
|
+
|
130
177
|
# @return [Pager] Duplicates the pager, updating it with the options
|
131
178
|
# supplied. Useful for resource scopes.
|
132
|
-
# @
|
179
|
+
# @option options [String, Symbol] :sort The attribute that will be used to order
|
180
|
+
# records: <tt>created_at</tt>, <tt>updated_at</tt>. Defaults to <tt>created_at</tt>.
|
181
|
+
# @option options [String, Symbol] :order The order in which records will be
|
182
|
+
# returned: <tt>asc</tt> for ascending order, <tt>desc</tt> for descending order.
|
183
|
+
# Defaults to <tt>desc</tt>.
|
184
|
+
# @option options [DateTime, String] :begin_time Operates on the attribute specified by the
|
185
|
+
# <tt>sort</tt> parameter. Filters records to only include those with datetimes
|
186
|
+
# greater than or equal to the supplied datetime. Accepts an ISO 8601
|
187
|
+
# date or date and time.
|
188
|
+
# @option options [DateTime, String] :end_time Operates on the attribute specified by
|
189
|
+
# the <tt>sort</tt> parameter. Filters records to only include those with
|
190
|
+
# datetimes less than or equal to the supplied datetime. Accepts an
|
191
|
+
# ISO 8601 date or date and time.
|
133
192
|
# @example
|
134
|
-
# Recurly::Account.
|
135
|
-
def paginate
|
193
|
+
# Recurly::Account.paginate(sort: :updated_at, per_page: 20)
|
194
|
+
def paginate(options = {})
|
136
195
|
dup.instance_eval {
|
137
196
|
@collection = @etag = nil
|
138
197
|
@options = @options.merge options
|
data/lib/recurly/version.rb
CHANGED
data/lib/recurly/webhook.rb
CHANGED
@@ -47,8 +47,11 @@ module Recurly
|
|
47
47
|
autoload :ProcessingInvoiceNotification, 'recurly/webhook/processing_invoice_notification'
|
48
48
|
autoload :ScheduledPaymentNotification, 'recurly/webhook/scheduled_payment_notification'
|
49
49
|
autoload :NewDunningEventNotification, 'recurly/webhook/new_dunning_event_notification'
|
50
|
+
autoload :GiftCardNotification, 'recurly/webhook/gift_card_notification'
|
51
|
+
autoload :PurchasedGiftCardNotification, 'recurly/webhook/purchased_gift_card_notification'
|
52
|
+
autoload :RedeemedGiftCardNotification, 'recurly/webhook/redeemed_gift_card_notification'
|
53
|
+
autoload :UpdatedBalanceGiftCardNotification,'recurly/webhook/updated_balance_gift_card_notification'
|
50
54
|
autoload :NewUsageNotification, 'recurly/webhook/new_usage_notification'
|
51
|
-
|
52
55
|
# This exception is raised if the Webhook Notification initialization fails
|
53
56
|
class NotificationError < Error
|
54
57
|
end
|
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.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recurly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/recurly/webhook/dunning_notification.rb
|
211
211
|
- lib/recurly/webhook/expired_subscription_notification.rb
|
212
212
|
- lib/recurly/webhook/failed_payment_notification.rb
|
213
|
+
- lib/recurly/webhook/gift_card_notification.rb
|
213
214
|
- lib/recurly/webhook/invoice_notification.rb
|
214
215
|
- lib/recurly/webhook/new_account_notification.rb
|
215
216
|
- lib/recurly/webhook/new_dunning_event_notification.rb
|
@@ -220,7 +221,9 @@ files:
|
|
220
221
|
- lib/recurly/webhook/past_due_invoice_notification.rb
|
221
222
|
- lib/recurly/webhook/processing_invoice_notification.rb
|
222
223
|
- lib/recurly/webhook/processing_payment_notification.rb
|
224
|
+
- lib/recurly/webhook/purchased_gift_card_notification.rb
|
223
225
|
- lib/recurly/webhook/reactivated_account_notification.rb
|
226
|
+
- lib/recurly/webhook/redeemed_gift_card_notification.rb
|
224
227
|
- lib/recurly/webhook/renewed_subscription_notification.rb
|
225
228
|
- lib/recurly/webhook/scheduled_payment_notification.rb
|
226
229
|
- lib/recurly/webhook/subscription_notification.rb
|
@@ -228,6 +231,7 @@ files:
|
|
228
231
|
- lib/recurly/webhook/successful_refund_notification.rb
|
229
232
|
- lib/recurly/webhook/transaction_notification.rb
|
230
233
|
- lib/recurly/webhook/updated_account_notification.rb
|
234
|
+
- lib/recurly/webhook/updated_balance_gift_card_notification.rb
|
231
235
|
- lib/recurly/webhook/updated_subscription_notification.rb
|
232
236
|
- lib/recurly/webhook/void_payment_notification.rb
|
233
237
|
- lib/recurly/xml.rb
|
@@ -255,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
259
|
version: '0'
|
256
260
|
requirements: []
|
257
261
|
rubyforge_project:
|
258
|
-
rubygems_version: 2.
|
262
|
+
rubygems_version: 2.6.13
|
259
263
|
signing_key:
|
260
264
|
specification_version: 4
|
261
265
|
summary: Recurly API Client
|