killbill-client 0.35.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dad39131d3cbc2056cd9333e9943faf20e4c8bf8
4
- data.tar.gz: 54e03e703307ad62140d9ed8d68595a4e879c543
3
+ metadata.gz: c703102c2d5b0ca273db8faa154cc6875b2b6021
4
+ data.tar.gz: 660786f1bf17d6bec10c01720ac0550de1f59f5c
5
5
  SHA512:
6
- metadata.gz: dcb2f78089cd651ace503d68dac2a398190a5f820de513b32c69923ea27857be5153b8870316d5cce6f45e6fbb57a82cf0048e7bc2da362a35c0b4c5dfe1fe1e
7
- data.tar.gz: 354334e362fca07e882e912196bdc1044b719c02411ab4f633296a4d05935377701be47fc80ce7e0f5b5f80583964550670a53b5ba57c0dbe7666f0d38c27b1d
6
+ metadata.gz: fe35609bef6402e72d22dd442f8c2dc875e69a49cd3ececf6fda7e04a7fc455178d41ab2f239fc8e8364b86f4e8db91f8cd35774702ee4b35b5547d343272ad9
7
+ data.tar.gz: 72a29072e1eafcc1c6f1b0fedca4fa248191b1fe5498892411f671c9a5be7e9bf79ce2967752706b1d7b04edf6857c09ef55ecae5e00b4f9eab8f5a82cd6d638
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  [![Build Status](https://travis-ci.org/killbill/killbill-client-ruby.png)](https://travis-ci.org/killbill/killbill-client-ruby)
2
2
  [![Code Climate](https://codeclimate.com/github/killbill/killbill-client-ruby.png)](https://codeclimate.com/github/killbill/killbill-client-ruby)
3
3
 
4
+ ------------------------------------------------
5
+ | Ruby client | Kill Bill version |
6
+ | -----------------------: | ----------------: |
7
+ | 0.x.y | 0.16.z |
8
+ | -----------------------: | ----------------: |
9
+ | 1.x.y | 0.18.z(and 0.17.x)|
10
+
11
+
4
12
  killbill-client-ruby
5
13
  ====================
6
14
 
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
 
40
40
  s.rdoc_options << '--exclude' << '.'
41
41
 
42
- s.add_dependency 'json', '>= 1.2.0', '< 2.0.0'
42
+ s.add_dependency 'json', '>= 1.2.0'
43
43
 
44
44
  s.add_development_dependency 'rake', '>= 10.0.0', '< 11.0.0'
45
45
  s.add_development_dependency 'rspec', '~> 3.4'
@@ -63,14 +63,6 @@ module KillBillClient
63
63
  "?#{pairs.join '&'}"
64
64
  end
65
65
 
66
- def create_http_client(uri, options = {})
67
- http = ::Net::HTTP.new uri.host, uri.port
68
- http.read_timeout = options[:read_timeout].to_f / 1000 if options[:read_timeout].is_a? Numeric
69
- http.open_timeout = options[:connection_timeout].to_f / 1000 if options[:connection_timeout].is_a? Numeric
70
- http.use_ssl = uri.scheme == 'https'
71
- http
72
- end
73
-
74
66
  def request(method, relative_uri, options = {})
75
67
  head = headers.dup
76
68
  head.update options[:head] if options[:head]
@@ -82,7 +74,7 @@ module KillBillClient
82
74
  # Note: make sure to keep the full path (if any) from URI::HTTP, for non-ROOT deployments
83
75
  # See https://github.com/killbill/killbill/issues/221#issuecomment-151980263
84
76
  base_path = uri.request_uri == '/' ? '' : uri.request_uri
85
- uri += (base_path + URI::DEFAULT_PARSER.escape(relative_uri))
77
+ uri += (base_path + URI.escape(relative_uri))
86
78
  else
87
79
  uri = relative_uri
88
80
  uri = URI.parse(uri) unless uri.is_a?(URI)
@@ -148,7 +140,8 @@ module KillBillClient
148
140
  request['X-Request-Id'] = options[:request_id]
149
141
  end
150
142
 
151
- http = create_http_client uri, options
143
+ http = ::Net::HTTP.new uri.host, uri.port
144
+ http.use_ssl = uri.scheme == 'https'
152
145
  net_http.each_pair { |key, value| http.send "#{key}=", value }
153
146
 
154
147
  if KillBillClient.logger
@@ -59,6 +59,7 @@ module KillBillClient
59
59
  params = {}
60
60
  params[:requestedDate] = requested_date unless requested_date.nil?
61
61
  params[:billingPolicy] = billing_policy unless billing_policy.nil?
62
+
62
63
  result = self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
63
64
  to_json,
64
65
  params,
@@ -106,17 +107,19 @@ module KillBillClient
106
107
  # Low level api to block/unblock a given subscription/bundle/account
107
108
  def set_blocking_state(state_name, service, block_change, block_entitlement, block_billing, requested_date = nil, user = nil, reason = nil, comment = nil, options = {})
108
109
 
110
+ params = {}
111
+ params[:requestedDate] = requested_date unless requested_date.nil?
112
+
109
113
  body = KillBillClient::Model::BlockingStateAttributes.new
110
114
  body.state_name = state_name
111
115
  body.service = service
112
116
  body.block_change = block_change
113
117
  body.block_entitlement = block_entitlement
114
118
  body.block_billing = block_billing
115
- body.effective_date = requested_date
116
119
 
117
120
  self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{@bundle_id}/block",
118
121
  body.to_json,
119
- {},
122
+ params,
120
123
  {
121
124
  :user => user,
122
125
  :reason => reason,
@@ -3,7 +3,6 @@ module KillBillClient
3
3
  class EventSubscription < EventSubscriptionAttributes
4
4
  has_many :audit_logs, KillBillClient::Model::AuditLog
5
5
 
6
- create_alias :requested_date, :requested_dt
7
6
  create_alias :effective_date, :effective_dt
8
7
  end
9
8
  end
@@ -29,10 +29,12 @@ module KillBillClient
29
29
  module Model
30
30
  class CreditAttributes < Resource
31
31
  attribute :credit_amount
32
+ attribute :currency
32
33
  attribute :invoice_id
33
34
  attribute :invoice_number
34
35
  attribute :effective_date
35
36
  attribute :account_id
37
+ attribute :description
36
38
  attribute :audit_logs
37
39
  end
38
40
  end
@@ -30,7 +30,6 @@ module KillBillClient
30
30
  class EventSubscriptionAttributes < Resource
31
31
  attribute :event_id
32
32
  attribute :billing_period
33
- attribute :requested_dt
34
33
  attribute :effective_dt
35
34
  attribute :product
36
35
  attribute :price_list
@@ -36,6 +36,8 @@ module KillBillClient
36
36
  attribute :amount
37
37
  attribute :currency
38
38
  attribute :effective_date
39
+ attribute :processed_amount
40
+ attribute :processed_currency
39
41
  attribute :status
40
42
  attribute :gateway_error_code
41
43
  attribute :gateway_error_msg
@@ -36,6 +36,8 @@ module KillBillClient
36
36
  attribute :amount
37
37
  attribute :currency
38
38
  attribute :effective_date
39
+ attribute :processed_amount
40
+ attribute :processed_currency
39
41
  attribute :status
40
42
  attribute :gateway_error_code
41
43
  attribute :gateway_error_msg
@@ -44,6 +44,7 @@ module KillBillClient
44
44
  attribute :charged_through_date
45
45
  attribute :billing_start_date
46
46
  attribute :billing_end_date
47
+ attribute :bill_cycle_day_local
47
48
  attribute :events
48
49
  attribute :price_overrides
49
50
  attribute :audit_logs
@@ -29,6 +29,7 @@ module KillBillClient
29
29
  module Model
30
30
  class SubscriptionUsageRecordAttributes < Resource
31
31
  attribute :subscription_id
32
+ attribute :tracking_id
32
33
  attribute :unit_usage_records
33
34
  end
34
35
  end
@@ -68,7 +68,7 @@ module KillBillClient
68
68
 
69
69
  res.refresh(options)
70
70
 
71
- rescue KillBillClient::API::BadRequest
71
+ rescue KillBillClient::API::BadRequest => e
72
72
  # No invoice to generate : TODO parse json to verify this is indeed the case
73
73
  end
74
74
  end
@@ -94,7 +94,7 @@ module KillBillClient
94
94
 
95
95
  res.refresh(options)
96
96
 
97
- rescue KillBillClient::API::NotFound
97
+ rescue KillBillClient::API::NotFound => e
98
98
  nil
99
99
  end
100
100
  end
@@ -126,7 +126,7 @@ module KillBillClient
126
126
  Invoice
127
127
 
128
128
  res.refresh(options)
129
- rescue KillBillClient::API::NotFound
129
+ rescue KillBillClient::API::NotFound => e
130
130
  nil
131
131
  end
132
132
  end
@@ -160,7 +160,7 @@ module KillBillClient
160
160
  Invoice
161
161
 
162
162
  res.refresh(options)
163
- rescue KillBillClient::API::NotFound
163
+ rescue KillBillClient::API::NotFound => e
164
164
  nil
165
165
  end
166
166
  end
@@ -193,7 +193,7 @@ module KillBillClient
193
193
 
194
194
  res.refresh(options)
195
195
 
196
- rescue KillBillClient::API::NotFound
196
+ rescue KillBillClient::API::NotFound => e
197
197
  nil
198
198
  end
199
199
  end
@@ -15,7 +15,6 @@ module KillBillClient
15
15
  @@attribute_names = {}
16
16
 
17
17
  def initialize(hash = nil)
18
- @uri = nil
19
18
  # Make sure we support ActiveSupport::HashWithIndifferentAccess for Kaui
20
19
  if hash.respond_to?(:each)
21
20
  hash.each do |key, value|
@@ -76,8 +75,8 @@ module KillBillClient
76
75
  when %r{text/plain}
77
76
  response.body
78
77
  when %r{application/xml}
79
- if response['location']
80
- response['location']
78
+ if response.header['location']
79
+ response.header['location']
81
80
  else
82
81
  response.body
83
82
  end
@@ -85,7 +84,7 @@ module KillBillClient
85
84
  record = from_json resource_class, response.body
86
85
  if record.nil?
87
86
  record = resource_class.new
88
- record.uri = response['location']
87
+ record.uri = response.header['location']
89
88
  end
90
89
 
91
90
  session_id = extract_session_id(response)
@@ -171,22 +170,26 @@ module KillBillClient
171
170
  end
172
171
 
173
172
  def attribute(name)
174
- send('attr_accessor', name.to_sym)
175
- attributes = @json_attributes ||= []
176
- begin
177
- json_attributes.push(name.to_s)
178
- rescue NameError
179
- (class << self; self; end).
180
- send(:define_method, :json_attributes) { attributes }
181
- retry
182
- end
183
- end
173
+ self.send('attr_accessor', name.to_sym)
174
+
175
+ self.instance_variable_set('@json_attributes', []) unless self.instance_variable_get('@json_attributes')
176
+ self.instance_variable_get('@json_attributes') << name.to_s
177
+
178
+ attributes = self.instance_variable_get('@json_attributes')
179
+
180
+ (
181
+ class << self;
182
+ self
183
+ end).send(:define_method, :json_attributes) do
184
+ attributes
185
+ end
186
+ end
184
187
 
185
188
  def has_many(attr_name, type = nil)
186
189
  send("attr_accessor", attr_name.to_sym)
187
190
 
188
191
  #add it to attribute_names
189
- @@attribute_names[self.name] ||= {}
192
+ @@attribute_names[self.name] = {} unless @@attribute_names[self.name]
190
193
  @@attribute_names[self.name][attr_name.to_sym] = {:type => type, :cardinality => :many}
191
194
  end
192
195
 
@@ -194,7 +197,7 @@ module KillBillClient
194
197
  send("attr_accessor", attr_name.to_sym)
195
198
 
196
199
  #add it to attribute_names
197
- @@attribute_names[self.name] ||= {}
200
+ @@attribute_names[self.name] = {} unless @@attribute_names[self.name]
198
201
  @@attribute_names[self.name][attr_name.to_sym] = {:type => type, :cardinality => :one}
199
202
  end
200
203
 
@@ -7,8 +7,8 @@ module KillBillClient
7
7
  :session_id,
8
8
  :pagination_max_nb_records,
9
9
  :pagination_total_nb_records,
10
- :pagination_next_page,
11
- :response
10
+ :pagination_next_page
11
+ :response
12
12
 
13
13
  # Same as .each, but fetch remaining pages as we go
14
14
  def each_in_batches(&block)
@@ -27,7 +27,7 @@ module KillBillClient
27
27
  end
28
28
 
29
29
  def delete_tenant_plugin_config(plugin_name, user = nil, reason = nil, comment = nil, options = {})
30
- delete_tenant_key_value(plugin_name, "uploadPluginConfig", "plugin config", user, reason, comment, options)
30
+ delete_tenant_user_key_value(plugin_name, "uploadPluginConfig", "plugin config", user, reason, comment, options)
31
31
  end
32
32
 
33
33
  def get_tenant_user_key_value(key_name, options = {})
@@ -40,7 +40,7 @@ module KillBillClient
40
40
 
41
41
 
42
42
  def delete_tenant_user_key_value(key_name, user = nil, reason = nil, comment = nil, options = {})
43
- delete_tenant_key_value(key_name, "userKeyValue", "tenant key/value", user, reason, comment, options)
43
+ delete_tenant_user_key_value(key_name, "userKeyValue", "tenant key/value", user, reason, comment, options)
44
44
  end
45
45
 
46
46
  def get_tenant_key_value(key_name, key_path, error_id_str, options = {})
@@ -75,7 +75,7 @@ module KillBillClient
75
75
  end
76
76
 
77
77
 
78
- def delete_tenant_key_value(key_name, key_path, error_id_str, user = nil, reason = nil, comment = nil, options = {})
78
+ def delete_tenant_user_key_value(key_name, key_path, error_id_str, user = nil, reason = nil, comment = nil, options = {})
79
79
 
80
80
  require_multi_tenant_options!(options, "Deleting a #{error_id_str} is only supported in multi-tenant mode")
81
81
 
@@ -164,9 +164,9 @@ module KillBillClient
164
164
  created_transaction = yield
165
165
  rescue KillBillClient::API::ResponseError => error
166
166
  response = error.response
167
- if response['location']
167
+ if response.header['location']
168
168
  created_transaction = Transaction.new
169
- created_transaction.uri = response['location']
169
+ created_transaction.uri = response.header['location']
170
170
  else
171
171
  raise error
172
172
  end
@@ -1,7 +1,7 @@
1
1
  module KillBillClient
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 35
3
+ MAJOR = 1
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
@@ -8,10 +8,6 @@ describe KillBillClient::API do
8
8
  ]
9
9
  }
10
10
 
11
- let (:ssl_uri) {URI.parse 'https://killbill.io'}
12
- let (:uri) {URI.parse 'http://killbill.io'}
13
- let (:timeouts) {{:read_timeout => 10000, :connection_timeout => 5000}}
14
-
15
11
  it 'should send double-encoded uri' do
16
12
  contract_property = KillBillClient::Model::PluginPropertyAttributes.new
17
13
  contract_property.key = :contractId
@@ -50,23 +46,6 @@ describe KillBillClient::API do
50
46
  # also ensure the undecoded value is different so that it was indeed encocded twice
51
47
  expect(output_info_property[1]).not_to eq(CGI.unescape output_info_property[1])
52
48
  end
53
-
54
- it 'should use the default parameters for http client' do
55
- http_adapter = DummyForHTTPAdapter.new
56
- http_client = http_adapter.send(:create_http_client, uri)
57
- expect(http_client.read_timeout).to eq(60)
58
- expect(http_client.open_timeout).to be_nil
59
- expect(http_client.use_ssl?).to be false
60
- end
61
-
62
- it 'should set the correct parameters for http client' do
63
- http_adapter = DummyForHTTPAdapter.new
64
- http_client = http_adapter.send(:create_http_client, ssl_uri, timeouts)
65
- expect(http_client.read_timeout).to eq(timeouts[:read_timeout] / 1000)
66
- expect(http_client.open_timeout).to eq(timeouts[:connection_timeout] / 1000)
67
- expect(http_client.use_ssl?).to be true
68
- end
69
-
70
49
  end
71
50
 
72
51
  class DummyForHTTPAdapter
@@ -59,7 +59,7 @@ describe KillBillClient::Model::Resource do
59
59
  end
60
60
 
61
61
  it 'should create alias attr accessors' do
62
- KillBillClient::Model::EventSubscription.create_alias :alias_date, :requested_dt
62
+ KillBillClient::Model::EventSubscription.create_alias :alias_date, :effective_dt
63
63
 
64
64
  methods = KillBillClient::Model::EventSubscription.instance_methods
65
65
  expect(methods.map(&:to_sym)).to include :alias_date
@@ -67,7 +67,7 @@ describe KillBillClient::Model::Resource do
67
67
 
68
68
  evt = KillBillClient::Model::EventSubscription.new
69
69
  evt.alias_date = "devaroop"
70
- expect(evt.requested_dt).to eq("devaroop")
70
+ expect(evt.effective_dt).to eq("devaroop")
71
71
  expect(evt.alias_date).to eq("devaroop")
72
72
  end
73
73
  end
metadata CHANGED
@@ -1,77 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.2.0
20
- - - <
21
- - !ruby/object:Gem::Version
22
- version: 2.0.0
23
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - '>='
24
+ - - ">="
26
25
  - !ruby/object:Gem::Version
27
26
  version: 1.2.0
28
- - - <
29
- - !ruby/object:Gem::Version
30
- version: 2.0.0
31
- prerelease: false
32
- type: :runtime
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - '>='
31
+ - - ">="
38
32
  - !ruby/object:Gem::Version
39
33
  version: 10.0.0
40
- - - <
34
+ - - "<"
41
35
  - !ruby/object:Gem::Version
42
36
  version: 11.0.0
43
- requirement: !ruby/object:Gem::Requirement
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
44
40
  requirements:
45
- - - '>='
41
+ - - ">="
46
42
  - !ruby/object:Gem::Version
47
43
  version: 10.0.0
48
- - - <
44
+ - - "<"
49
45
  - !ruby/object:Gem::Version
50
46
  version: 11.0.0
51
- prerelease: false
52
- type: :development
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: rspec
55
- version_requirements: !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
- - - ~>
51
+ - - "~>"
58
52
  - !ruby/object:Gem::Version
59
53
  version: '3.4'
60
- requirement: !ruby/object:Gem::Requirement
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
61
57
  requirements:
62
- - - ~>
58
+ - - "~>"
63
59
  - !ruby/object:Gem::Version
64
60
  version: '3.4'
65
- prerelease: false
66
- type: :development
67
61
  description: An API client library for Kill Bill.
68
62
  email: killbilling-users@googlegroups.com
69
63
  executables: []
70
64
  extensions: []
71
65
  extra_rdoc_files: []
72
66
  files:
73
- - .gitignore
74
- - .travis.yml
67
+ - ".gitignore"
68
+ - ".travis.yml"
75
69
  - Gemfile
76
70
  - README.md
77
71
  - Rakefile
@@ -187,8 +181,8 @@ files:
187
181
  - lib/rails/generators/killbill_client/config_generator.rb
188
182
  - lib/rails/killbill_client.rb
189
183
  - spec/killbill_client/base_uri_spec.rb
184
+ - spec/killbill_client/encoding_spec.rb
190
185
  - spec/killbill_client/errors_spec.rb
191
- - spec/killbill_client/http_adapter_spec.rb
192
186
  - spec/killbill_client/model_relation_spec.rb
193
187
  - spec/killbill_client/remote/api_spec.rb
194
188
  - spec/killbill_client/remote/model_spec.rb
@@ -199,26 +193,35 @@ homepage: http://www.killbilling.org
199
193
  licenses:
200
194
  - Apache License (2.0)
201
195
  metadata: {}
202
- post_install_message:
196
+ post_install_message:
203
197
  rdoc_options:
204
- - --exclude
205
- - .
198
+ - "--exclude"
199
+ - "."
206
200
  require_paths:
207
201
  - lib
208
202
  required_ruby_version: !ruby/object:Gem::Requirement
209
203
  requirements:
210
- - - '>='
204
+ - - ">="
211
205
  - !ruby/object:Gem::Version
212
206
  version: 1.8.6
213
207
  required_rubygems_version: !ruby/object:Gem::Requirement
214
208
  requirements:
215
- - - '>='
209
+ - - ">="
216
210
  - !ruby/object:Gem::Version
217
211
  version: '0'
218
212
  requirements: []
219
- rubyforge_project:
220
- rubygems_version: 2.4.6
221
- signing_key:
213
+ rubyforge_project:
214
+ rubygems_version: 2.2.2
215
+ signing_key:
222
216
  specification_version: 4
223
217
  summary: Kill Bill client library.
224
- test_files: []
218
+ test_files:
219
+ - spec/killbill_client/base_uri_spec.rb
220
+ - spec/killbill_client/encoding_spec.rb
221
+ - spec/killbill_client/errors_spec.rb
222
+ - spec/killbill_client/model_relation_spec.rb
223
+ - spec/killbill_client/remote/api_spec.rb
224
+ - spec/killbill_client/remote/model_spec.rb
225
+ - spec/killbill_client/resource_spec.rb
226
+ - spec/killbill_client/resources_spec.rb
227
+ - spec/spec_helper.rb