recurly 2.10.1 → 2.10.2
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 +4 -4
- data/README.md +10 -10
- data/lib/recurly/account.rb +35 -12
- data/lib/recurly/account_balance.rb +11 -1
- data/lib/recurly/adjustment.rb +7 -5
- data/lib/recurly/billing_info.rb +3 -0
- data/lib/recurly/coupon.rb +31 -11
- data/lib/recurly/delivery.rb +4 -0
- data/lib/recurly/gift_card.rb +18 -2
- data/lib/recurly/invoice.rb +20 -5
- data/lib/recurly/js.rb +3 -1
- data/lib/recurly/measured_unit.rb +3 -0
- data/lib/recurly/plan.rb +1 -0
- data/lib/recurly/purchase.rb +12 -3
- data/lib/recurly/redemption.rb +1 -1
- data/lib/recurly/shipping_address.rb +1 -0
- data/lib/recurly/subscription.rb +15 -14
- data/lib/recurly/subscription_add_on.rb +1 -2
- data/lib/recurly/transaction.rb +6 -7
- data/lib/recurly/version.rb +1 -1
- metadata +9 -11
- data/lib/ecurly.rb +0 -1
- data/lib/recurly/all.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 984fbc5162b49f6c95574b5c95eda47c740ade47
|
4
|
+
data.tar.gz: f75c30db75dce51b6f8bc51082105bf6a57c95ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34c727df7638eb67ec860c15e0e9991fcfeebcd6a01a028c2ff935547a14562ecdda2ae3337ba46ecaee1495f57eaee2c5014e848687f95ac699471850dcd437
|
7
|
+
data.tar.gz: 200f5d800e6cf183ce182e56be1b8dc8ee476ad229a3f5eaa363d7311d4a8c407a71dbe37d98fe19c01224f27fa9da10ee98314d107b7191aaa86cafb60dabcf
|
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.10.
|
17
|
+
gem 'recurly', '~> 2.10.2'
|
18
18
|
```
|
19
19
|
|
20
20
|
Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
|
@@ -63,15 +63,20 @@ recurly.configure({ publicKey: '<%= Recurly.js.public_key %>'});
|
|
63
63
|
```
|
64
64
|
|
65
65
|
The client library currently uses a Net::HTTP adapter. If you need to
|
66
|
-
configure the settings passed to Net::HTTP (e.g., an SSL certificates path),
|
67
|
-
make sure you assign them
|
66
|
+
configure the settings passed to Net::HTTP (e.g., an SSL certificates path or timeout lengths),
|
67
|
+
make sure you assign them when initializing the library:
|
68
68
|
|
69
69
|
``` ruby
|
70
70
|
Recurly::API.net_http = {
|
71
|
-
:
|
71
|
+
ca_path: "/etc/ssl/certs",
|
72
|
+
open_timeout: 5, # 5 seconds (defaults to 60)
|
73
|
+
read_timeout: 45 # 45 seconds (defaults to 60)
|
72
74
|
}
|
73
75
|
```
|
74
76
|
|
77
|
+
To see which keys are supported for this Hash, see the `Attributes` section
|
78
|
+
of the [Net::HTTP documentation](http://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html) for your ruby version.
|
79
|
+
|
75
80
|
## Multi-Threaded Configuration
|
76
81
|
If you are using the client in a multi-threaded environment and require a different configuration per
|
77
82
|
thread you can use the following within the thread's context:
|
@@ -116,11 +121,6 @@ Recurly's gem API is available
|
|
116
121
|
- [https://support.recurly.com](https://support.recurly.com)
|
117
122
|
- [stackoverflow](http://stackoverflow.com/questions/tagged/recurly)
|
118
123
|
|
119
|
-
## Announcements
|
120
|
-
|
121
|
-
- [@recurly](https://twitter.com/recurly)
|
122
|
-
- [Google Group Announcements](https://groups.google.com/group/recurly-api)
|
123
|
-
|
124
124
|
## Contributing
|
125
125
|
|
126
126
|
Developing for the Recurly gem is easy with [Bundler](http://gembundler.com/).
|
@@ -161,7 +161,7 @@ If everything looks good, submit a pull request on GitHub and we'll bring in you
|
|
161
161
|
|
162
162
|
(The MIT License.)
|
163
163
|
|
164
|
-
© 2009–
|
164
|
+
© 2009–2017 Recurly Inc.
|
165
165
|
|
166
166
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
167
167
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/recurly/account.rb
CHANGED
@@ -1,31 +1,48 @@
|
|
1
1
|
module Recurly
|
2
|
+
# Accounts are core to managing your customers inside of Recurly.
|
3
|
+
# The account object stores the entire Recurly history of your customer and acts as the entry point
|
4
|
+
# for working with a customer's billing information, subscription data, transactions, invoices and more.
|
5
|
+
#
|
6
|
+
# Recurly Documentation: https://dev.recurly.com/docs/account-object
|
2
7
|
class Account < Resource
|
3
8
|
# @macro [attach] scope
|
4
9
|
# @scope class
|
5
10
|
# @return [Pager<Account>] A pager that yields +$1+ accounts.
|
6
|
-
scope :active, :
|
7
|
-
scope :closed, :
|
8
|
-
scope :subscriber, :
|
9
|
-
scope :non_subscriber, :
|
10
|
-
scope :past_due, :
|
11
|
-
|
12
|
-
# @
|
13
|
-
# @return [Pager<Resource>, []] A pager that yields $1 for persisted
|
14
|
-
# accounts; an empty array otherwise.
|
11
|
+
scope :active, state: :active
|
12
|
+
scope :closed, state: :closed
|
13
|
+
scope :subscriber, state: :subscriber
|
14
|
+
scope :non_subscriber, state: :non_subscriber
|
15
|
+
scope :past_due, state: :past_due
|
16
|
+
|
17
|
+
# @return [Pager<Adjustment>, []] A pager that yields Adjustments for persisted
|
15
18
|
has_many :adjustments
|
19
|
+
|
20
|
+
# @return [Pager<Invoice>, []] A pager that yields Invoices for persisted
|
16
21
|
has_many :invoices
|
22
|
+
|
23
|
+
# @return [Pager<Subscription>, []] A pager that yields Subscriptions for persisted
|
17
24
|
has_many :subscriptions
|
25
|
+
|
26
|
+
# @return [Pager<Transaction>, []] A pager that yields Transaction for persisted
|
18
27
|
has_many :transactions
|
28
|
+
|
29
|
+
# @return [Pager<Redemption>, []] A pager that yields Redemptions for persisted
|
19
30
|
has_many :redemptions
|
31
|
+
|
32
|
+
# @return [Pager<ShippingAddress>, [ShippingAddress], []] A pager that yields ShippingAddresses;
|
33
|
+
# or a list of ShippingAddresses if set by the programmer
|
20
34
|
has_many :shipping_addresses, readonly: false
|
21
35
|
|
22
36
|
# @return [BillingInfo, nil]
|
23
|
-
has_one :billing_info, :
|
37
|
+
has_one :billing_info, readonly: false
|
24
38
|
|
25
39
|
# @return [AccountBalance, nil]
|
26
|
-
has_one :account_balance, :
|
40
|
+
has_one :account_balance, readonly: true
|
27
41
|
|
28
|
-
|
42
|
+
# Get's the first redemption given a coupon code
|
43
|
+
# @deprecated Use #{redemptions} instead
|
44
|
+
# @param coupon_code [String] The coupon code for the redemption
|
45
|
+
def redemption(coupon_code)
|
29
46
|
redemptions.detect { |r| r.coupon_code == coupon_code }
|
30
47
|
end
|
31
48
|
|
@@ -56,6 +73,9 @@ module Recurly
|
|
56
73
|
)
|
57
74
|
alias to_param account_code
|
58
75
|
|
76
|
+
# Creates an invoice from the pending charges on the account.
|
77
|
+
# Raises an error if it fails.
|
78
|
+
#
|
59
79
|
# @return [Invoice] A newly-created invoice.
|
60
80
|
# @raise [Invalid] Raised if the account cannot be invoiced.
|
61
81
|
def invoice!(attrs={})
|
@@ -64,6 +84,9 @@ module Recurly
|
|
64
84
|
raise Invalid, e.message
|
65
85
|
end
|
66
86
|
|
87
|
+
# Builds an invoice from the pending charges on the account but does not persist the invoice.
|
88
|
+
# Raises an error if it fails.
|
89
|
+
#
|
67
90
|
# @return [Invoice] The newly-built invoice that has not been persisted.
|
68
91
|
# @raise [Invalid] Raised if the account cannot be invoiced.
|
69
92
|
def build_invoice
|
@@ -1,11 +1,21 @@
|
|
1
1
|
module Recurly
|
2
|
+
# The AccountBalance object contains some information about the account's balance.
|
3
|
+
# It exists to give us parity with the v1 API which used to include this information with
|
4
|
+
# the {Account}. You can get an account's balance by calling {Account#account_balance} on an account instance.
|
5
|
+
#
|
6
|
+
# Recurly Documentation: https://dev.recurly.com/docs/lookup-account-balance
|
2
7
|
class AccountBalance < Resource
|
3
8
|
# @return [Account, nil]
|
4
|
-
has_one :account, :
|
9
|
+
has_one :account, readonly: true
|
5
10
|
|
6
11
|
define_attribute_methods %w(
|
7
12
|
past_due
|
8
13
|
balance_in_cents
|
9
14
|
)
|
15
|
+
|
16
|
+
# This object does not represent a model on the server side
|
17
|
+
# so we do not need to expose these methods.
|
18
|
+
protected(*%w(save save!))
|
19
|
+
private_class_method(*%w(all find_each first paginate scoped where create! create))
|
10
20
|
end
|
11
21
|
end
|
data/lib/recurly/adjustment.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module Recurly
|
2
|
+
# The history of your customer's Recurly account can be tracked through adjustments, made up of credits and charges.
|
3
|
+
#
|
4
|
+
# Recurly Documentation: https://dev.recurly.com/docs/adjustment-object
|
2
5
|
class Adjustment < Resource
|
3
6
|
# @macro [attach] scope
|
4
7
|
# @scope class
|
5
8
|
# @return [Pager<Adjustment>] a pager that yields +$1+.
|
6
|
-
scope :charges, :
|
7
|
-
scope :credits, :
|
8
|
-
|
9
|
-
scope :
|
10
|
-
scope :invoiced, :state => 'invoiced'
|
9
|
+
scope :charges, type: 'charge'
|
10
|
+
scope :credits, type: 'credit'
|
11
|
+
scope :pending, state: 'pending'
|
12
|
+
scope :invoiced, state: 'invoiced'
|
11
13
|
|
12
14
|
# @return [Account, nil]
|
13
15
|
belongs_to :account
|
data/lib/recurly/billing_info.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module Recurly
|
2
|
+
# Represents an account's Billing Information. You normally want to use a token when creating billing information.
|
3
|
+
#
|
4
|
+
# Recurly Documentation: https://dev.recurly.com/docs/create-an-accounts-billing-info-token
|
2
5
|
class BillingInfo < Resource
|
3
6
|
BANK_ACCOUNT_ATTRIBUTES = %w(name_on_account account_type last_four routing_number).freeze
|
4
7
|
CREDIT_CARD_ATTRIBUTES = %w(number verification_value card_type year month first_six last_four).freeze
|
data/lib/recurly/coupon.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Recurly
|
2
|
+
|
3
|
+
# Recurly Documentation: https://dev.recurly.com/docs/list-active-coupons
|
2
4
|
class Coupon < Resource
|
3
5
|
BULK = 'bulk'.freeze
|
4
6
|
SINGLE_CODE = 'single_code'.freeze
|
@@ -10,10 +12,10 @@ module Recurly
|
|
10
12
|
scope :expired, :state => :expired
|
11
13
|
scope :maxed_out, :state => :maxed_out
|
12
14
|
|
13
|
-
# @return [Pager<Redemption>, []]
|
15
|
+
# @return [Pager<Redemption>, []] A pager that yields Redemptions
|
14
16
|
has_many :redemptions
|
15
17
|
|
16
|
-
# @return [Pager<Coupon>, []]
|
18
|
+
# @return [Pager<Coupon>, []] A pager that yields coupon-code type Coupons
|
17
19
|
has_many :unique_coupon_codes, class_name: :Coupon
|
18
20
|
|
19
21
|
define_attribute_methods %w(
|
@@ -51,15 +53,15 @@ module Recurly
|
|
51
53
|
#
|
52
54
|
# @return [true]
|
53
55
|
# @param account_or_code [Account, String]
|
54
|
-
# @param currency [String]
|
55
|
-
# @param
|
56
|
+
# @param currency [String] Three-letter currency code
|
57
|
+
# @param extra_opts [Hash] extra options that go into the {Redemption}
|
56
58
|
# @example
|
57
|
-
# coupon = Coupon.find
|
58
|
-
# coupon.redeem
|
59
|
+
# coupon = Coupon.find(coupon_code)
|
60
|
+
# coupon.redeem(account_code, 'USD', subscription_uuid: 'ab3b1dbabc3195')
|
59
61
|
#
|
60
|
-
# coupon = Coupon.find
|
61
|
-
# account = Account.find
|
62
|
-
# coupon.redeem
|
62
|
+
# coupon = Coupon.find(coupon_code)
|
63
|
+
# account = Account.find(account_code)
|
64
|
+
# coupon.redeem(account)
|
63
65
|
def redeem account_or_code, currency = nil, extra_opts={}
|
64
66
|
return false unless link? :redeem
|
65
67
|
|
@@ -84,6 +86,15 @@ module Recurly
|
|
84
86
|
redemption
|
85
87
|
end
|
86
88
|
|
89
|
+
# Generate unique coupon codes on the server. This is based on the unique_template_code.
|
90
|
+
#
|
91
|
+
# @param amount [Integer]
|
92
|
+
# @return [Pager<Coupon>] A pager that yields the coupon-code type Coupons
|
93
|
+
# @example
|
94
|
+
# unique_codes = coupon.generate(10)
|
95
|
+
# unique_codes.each do |c|
|
96
|
+
# puts c.coupon_code
|
97
|
+
# end
|
87
98
|
def generate(amount)
|
88
99
|
builder = XML.new("<coupon/>")
|
89
100
|
builder.add_element 'number_of_unique_codes', amount
|
@@ -95,17 +106,26 @@ module Recurly
|
|
95
106
|
Pager.new(Recurly::Coupon, uri: resp['location'], parent: self, etag: resp['ETag'])
|
96
107
|
end
|
97
108
|
|
98
|
-
|
99
|
-
|
109
|
+
# Redeem a coupon on the given account code
|
110
|
+
#
|
111
|
+
# @param account_code [String] Acccount's account code
|
112
|
+
# @param currency [String] Three-letter currency code
|
113
|
+
# @return [Redemption] The Coupon Redemption
|
114
|
+
def redeem!(account_code, currency = nil)
|
115
|
+
redemption = redeem(account_code, currency)
|
100
116
|
raise Invalid.new(redemption) unless redemption.persisted?
|
101
117
|
redemption
|
102
118
|
end
|
103
119
|
|
120
|
+
# Restores the coupon
|
104
121
|
def restore!
|
105
122
|
return false unless link? :restore
|
106
123
|
reload follow_link(:restore, body: self.to_xml(delta: true))
|
107
124
|
end
|
108
125
|
|
126
|
+
# Will return true if there are no limits on number of redemptions for this Coupon.
|
127
|
+
#
|
128
|
+
# @return [true, false]
|
109
129
|
def unlimited_redemptions_per_account?
|
110
130
|
!max_redemptions_per_account
|
111
131
|
end
|
data/lib/recurly/delivery.rb
CHANGED
data/lib/recurly/gift_card.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module Recurly
|
2
2
|
class GiftCard < Resource
|
3
|
+
# @return [Invoice, nil]
|
3
4
|
belongs_to :invoice
|
5
|
+
|
6
|
+
# @return [Account, nil] The Account belonging to the gifter
|
4
7
|
belongs_to :gifter_account, class_name: :Account, readonly: false
|
8
|
+
|
9
|
+
# @return [Account, nil] The Account belonging to the recipient of the gift
|
5
10
|
belongs_to :recipient_account, class_name: :Account, readonly: false
|
6
|
-
|
7
|
-
|
11
|
+
|
12
|
+
# @return [Delivery, nil] Delivery information of the recipient.
|
13
|
+
has_one :delivery, class_name: :Delivery, readonly: false
|
8
14
|
|
9
15
|
define_attribute_methods %w(
|
10
16
|
balance_in_cents
|
@@ -20,10 +26,17 @@ module Recurly
|
|
20
26
|
canceled_at
|
21
27
|
)
|
22
28
|
|
29
|
+
# Preview a GiftCard given some attributes
|
30
|
+
#
|
31
|
+
# @param [Hash] attributes for the gift card
|
32
|
+
# @return [GiftCard] The resulting preview GiftCard
|
23
33
|
def self.preview(attributes = {})
|
24
34
|
new(attributes) { |record| record.preview }
|
25
35
|
end
|
26
36
|
|
37
|
+
# Preview the GiftCard. Runs and validates the GiftCard but
|
38
|
+
# does not persist it. Errors are applied to the GiftCard if there
|
39
|
+
# are any errors.
|
27
40
|
def preview
|
28
41
|
clear_errors
|
29
42
|
@response = API.send(:post, "#{path}/preview", to_xml)
|
@@ -32,6 +45,9 @@ module Recurly
|
|
32
45
|
apply_errors e
|
33
46
|
end
|
34
47
|
|
48
|
+
# Redeem this GiftCard on the given account.
|
49
|
+
#
|
50
|
+
# @param [String] Recipient's account code
|
35
51
|
def redeem(recipient_account_code)
|
36
52
|
clear_errors
|
37
53
|
xml = <<-XML
|
data/lib/recurly/invoice.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module Recurly
|
2
2
|
# Invoices are created through account objects.
|
3
3
|
#
|
4
|
+
# Recurly Documentation: https://dev.recurly.com/docs/list-invoices
|
5
|
+
#
|
4
6
|
# @example
|
5
|
-
# account = Account.find
|
7
|
+
# account = Account.find(account_code)
|
6
8
|
# account.invoice!
|
7
9
|
class Invoice < Resource
|
8
10
|
# @macro [attach] scope
|
@@ -15,25 +17,33 @@ module Recurly
|
|
15
17
|
|
16
18
|
# @return [Account]
|
17
19
|
belongs_to :account
|
20
|
+
|
18
21
|
# @return [Subscription]
|
19
22
|
belongs_to :subscription
|
23
|
+
|
20
24
|
# @return [Invoice]
|
21
25
|
belongs_to :original_invoice, class_name: :Invoice
|
22
26
|
|
23
27
|
# This will only be present if the invoice has > 500 line items
|
24
|
-
# @return [Adjustment]
|
28
|
+
# @return [Pager<Adjustment>, []]
|
25
29
|
has_many :all_line_items, class_name: :Adjustment
|
26
30
|
|
27
|
-
# @return [Redemption]
|
31
|
+
# @return [Pager<Redemption>, []]
|
28
32
|
has_many :redemptions
|
29
33
|
|
30
|
-
# return [ShippingAddress]
|
34
|
+
# @return [Pager<ShippingAddress>, [ShippingAddress], []]
|
31
35
|
has_one :shipping_address, resource_class: :ShippingAddress, readonly: true
|
32
36
|
|
37
|
+
# Returns the first redemption in the Invoice's redemptions.
|
38
|
+
# This was placed here for backwards compatibility when we went from
|
39
|
+
# having a single redemption per invoice to multiple redemptions per invoice.
|
40
|
+
#
|
41
|
+
# @deprecated Use {#redemptions} and find the redemption you want.
|
33
42
|
def redemption
|
34
43
|
redemptions.first
|
35
44
|
end
|
36
45
|
|
46
|
+
# @return [String] The invoice number with the prefix (if there is one)
|
37
47
|
def invoice_number_with_prefix
|
38
48
|
"#{invoice_number_prefix}#{invoice_number}"
|
39
49
|
end
|
@@ -107,14 +117,19 @@ module Recurly
|
|
107
117
|
true
|
108
118
|
end
|
109
119
|
|
120
|
+
# Posts an offline payment on this invoice
|
121
|
+
#
|
122
|
+
# @return [Transaction]
|
123
|
+
# @raise [Error] If the transaction fails.
|
110
124
|
def enter_offline_payment(attrs={})
|
111
125
|
Transaction.from_response API.post("#{uri}/transactions", attrs.empty? ? nil : Transaction.to_xml(attrs))
|
112
126
|
rescue Recurly::API::UnprocessableEntity => e
|
113
127
|
raise Invalid, e.message
|
114
128
|
end
|
115
129
|
|
130
|
+
# Fetches the pdf for this invoice
|
116
131
|
def pdf
|
117
|
-
self.class.find
|
132
|
+
self.class.find(to_param, format: 'pdf')
|
118
133
|
end
|
119
134
|
|
120
135
|
# Refunds specific line items on the invoice.
|
data/lib/recurly/js.rb
CHANGED
@@ -3,7 +3,9 @@ require 'base64'
|
|
3
3
|
require 'cgi'
|
4
4
|
|
5
5
|
module Recurly
|
6
|
-
#
|
6
|
+
# @deprecated Please use the new Recurly.js tokenization system https://dev.recurly.com/docs/recurlyjs
|
7
|
+
#
|
8
|
+
# A collection of helper methods to use to verify the old
|
7
9
|
# {Recurly.js}[http://js.recurly.com/] callbacks.
|
8
10
|
module JS
|
9
11
|
# Raised when signature verification fails.
|
data/lib/recurly/plan.rb
CHANGED
data/lib/recurly/purchase.rb
CHANGED
@@ -19,7 +19,7 @@ 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
|
-
#
|
22
|
+
# @example
|
23
23
|
# require 'securerandom'
|
24
24
|
#
|
25
25
|
# purchase = Recurly::Purchase.new({
|
@@ -76,7 +76,6 @@ module Recurly
|
|
76
76
|
# # e.transaction
|
77
77
|
# # e.transaction_error_code
|
78
78
|
# end
|
79
|
-
#
|
80
79
|
class Purchase < Resource
|
81
80
|
# @return [[Adjustment], nil]
|
82
81
|
has_many :adjustments, class_name: :Adjustment, readonly: false
|
@@ -130,8 +129,18 @@ module Recurly
|
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
132
|
+
# TODO
|
133
|
+
# This is a temporary solution which allows us to
|
134
|
+
# embed these resources in a purchase without changing their
|
135
|
+
# interface. It will be removed once we get rid of default_currency.
|
136
|
+
def to_xml(options = {})
|
137
|
+
subscriptions.each {|s| s.currency = nil}
|
138
|
+
adjustments.each {|a| a.currency = nil}
|
139
|
+
super(options)
|
140
|
+
end
|
141
|
+
|
133
142
|
# This object does not represent a model on the server side
|
134
|
-
# so we do not need to expose
|
143
|
+
# so we do not need to expose these methods.
|
135
144
|
protected(*%w(save save!))
|
136
145
|
private_class_method(*%w(all find_each first paginate scoped where post create! create))
|
137
146
|
end
|
data/lib/recurly/redemption.rb
CHANGED
data/lib/recurly/subscription.rb
CHANGED
@@ -5,33 +5,34 @@ module Recurly
|
|
5
5
|
# @macro [attach] scope
|
6
6
|
# @scope class
|
7
7
|
# @return [Pager<Subscription>] A pager that yields +$1+ subscriptions.
|
8
|
-
scope :active, :
|
9
|
-
scope :canceled, :
|
10
|
-
scope :expired, :
|
11
|
-
scope :future, :
|
8
|
+
scope :active, state: :active
|
9
|
+
scope :canceled, state: :canceled
|
10
|
+
scope :expired, state: :expired
|
11
|
+
scope :future, state: :future
|
12
12
|
# @return [Pager<Subscription>] A pager that yields subscriptions in
|
13
13
|
# trials.
|
14
|
-
scope :in_trial, :
|
14
|
+
scope :in_trial, state: :in_trial
|
15
15
|
# @return [Pager<Subscription>] A pager that yields active, canceled, and
|
16
16
|
# future subscriptions.
|
17
|
-
scope :live, :
|
18
|
-
scope :past_due, :
|
17
|
+
scope :live, state: :live
|
18
|
+
scope :past_due, state: :past_due
|
19
|
+
|
20
|
+
# @return [Pager<Redemption>, []]
|
21
|
+
has_many :redemptions
|
19
22
|
|
20
23
|
# @return [Account]
|
21
24
|
belongs_to :account
|
25
|
+
|
22
26
|
# @return [Plan]
|
23
27
|
belongs_to :plan
|
24
28
|
|
25
|
-
# @return [Invoice]
|
29
|
+
# @return [Invoice, nil]
|
26
30
|
has_one :invoice
|
27
31
|
|
28
|
-
# @return [GiftCard]
|
32
|
+
# @return [GiftCard, nil]
|
29
33
|
has_one :gift_card
|
30
34
|
|
31
|
-
# @return [
|
32
|
-
has_many :redemptions
|
33
|
-
|
34
|
-
# return [ShippingAddress]
|
35
|
+
# @return [ShippingAddress, nil]
|
35
36
|
has_one :shipping_address, resource_class: :ShippingAddress, readonly: false
|
36
37
|
|
37
38
|
define_attribute_methods %w(
|
@@ -91,7 +92,7 @@ module Recurly
|
|
91
92
|
|
92
93
|
# @return [Subscription] A new subscription.
|
93
94
|
def initialize(attributes = {})
|
94
|
-
super(attributes)
|
95
|
+
super({ :currency => Recurly.default_currency }.merge attributes)
|
95
96
|
end
|
96
97
|
|
97
98
|
# Assign a Plan resource (rather than a plan code).
|
data/lib/recurly/transaction.rb
CHANGED
@@ -5,13 +5,12 @@ module Recurly
|
|
5
5
|
# @macro [attach] scope
|
6
6
|
# @scope class
|
7
7
|
# @return [Pager] a pager that yields +$1+ transactions.
|
8
|
-
scope :authorizations, :
|
9
|
-
scope :purchases, :
|
10
|
-
scope :refunds, :
|
11
|
-
|
12
|
-
scope :
|
13
|
-
scope :
|
14
|
-
scope :voided, :state => 'voided'
|
8
|
+
scope :authorizations, type: 'authorization'
|
9
|
+
scope :purchases, type: 'purchase'
|
10
|
+
scope :refunds, type: 'refund'
|
11
|
+
scope :successful, state: 'successful'
|
12
|
+
scope :failed, state: 'failed'
|
13
|
+
scope :voided, state: 'voided'
|
15
14
|
|
16
15
|
# @return [Account]
|
17
16
|
belongs_to :account
|
data/lib/recurly/version.rb
CHANGED
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.10.
|
4
|
+
version: 2.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recurly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -81,21 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.3.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.9.9
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.9.9
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: redcarpet
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -146,7 +146,6 @@ extra_rdoc_files:
|
|
146
146
|
files:
|
147
147
|
- README.md
|
148
148
|
- bin/recurly
|
149
|
-
- lib/ecurly.rb
|
150
149
|
- lib/rails/generators/recurly/config_generator.rb
|
151
150
|
- lib/rails/recurly.rb
|
152
151
|
- lib/recurly.rb
|
@@ -155,7 +154,6 @@ files:
|
|
155
154
|
- lib/recurly/add_on.rb
|
156
155
|
- lib/recurly/address.rb
|
157
156
|
- lib/recurly/adjustment.rb
|
158
|
-
- lib/recurly/all.rb
|
159
157
|
- lib/recurly/api.rb
|
160
158
|
- lib/recurly/api/errors.rb
|
161
159
|
- lib/recurly/api/net_http_adapter.rb
|
@@ -240,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
238
|
version: '0'
|
241
239
|
requirements: []
|
242
240
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.6.
|
241
|
+
rubygems_version: 2.6.13
|
244
242
|
signing_key:
|
245
243
|
specification_version: 4
|
246
244
|
summary: Recurly API Client
|
data/lib/ecurly.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'recurly'
|
data/lib/recurly/all.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'recurly'
|
2
|
-
require 'recurly/account'
|
3
|
-
require 'recurly/add_on'
|
4
|
-
require 'recurly/address'
|
5
|
-
require 'recurly/adjustment'
|
6
|
-
require 'recurly/api'
|
7
|
-
require 'recurly/billing_info'
|
8
|
-
require 'recurly/coupon'
|
9
|
-
require 'recurly/helper'
|
10
|
-
require 'recurly/invoice'
|
11
|
-
require 'recurly/js'
|
12
|
-
require 'recurly/money'
|
13
|
-
require 'recurly/plan'
|
14
|
-
require 'recurly/redemption'
|
15
|
-
require 'recurly/resource'
|
16
|
-
require 'recurly/resource/pager'
|
17
|
-
require 'recurly/subscription'
|
18
|
-
require 'recurly/subscription/add_ons'
|
19
|
-
require 'recurly/transaction'
|
20
|
-
require 'recurly/version'
|
21
|
-
require 'recurly/xml'
|