killbill-client 0.34.0 → 0.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/killbill_client.gemspec +1 -1
- data/lib/killbill_client/api/net_http_adapter.rb +10 -3
- data/lib/killbill_client/models/invoice.rb +5 -5
- data/lib/killbill_client/models/resource.rb +16 -19
- data/lib/killbill_client/models/resources.rb +2 -2
- data/lib/killbill_client/models/tenant.rb +3 -3
- data/lib/killbill_client/models/transaction.rb +2 -2
- data/lib/killbill_client/version.rb +1 -1
- data/spec/killbill_client/{encoding_spec.rb → http_adapter_spec.rb} +21 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad39131d3cbc2056cd9333e9943faf20e4c8bf8
|
4
|
+
data.tar.gz: 54e03e703307ad62140d9ed8d68595a4e879c543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb2f78089cd651ace503d68dac2a398190a5f820de513b32c69923ea27857be5153b8870316d5cce6f45e6fbb57a82cf0048e7bc2da362a35c0b4c5dfe1fe1e
|
7
|
+
data.tar.gz: 354334e362fca07e882e912196bdc1044b719c02411ab4f633296a4d05935377701be47fc80ce7e0f5b5f80583964550670a53b5ba57c0dbe7666f0d38c27b1d
|
data/killbill_client.gemspec
CHANGED
@@ -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'
|
42
|
+
s.add_dependency 'json', '>= 1.2.0', '< 2.0.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,6 +63,14 @@ 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
|
+
|
66
74
|
def request(method, relative_uri, options = {})
|
67
75
|
head = headers.dup
|
68
76
|
head.update options[:head] if options[:head]
|
@@ -74,7 +82,7 @@ module KillBillClient
|
|
74
82
|
# Note: make sure to keep the full path (if any) from URI::HTTP, for non-ROOT deployments
|
75
83
|
# See https://github.com/killbill/killbill/issues/221#issuecomment-151980263
|
76
84
|
base_path = uri.request_uri == '/' ? '' : uri.request_uri
|
77
|
-
uri += (base_path + URI.escape(relative_uri))
|
85
|
+
uri += (base_path + URI::DEFAULT_PARSER.escape(relative_uri))
|
78
86
|
else
|
79
87
|
uri = relative_uri
|
80
88
|
uri = URI.parse(uri) unless uri.is_a?(URI)
|
@@ -140,8 +148,7 @@ module KillBillClient
|
|
140
148
|
request['X-Request-Id'] = options[:request_id]
|
141
149
|
end
|
142
150
|
|
143
|
-
http =
|
144
|
-
http.use_ssl = uri.scheme == 'https'
|
151
|
+
http = create_http_client uri, options
|
145
152
|
net_http.each_pair { |key, value| http.send "#{key}=", value }
|
146
153
|
|
147
154
|
if KillBillClient.logger
|
@@ -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
|
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
|
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
|
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
|
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
|
197
197
|
nil
|
198
198
|
end
|
199
199
|
end
|
@@ -15,6 +15,7 @@ module KillBillClient
|
|
15
15
|
@@attribute_names = {}
|
16
16
|
|
17
17
|
def initialize(hash = nil)
|
18
|
+
@uri = nil
|
18
19
|
# Make sure we support ActiveSupport::HashWithIndifferentAccess for Kaui
|
19
20
|
if hash.respond_to?(:each)
|
20
21
|
hash.each do |key, value|
|
@@ -75,8 +76,8 @@ module KillBillClient
|
|
75
76
|
when %r{text/plain}
|
76
77
|
response.body
|
77
78
|
when %r{application/xml}
|
78
|
-
if response
|
79
|
-
response
|
79
|
+
if response['location']
|
80
|
+
response['location']
|
80
81
|
else
|
81
82
|
response.body
|
82
83
|
end
|
@@ -84,7 +85,7 @@ module KillBillClient
|
|
84
85
|
record = from_json resource_class, response.body
|
85
86
|
if record.nil?
|
86
87
|
record = resource_class.new
|
87
|
-
record.uri = response
|
88
|
+
record.uri = response['location']
|
88
89
|
end
|
89
90
|
|
90
91
|
session_id = extract_session_id(response)
|
@@ -170,26 +171,22 @@ module KillBillClient
|
|
170
171
|
end
|
171
172
|
|
172
173
|
def attribute(name)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end).send(:define_method, :json_attributes) do
|
184
|
-
attributes
|
185
|
-
end
|
186
|
-
end
|
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
|
187
184
|
|
188
185
|
def has_many(attr_name, type = nil)
|
189
186
|
send("attr_accessor", attr_name.to_sym)
|
190
187
|
|
191
188
|
#add it to attribute_names
|
192
|
-
@@attribute_names[self.name]
|
189
|
+
@@attribute_names[self.name] ||= {}
|
193
190
|
@@attribute_names[self.name][attr_name.to_sym] = {:type => type, :cardinality => :many}
|
194
191
|
end
|
195
192
|
|
@@ -197,7 +194,7 @@ module KillBillClient
|
|
197
194
|
send("attr_accessor", attr_name.to_sym)
|
198
195
|
|
199
196
|
#add it to attribute_names
|
200
|
-
@@attribute_names[self.name]
|
197
|
+
@@attribute_names[self.name] ||= {}
|
201
198
|
@@attribute_names[self.name][attr_name.to_sym] = {:type => type, :cardinality => :one}
|
202
199
|
end
|
203
200
|
|
@@ -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
|
-
|
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
|
-
|
30
|
+
delete_tenant_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
|
-
|
43
|
+
delete_tenant_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
|
78
|
+
def delete_tenant_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
|
167
|
+
if response['location']
|
168
168
|
created_transaction = Transaction.new
|
169
|
-
created_transaction.uri = response
|
169
|
+
created_transaction.uri = response['location']
|
170
170
|
else
|
171
171
|
raise error
|
172
172
|
end
|
@@ -8,6 +8,10 @@ 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
|
+
|
11
15
|
it 'should send double-encoded uri' do
|
12
16
|
contract_property = KillBillClient::Model::PluginPropertyAttributes.new
|
13
17
|
contract_property.key = :contractId
|
@@ -46,6 +50,23 @@ describe KillBillClient::API do
|
|
46
50
|
# also ensure the undecoded value is different so that it was indeed encocded twice
|
47
51
|
expect(output_info_property[1]).not_to eq(CGI.unescape output_info_property[1])
|
48
52
|
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
|
+
|
49
70
|
end
|
50
71
|
|
51
72
|
class DummyForHTTPAdapter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: killbill-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Killbill core team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -17,11 +17,17 @@ dependencies:
|
|
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
|
20
23
|
requirement: !ruby/object:Gem::Requirement
|
21
24
|
requirements:
|
22
25
|
- - '>='
|
23
26
|
- !ruby/object:Gem::Version
|
24
27
|
version: 1.2.0
|
28
|
+
- - <
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
25
31
|
prerelease: false
|
26
32
|
type: :runtime
|
27
33
|
- !ruby/object:Gem::Dependency
|
@@ -181,8 +187,8 @@ files:
|
|
181
187
|
- lib/rails/generators/killbill_client/config_generator.rb
|
182
188
|
- lib/rails/killbill_client.rb
|
183
189
|
- spec/killbill_client/base_uri_spec.rb
|
184
|
-
- spec/killbill_client/encoding_spec.rb
|
185
190
|
- spec/killbill_client/errors_spec.rb
|
191
|
+
- spec/killbill_client/http_adapter_spec.rb
|
186
192
|
- spec/killbill_client/model_relation_spec.rb
|
187
193
|
- spec/killbill_client/remote/api_spec.rb
|
188
194
|
- spec/killbill_client/remote/model_spec.rb
|