recurly 2.2.6 → 2.3.0

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,15 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: ad8b2a29b7b37f7bdfce5c727e15d642ce9d2862828710acf45ad24abcc47a44
4
- data.tar.gz: 20982fe970032ae0da58c8ed72ce0a5ad307827d6ad1b1a7bfd11192c8d27766
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWZhMjQwMTY2MDFjMWZhZjk5NWQ5OTYzOGYxZjdhYWFkZDIxOTYwYw==
5
+ data.tar.gz: !binary |-
6
+ OWRhNjkwMjAwOTAzYTA0OTY0MDE1Mzg3Y2QwMTE2YmE1OWQ1NDBiMg==
5
7
  SHA512:
6
- metadata.gz: 935a3fcd8905e2e435585ddb4f7523cba42618c5a33b890314e411abaa39c1b49f5c25f7dc9abf4d0bdb093e3c78aa9d248f18bc97994260bc222860dfb409b9
7
- data.tar.gz: b805d4341d9b06b24bc6830226dd3f53f1d6d74996174a076b97c942feb81a916bbd1f305401b7a5563cc548d2f3137294478cbe7bca57d88deb47d45268be1e
8
+ metadata.gz: !binary |-
9
+ YjMwMjRjNjkwNTliZjlkODBmNDE5MTY4ZjYzZTY3ODFmMTlmOGJmZTU0MzM4
10
+ YjY0ZGRlMTkyZjAyZTcwMDg3ZDdkMDdmMzRiNDMyZmNlMTk3ZTc1MzIxNzlm
11
+ MThiZDU4ZWFiYjRhZWMwZTQwMGVkM2MzMzliNTIxY2IwZGY5MGM=
12
+ data.tar.gz: !binary |-
13
+ OTkyZmRkYWE0NjY2MDkwZDViOTQ2YzNjMjUwNmVkYmVhNzI2Y2I4MmQzN2Iw
14
+ M2Q0Nzk4MzI0ZmRiODE0MWVjYWFiMDE1Zjc4ZjlmY2EyZDVkZTBkZjkxODI0
15
+ OTRjOGMwYmI1MGQyZWVjMjZmZWY4NDAyMGE1NzlkZTA1ZDJkMDA=
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.2.5'
15
+ gem 'recurly', '~> 2.3.0'
16
16
  ```
17
17
 
18
18
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -3,6 +3,7 @@ module Recurly
3
3
  autoload :Account, 'recurly/account'
4
4
  autoload :AddOn, 'recurly/add_on'
5
5
  autoload :Address, 'recurly/address'
6
+ autoload :TaxDetail, 'recurly/tax_detail'
6
7
  autoload :Adjustment, 'recurly/adjustment'
7
8
  autoload :API, 'recurly/api'
8
9
  autoload :BillingInfo, 'recurly/billing_info'
@@ -67,8 +68,6 @@ module Recurly
67
68
  end
68
69
 
69
70
  # Assigns a logger to log requests/responses and more.
70
- # The logger can only be set if the environment variable
71
- # `RECURLY_INSECURE_DEBUG` equals `true`.
72
71
  #
73
72
  # @return [Logger, nil]
74
73
  # @example
@@ -80,22 +79,6 @@ module Recurly
80
79
  # Recurly.logger = nil # Or Recurly.logger = Logger.new nil
81
80
  attr_accessor :logger
82
81
 
83
- def logger=(logger)
84
- if ENV['RECURLY_INSECURE_DEBUG'].to_s.downcase == 'true'
85
- @logger = logger
86
- puts <<-MSG
87
- [WARNING] Recurly logger enabled. The logger has the potential to leak
88
- PII and should never be used in production environments.
89
- MSG
90
- else
91
- puts <<-MSG
92
- [WARNING] Recurly logger has been disabled. If you wish to use it,
93
- only do so in a non-production environment and make sure
94
- the `RECURLY_INSECURE_DEBUG` environment variable is set to `true`.
95
- MSG
96
- end
97
- end
98
-
99
82
  # Convenience logging method includes a Logger#progname dynamically.
100
83
  # @return [true, nil]
101
84
  def log level, message
@@ -35,6 +35,7 @@ module Recurly
35
35
  hosted_login_token
36
36
  vat_number
37
37
  address
38
+ tax_exempt
38
39
  created_at
39
40
  )
40
41
  alias to_param account_code
@@ -11,4 +11,4 @@ module Recurly
11
11
  phone
12
12
  )
13
13
  end
14
- end
14
+ end
@@ -28,7 +28,8 @@ module Recurly
28
28
  tax_in_cents
29
29
  total_in_cents
30
30
  currency
31
- taxable
31
+ tax_exempt
32
+ tax_details
32
33
  product_code
33
34
  start_date
34
35
  end_date
@@ -15,7 +15,6 @@ module Recurly
15
15
  require 'recurly/api/errors'
16
16
 
17
17
  @@base_uri = "https://api.recurly.com/v2/"
18
- @@valid_domains = [".recurly.com"]
19
18
 
20
19
  FORMATS = Helper.hash_with_indifferent_read_access(
21
20
  'pdf' => 'application/pdf',
@@ -74,13 +73,6 @@ module Recurly
74
73
  URI.parse @@base_uri.sub('api', Recurly.subdomain)
75
74
  end
76
75
 
77
- def validate_uri!(uri)
78
- domain = @@valid_domains.detect { |d| uri.host.end_with?(d) }
79
- unless domain
80
- raise ArgumentError, "URI #{uri} is invalid. You may only make requests to a Recurly domain."
81
- end
82
- end
83
-
84
76
  # @return [String]
85
77
  def user_agent
86
78
  "Recurly/#{Version}; #{RUBY_DESCRIPTION}"
@@ -36,14 +36,13 @@ module Recurly
36
36
  head = headers.dup
37
37
  head.update options[:head] if options[:head]
38
38
  head.delete_if { |_, value| value.nil? }
39
- uri = base_uri + uri
39
+ uri = base_uri + URI.escape(uri)
40
40
  if options[:params] && !options[:params].empty?
41
41
  pairs = options[:params].map { |key, value|
42
42
  "#{CGI.escape key.to_s}=#{CGI.escape value.to_s}"
43
43
  }
44
44
  uri += "?#{pairs.join '&'}"
45
45
  end
46
- self.validate_uri!(uri)
47
46
  request = METHODS[method].new uri.request_uri, head
48
47
  request.basic_auth(*[Recurly.api_key, nil].flatten[0, 2])
49
48
  if options[:body]
@@ -29,6 +29,8 @@ module Recurly
29
29
  vat_number
30
30
  subtotal_in_cents
31
31
  tax_in_cents
32
+ tax_type
33
+ tax_rate
32
34
  total_in_cents
33
35
  currency
34
36
  created_at
@@ -24,6 +24,7 @@ module Recurly
24
24
  trial_interval_unit
25
25
  total_billing_cycles
26
26
  accounting_code
27
+ tax_exempt
27
28
  created_at
28
29
  )
29
30
  alias to_param plan_code
@@ -1,5 +1,4 @@
1
1
  require 'date'
2
- require 'erb'
3
2
 
4
3
  module Recurly
5
4
  # The base class for all Recurly resources (e.g. {Account}, {Subscription},
@@ -185,7 +184,6 @@ module Recurly
185
184
  # Recurly::Account.member_path "code" # => "accounts/code"
186
185
  # Recurly::Account.member_path nil # => "accounts"
187
186
  def member_path uuid
188
- uuid = ERB::Util.url_encode(uuid) if uuid
189
187
  [collection_path, uuid].compact.join '/'
190
188
  end
191
189
 
@@ -321,8 +319,9 @@ module Recurly
321
319
  raise NotFound, "can't find a record with nil identifier"
322
320
  end
323
321
 
322
+ uri = uuid =~ /^http/ ? uuid : member_path(uuid)
324
323
  begin
325
- from_response API.get(member_path(uuid), {}, options)
324
+ from_response API.get(uri, {}, options)
326
325
  rescue API::NotFound => e
327
326
  raise NotFound, e.description
328
327
  end
@@ -559,12 +558,9 @@ module Recurly
559
558
  return if response.body.to_s.length.zero?
560
559
  fresh = self.class.from_response response
561
560
  else
562
- options = {:etag => (etag unless changed?)}
563
- fresh = if @href
564
- self.class.from_response API.get(@href, {}, options)
565
- else
566
- self.class.find(to_param, options)
567
- end
561
+ fresh = self.class.find(
562
+ @href || to_param, :etag => (etag unless changed?)
563
+ )
568
564
  end
569
565
  fresh and copy_from fresh
570
566
  persist! true
@@ -2,6 +2,8 @@ module Recurly
2
2
  class Subscription < Resource
3
3
  autoload :AddOns, 'recurly/subscription/add_ons'
4
4
 
5
+ class NotPreviewableError < StandardError; end
6
+
5
7
  # @macro [attach] scope
6
8
  # @scope class
7
9
  # @return [Pager<Subscription>] A pager that yields +$1+ subscriptions.
@@ -45,9 +47,26 @@ module Recurly
45
47
  net_terms
46
48
  collection_method
47
49
  po_number
50
+ tax_in_cents
51
+ tax_type
52
+ tax_rate
48
53
  )
49
54
  alias to_param uuid
50
55
 
56
+ def self.preview(attributes = {})
57
+ new(attributes) { |record| record.preview }
58
+ end
59
+
60
+ def preview
61
+ raise NotPreviewableError.new('Cannot preview an existing subscription') unless new_record?
62
+
63
+ clear_errors
64
+ @response = API.send(:post, "#{path}/preview", to_xml)
65
+ reload response
66
+ rescue API::UnprocessableEntity => e
67
+ apply_errors e
68
+ end
69
+
51
70
  # @return [Subscription] A new subscription.
52
71
  def initialize attributes = {}
53
72
  super({ :currency => Recurly.default_currency }.merge attributes)
@@ -0,0 +1,14 @@
1
+ require 'bigdecimal'
2
+
3
+ module Recurly
4
+ class TaxDetail < Resource
5
+ define_attribute_methods %w(
6
+ name
7
+ type
8
+ tax_rate
9
+ tax_in_cents
10
+ )
11
+
12
+ embedded! true
13
+ end
14
+ end
@@ -1,8 +1,8 @@
1
1
  module Recurly
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 2
5
- PATCH = 6
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
metadata CHANGED
@@ -1,58 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.3.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-05-09 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.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
26
  version: 0.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.6.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.6.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.7.6
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.7.6
55
- description: 'An API client library for Recurly: http://recurly.com'
55
+ description: ! 'An API client library for Recurly: http://recurly.com'
56
56
  email: support@recurly.com
57
57
  executables:
58
58
  - recurly
@@ -88,6 +88,7 @@ files:
88
88
  - lib/recurly/subscription.rb
89
89
  - lib/recurly/subscription/add_ons.rb
90
90
  - lib/recurly/subscription_add_on.rb
91
+ - lib/recurly/tax_detail.rb
91
92
  - lib/recurly/transaction.rb
92
93
  - lib/recurly/transaction/errors.rb
93
94
  - lib/recurly/version.rb
@@ -100,24 +101,25 @@ licenses:
100
101
  metadata: {}
101
102
  post_install_message:
102
103
  rdoc_options:
103
- - "--main"
104
+ - --main
104
105
  - README.md
105
106
  require_paths:
106
107
  - lib
107
108
  required_ruby_version: !ruby/object:Gem::Requirement
108
109
  requirements:
109
- - - ">="
110
+ - - ! '>='
110
111
  - !ruby/object:Gem::Version
111
112
  version: 1.9.3
112
113
  required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
- - - ">="
115
+ - - ! '>='
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  requirements: []
118
119
  rubyforge_project:
119
- rubygems_version: 2.7.6
120
+ rubygems_version: 2.2.2
120
121
  signing_key:
121
122
  specification_version: 4
122
123
  summary: Recurly API Client
123
124
  test_files: []
125
+ has_rdoc: true