recurly 2.4.6 → 2.4.7

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: 972f95d54db4267cb3a761d4ca74c95e79eb8df3
4
- data.tar.gz: 61d5fb37a103b1551f19562b1e71600b1ceffa00
3
+ metadata.gz: 1203bd1945ec1c2eae87b580b09a47a214965a6c
4
+ data.tar.gz: ba492e09b36d0479a5e41ea1e29b41ccc94561b2
5
5
  SHA512:
6
- metadata.gz: 65cf967a326482f1c394289957c670119480797e5864aad3d149c1e2cb305437738dd3f3e3849c61e7d349029dd0bdf9002e2420d6a20646f1d395f4d7c6a098
7
- data.tar.gz: c94dc16a2010ed26dc803e7bf6f0f7f29c1608f23c0e9f842d192d50a1f1dda3aba44638e347a4dd19ef6a20392b526a2d036cfebd6ce015714c85419f6ac4b9
6
+ metadata.gz: bc27d6d635846fb6a9fdcfda6755be969c92f1b97d32a2fec8fc8918a78dff58084d1e41f95a9dda0660de5273eed9ba075d52d826f163807f9d69d7d5f39d68
7
+ data.tar.gz: 120302e3ea0d5b8038b4607957c396d1ccc86f79f18214ab3df402f1455ebcf952ca6ef1ce7cdef5d640f9f484866f9f70ba25ae40be1832edeb51780d322486
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.4.6'
15
+ gem 'recurly', '~> 2.4.7'
16
16
  ```
17
17
 
18
18
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -1,5 +1,8 @@
1
1
  module Recurly
2
2
  class Coupon < Resource
3
+ BULK = 'bulk'.freeze
4
+ SINGLE_CODE = 'single_code'.freeze
5
+
3
6
  # @macro [attach] scope
4
7
  # @scope class
5
8
  # @return [Pager<Coupon>] A pager that yields +$1+ coupons.
@@ -10,6 +13,9 @@ module Recurly
10
13
  # @return [Pager<Redemption>, []]
11
14
  has_many :redemptions
12
15
 
16
+ # @return [Pager<Coupon>, []]
17
+ has_many :unique_coupon_codes, class_name: :Coupon
18
+
13
19
  define_attribute_methods %w(
14
20
  coupon_code
15
21
  name
@@ -32,19 +38,11 @@ module Recurly
32
38
  invoice_description
33
39
  applies_to_non_plan_charges
34
40
  redemption_resource
41
+ coupon_type
42
+ unique_template_code
35
43
  )
36
44
  alias to_param coupon_code
37
45
 
38
- # Saves new records only.
39
- #
40
- # @return [true, false]
41
- # @raise [Recurly::Error] For persisted coupons.
42
- # @see Resource#save
43
- def save
44
- return super if new_record?
45
- raise Recurly::Error, "#{self.class.collection_name} cannot be updated"
46
- end
47
-
48
46
  # Redeem a coupon with a given account or account code.
49
47
  #
50
48
  # @return [true]
@@ -82,12 +80,28 @@ module Recurly
82
80
  redemption
83
81
  end
84
82
 
83
+ def generate(amount)
84
+ builder = XML.new("<coupon/>")
85
+ builder.add_element 'number_of_unique_codes', amount
86
+
87
+ resp = follow_link(:generate,
88
+ :body => builder.to_s
89
+ )
90
+
91
+ Pager.new(Recurly::Coupon, uri: resp['location'], parent: self, etag: resp['ETag'])
92
+ end
93
+
85
94
  def redeem! account_code, currency = nil
86
95
  redemption = redeem account_code, currency
87
96
  raise Invalid.new(self) unless redemption.persisted?
88
97
  redemption
89
98
  end
90
99
 
100
+ def restore!
101
+ return false unless link? :restore
102
+ reload follow_link(:restore, body: self.to_xml(delta: true))
103
+ end
104
+
91
105
  def unlimited_redemptions_per_account?
92
106
  !max_redemptions_per_account
93
107
  end
@@ -403,10 +403,14 @@ module Recurly
403
403
  end
404
404
 
405
405
  if el.children.empty? && href = el.attribute('href')
406
- resource_class = Recurly.const_get(
407
- Helper.classify(klass.association_class_name(el.name) ||
408
- el.attribute('type') || el.name), false
409
- )
406
+ klass_name = Helper.classify(klass.association_class_name(el.name) ||
407
+ el.attribute('type') ||
408
+ el.name)
409
+
410
+ next unless Recurly.const_defined?(klass_name)
411
+
412
+ resource_class = Recurly.const_get(klass_name, false)
413
+
410
414
  case el.name
411
415
  when *klass.associations_for_relation(:has_many)
412
416
  record[el.name] = Pager.new(
@@ -15,10 +15,10 @@ module Recurly
15
15
 
16
16
  # @return [Account]
17
17
  belongs_to :account
18
- # @return [Invoice, nil]
19
- belongs_to :invoice
20
- # @return [Subscription, nil]
21
- belongs_to :subscription
18
+ # @return [Invoice, nil]
19
+ belongs_to :invoice
20
+ # @return [Subscription, nil]
21
+ belongs_to :subscription
22
22
 
23
23
  define_attribute_methods %w(
24
24
  uuid
@@ -2,7 +2,7 @@ module Recurly
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 4
5
- PATCH = 6
5
+ PATCH = 7
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.4.6
4
+ version: 2.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.2.2
121
+ rubygems_version: 2.2.5
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Recurly API Client