killbill-client 1.11.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f34cbba28821aa7e8fdee247bd18b91f1934b13b
4
- data.tar.gz: 09ef75444ac99a4bcecdc75bdad1a763ded0e27a
3
+ metadata.gz: e6023e6dc3700baf51b54eb966013c0097df4bb6
4
+ data.tar.gz: 273deea1e796f0f63b06d1d911e58494e4d51b7f
5
5
  SHA512:
6
- metadata.gz: a963240b1466170b108ba01fc8503c03b35b8c564bac405e35b329ea1a37d8803a3a0a72ddfeb0c25bc94de04438369bcca6dd4379cdfe51dd37e9aa4d236853
7
- data.tar.gz: 3b07fb964a98abf2bf20c22320567fd9cc426042db68adb2c69cf4162d53dfd313670a7b6d81fc8acddb58f8584084645100b63b18e2ddde9dfa95d4b82c5098
6
+ metadata.gz: 9a484124e71caf99ea3afb36f83cc8ccbd6c75d5f94f67646c9b6fb0fd4bc817257b99a47e3e19e735d758aed9440ecd3f60962e0810a0f49288d471faa58bce
7
+ data.tar.gz: 9934d9680adeed6c8d8c7777e908da473de810f3f9721951ee5201ad226abde89dd5c22de62629099d059e51cf7ae6f8657c057e656e6ef07183df8bf63908d3
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env sh
2
+
3
+ travis_retry() {
4
+ local result=0
5
+ local count=1
6
+ while [ $count -le 3 ]; do
7
+ [ $result -ne 0 ] && {
8
+ echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
9
+ }
10
+ "$@" && { result=0 && break; } || result=$?
11
+ count=$(($count + 1))
12
+ sleep 1
13
+ done
14
+ [ $count -gt 3 ] && {
15
+ echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
16
+ }
17
+ return $result
18
+ }
19
+
20
+ sudo sysctl -w net.ipv4.tcp_fin_timeout=15
21
+ sudo sysctl -w net.ipv4.tcp_tw_reuse=1
22
+
23
+ if [ "$DB_ADAPTER" = 'mysql2' ] || [ "$DB_ADAPTER" = 'mariadb' ]; then
24
+ mysql -u $DB_USER -e 'create database killbill;'
25
+ curl 'http://docs.killbill.io/0.18/ddl.sql' | mysql -u $DB_USER killbill
26
+ elif [ "$DB_ADAPTER" = 'postgresql' ]; then
27
+ psql -U $DB_USER -c 'create database killbill;'
28
+ curl 'https://raw.githubusercontent.com/killbill/killbill/master/util/src/main/resources/org/killbill/billing/util/ddl-postgresql.sql' | psql -U $DB_USER killbill
29
+ curl 'https://raw.githubusercontent.com/killbill/killbill/master/util/src/main/resources/org/killbill/billing/util/ddl-postgresql.sql' | psql -U $DB_USER kaui_test
30
+ curl 'http://docs.killbill.io/0.18/ddl.sql' | psql -U $DB_USER killbill
31
+ fi
32
+
33
+ if $(ruby -e'require "java"'); then
34
+ # Somehow missing on JRuby-9
35
+ gem install bundler
36
+ bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
37
+ else
38
+ bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
39
+ fi
40
+
41
+ travis_retry curl -L -O https://search.maven.org/remotecontent?filepath=org/kill-bill/billing/installer/kpm/0.6.0/kpm-0.6.0-linux-x86_64.tar.gz
42
+ tar zxf kpm-0.6.0-linux-x86_64.tar.gz
43
+ kpm-0.6.0-linux-x86_64/kpm install
44
+
45
+ if [ "$DB_ADAPTER" = 'mysql2' ] || [ "$DB_ADAPTER" = 'mariadb' ]; then
46
+ cat<<EOS >> conf/catalina.properties
47
+ org.killbill.dao.url=jdbc:mysql://127.0.0.1:$DB_PORT/killbill
48
+ org.killbill.billing.osgi.dao.url=jdbc:mysql://127.0.0.1:$DB_PORT/killbill
49
+ EOS
50
+ elif [ "$DB_ADAPTER" = 'postgresql' ]; then
51
+ cat<<EOS >> conf/catalina.properties
52
+ org.killbill.dao.url=jdbc:postgresql://127.0.0.1:$DB_PORT/killbill
53
+ org.killbill.billing.osgi.dao.url=jdbc:postgresql://127.0.0.1:$DB_PORT/killbill
54
+ EOS
55
+ fi
56
+
57
+ cat<<EOS >> conf/catalina.properties
58
+ org.killbill.dao.user=$DB_USER
59
+ org.killbill.dao.password=
60
+ org.killbill.billing.osgi.dao.user=$DB_USER
61
+ org.killbill.billing.osgi.dao.password=
62
+ org.killbill.catalog.uri=SpyCarAdvanced.xml
63
+ org.killbill.server.test.mode=true
64
+ EOS
65
+
66
+ ./bin/catalina.sh start
67
+
68
+ TIME_LIMIT=$(( $(date +%s) + 120 ))
69
+ RET=0
70
+ while [ $RET != 201 -a $(date +%s) -lt $TIME_LIMIT ] ; do
71
+ RET=$(curl -s \
72
+ -o /dev/null \
73
+ -w "%{http_code}" \
74
+ -X POST \
75
+ -u 'admin:password' \
76
+ -H 'Content-Type:application/json' \
77
+ -H 'X-Killbill-CreatedBy:admin' \
78
+ -d '{"apiKey":"bob", "apiSecret":"lazar"}' \
79
+ "http://127.0.0.1:8080/1.0/kb/tenants?useGlobalDefault=true")
80
+ tail -50 logs/catalina.out
81
+ sleep 5
82
+ done
83
+
84
+ # For Travis debugging
85
+ echo "*** conf/catalina.properties"
86
+ cat conf/catalina.properties
87
+
88
+ echo "*** logs/catalina.out"
89
+ tail -50 logs/catalina.out
@@ -3,20 +3,19 @@ language: ruby
3
3
  sudo: required
4
4
  cache: bundler
5
5
 
6
+ services:
7
+ - mysql
8
+
6
9
  dist: trusty
7
10
 
8
11
  before_install:
9
- - sudo sysctl -w net.ipv4.tcp_fin_timeout=15
10
- - sudo sysctl -w net.ipv4.tcp_tw_reuse=1
11
- - travis_retry gem install bundler
12
- - travis_retry curl -LO 'https://search.maven.org/remotecontent?filepath=org/kill-bill/billing/killbill-profiles-killbill/0.18.8/killbill-profiles-killbill-0.18.8-jetty-console.war' && java -Dorg.killbill.catalog.uri=SpyCarAdvanced.xml -Djava.security.egd=file:/dev/./urandom -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -jar killbill-profiles-killbill-0.18.8-jetty-console.war --port 8080 --headless 2>&1 | egrep -v "lvl='INFO'| < | > |[ \t]*at [ \ta-zA-Z0-9\.\:\(\)]+" & sleep 80 && travis_retry curl -v -X POST -u 'admin:password' -H 'Content-Type:application/json' -H 'X-Killbill-CreatedBy:admin' -d '{"apiKey":"bob", "apiSecret":"lazar"}' "http://127.0.0.1:8080/1.0/kb/tenants"
12
+ - jdk_switcher use openjdk8
13
+ - ./.travis-install-dependencies.sh
13
14
 
14
15
  before_script:
15
16
  - jdk_switcher use $JDK
16
17
 
17
- # Need Kill Bill 0.18.9
18
- #script: 'bundle exec rake test:spec test:remote:spec'
19
- script: 'bundle exec rake test:spec'
18
+ script: 'bundle exec rake test:spec test:remote:spec'
20
19
 
21
20
  notifications:
22
21
  email:
@@ -24,7 +23,7 @@ notifications:
24
23
 
25
24
  env:
26
25
  global:
27
- - JRUBY_OPTS='--2.0 -J-Xmx1024M'
26
+ - DB_ADAPTER=mariadb DB_USER='root' DB_PORT=3306 JRUBY_OPTS='-J-Xmx1024m --debug -J-Djava.security.egd=file:/dev/./urandom'
28
27
 
29
28
  matrix:
30
29
  include:
@@ -32,16 +31,17 @@ matrix:
32
31
  - rvm: 1.8.7
33
32
  - rvm: 1.9.3
34
33
  - rvm: 2.2.0
34
+ - rvm: 2.4.2
35
35
  - rvm: ruby-head
36
- - rvm: jruby-1.7.26
37
- env: JDK=oraclejdk8
38
36
  - rvm: jruby-1.7.26
39
37
  env: JDK=openjdk8
40
- - rvm: jruby-head
41
- env: JDK=oraclejdk8
42
38
  - rvm: jruby-head
43
39
  env: JDK=openjdk8
44
40
  allow_failures:
45
41
  - rvm: ruby-head
46
42
  - rvm: jruby-head
43
+ - rvm: 1.8.7
44
+ - rvm: 1.9.3
45
+ - rvm: 2.2.0
46
+ - rvm: jruby-1.7.26
47
47
  fast_finish: true
@@ -39,7 +39,9 @@ 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
+ if RUBY_VERSION < '2.0.0'
43
+ s.add_dependency 'json', '>= 1.2.0', '< 2.0.0'
44
+ end
43
45
 
44
46
  s.add_development_dependency 'rake', '>= 10.0.0', '< 11.0.0'
45
47
  s.add_development_dependency 'rspec', '~> 3.4'
@@ -123,4 +123,13 @@ rescue LoadError, NoMethodError
123
123
  end
124
124
  end
125
125
 
126
+ # URI::DEFAULT_PARSER is NOT compatible with ree 1.8.3
127
+ module URI
128
+ module DEFAULT_PARSER
129
+ def self.escape(*args)
130
+ URI.escape(*args)
131
+ end
132
+ end
133
+ end unless defined? URI::DEFAULT_PARSER
134
+
126
135
  require 'rails/killbill_client' if defined? Rails::Railtie
@@ -46,7 +46,7 @@ module KillBillClient
46
46
  comment = args[3]
47
47
  options = args[4] || {}
48
48
 
49
- custom_fields_param = custom_fields.is_a?(Enumerable) ? custom_fields.join(",") : custom_fields
49
+ custom_fields_param = custom_fields.respond_to?(:join) ? custom_fields.join(",") : custom_fields
50
50
  self.class.delete "#{url_prefix}/#{send(id_alias)}/customFields",
51
51
  {},
52
52
  {
@@ -1,12 +1,17 @@
1
1
  module KillBillClient
2
2
  module Model
3
3
  class InvoicePayment < InvoicePaymentAttributes
4
+
5
+ include KillBillClient::Model::CustomFieldHelper
6
+
4
7
  KILLBILL_API_INVOICE_PAYMENTS_PREFIX = "#{KILLBILL_API_PREFIX}/invoicePayments"
5
8
 
6
9
  has_many :transactions, KillBillClient::Model::Transaction
7
10
  has_many :payment_attempts, KillBillClient::Model::PaymentAttemptAttributes
8
11
  has_many :audit_logs, KillBillClient::Model::AuditLog
9
12
 
13
+ has_custom_fields KILLBILL_API_INVOICE_PAYMENTS_PREFIX, :payment_id
14
+
10
15
  class << self
11
16
  def find_by_id(payment_id, with_plugin_info = false, with_attempts = false, options = {})
12
17
  get "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}",
@@ -2,6 +2,7 @@ module KillBillClient
2
2
  module Model
3
3
  class Subscription < SubscriptionAttributes
4
4
 
5
+ include KillBillClient::Model::TagHelper
5
6
  include KillBillClient::Model::CustomFieldHelper
6
7
 
7
8
  KILLBILL_API_ENTITLEMENT_PREFIX = "#{KILLBILL_API_PREFIX}/subscriptions"
@@ -10,6 +11,7 @@ module KillBillClient
10
11
  has_many :price_overrides, KillBillClient::Model::PhasePriceOverrideAttributes
11
12
 
12
13
  has_custom_fields KILLBILL_API_ENTITLEMENT_PREFIX, :subscription_id
14
+ has_tags KILLBILL_API_ENTITLEMENT_PREFIX, :subscription_id
13
15
 
14
16
  class << self
15
17
  def find_by_id(subscription_id, options = {})
@@ -1,8 +1,8 @@
1
1
  module KillBillClient
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 11
5
- PATCH = 0
4
+ MINOR = 12
5
+ PATCH = 1
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
@@ -55,7 +55,6 @@ describe KillBillClient::API do
55
55
  http_adapter = DummyForHTTPAdapter.new
56
56
  http_client = http_adapter.send(:create_http_client, uri)
57
57
  expect(http_client.read_timeout).to eq(60)
58
- expect(http_client.open_timeout).to be_nil
59
58
  expect(http_client.use_ssl?).to be false
60
59
  expect(http_client.verify_mode).to be_nil
61
60
  end
@@ -150,11 +150,11 @@ describe KillBillClient::Model do
150
150
  # Check the account balance (need to wait a bit for the payment to happen)
151
151
  begin
152
152
  retries ||= 0
153
- sleep(0.1) if retries > 0
153
+ sleep(1) if retries > 0
154
154
  account = KillBillClient::Model::Account.find_by_id account.account_id, true
155
155
  expect(account.account_balance).to eq(0)
156
156
  rescue => e
157
- if (retries += 1) < 3
157
+ if (retries += 1) < 6
158
158
  retry
159
159
  else
160
160
  raise e
@@ -218,6 +218,19 @@ describe KillBillClient::Model do
218
218
  expect(payments.size).to eq(1)
219
219
  expect(payments.first.account_id).to eq(account.account_id)
220
220
 
221
+ # Add/Remove an invoice payment custom field
222
+ expect(invoice_payment.custom_fields.size).to eq(0)
223
+ custom_field = KillBillClient::Model::CustomField.new
224
+ custom_field.name = Time.now.to_i.to_s
225
+ custom_field.value = Time.now.to_i.to_s
226
+ invoice_payment.add_custom_field(custom_field, 'KillBill Spec test')
227
+ custom_fields = invoice_payment.custom_fields
228
+ expect(custom_fields.size).to eq(1)
229
+ expect(custom_fields.first.name).to eq(custom_field.name)
230
+ expect(custom_fields.first.value).to eq(custom_field.value)
231
+ invoice_payment.remove_custom_field(custom_fields.first.custom_field_id, 'KillBill Spec test')
232
+ expect(invoice_payment.custom_fields.size).to eq(0)
233
+
221
234
  # Check the account balance
222
235
  account = KillBillClient::Model::Account.find_by_id account.account_id, true
223
236
  expect(account.account_balance).to eq(0)
@@ -291,7 +304,7 @@ describe KillBillClient::Model do
291
304
  bundles = KillBillClient::Model::Bundle.find_all_by_account_id_and_external_key(account.account_id, bundle.external_key)
292
305
  expect(bundles.size).to eq(1)
293
306
  expect(bundles[0]).to eq(bundle)
294
-
307
+
295
308
  # Try to export it
296
309
  export = KillBillClient::Model::Export.find_by_account_id(account.account_id, 'KillBill Spec test')
297
310
  expect(export).to include(account.account_id)
@@ -316,7 +329,7 @@ describe KillBillClient::Model do
316
329
  end
317
330
 
318
331
  it 'should manipulate tenants', :integration => true do
319
- api_key = Time.now.to_i.to_s + Random.rand(100).to_s
332
+ api_key = Time.now.to_i.to_s + rand(100).to_s
320
333
  api_secret = 'S4cr3333333t!!!!!!lolz'
321
334
 
322
335
  tenant = KillBillClient::Model::Tenant.new
@@ -20,7 +20,7 @@ RSpec.configure do |config|
20
20
 
21
21
  config.before(:each, :integration => true) do
22
22
  # Setup a tenant for that test
23
- KillBillClient.api_key = Time.now.to_i.to_s + Random.rand(100).to_s
23
+ KillBillClient.api_key = Time.now.to_i.to_s + rand(100).to_s
24
24
  KillBillClient.api_secret = 'S4cr3333333t!!!!!!lolz'
25
25
 
26
26
  tenant = KillBillClient::Model::Tenant.new
metadata CHANGED
@@ -1,36 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.1
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: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: 1.2.0
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: 2.0.0
22
- name: json
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.2.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 2.0.0
33
- - !ruby/object:Gem::Dependency
14
+ name: rake
34
15
  requirement: !ruby/object:Gem::Requirement
35
16
  requirements:
36
17
  - - ">="
@@ -39,9 +20,8 @@ dependencies:
39
20
  - - "<"
40
21
  - !ruby/object:Gem::Version
41
22
  version: 11.0.0
42
- name: rake
43
- prerelease: false
44
23
  type: :development
24
+ prerelease: false
45
25
  version_requirements: !ruby/object:Gem::Requirement
46
26
  requirements:
47
27
  - - ">="
@@ -51,14 +31,14 @@ dependencies:
51
31
  - !ruby/object:Gem::Version
52
32
  version: 11.0.0
53
33
  - !ruby/object:Gem::Dependency
34
+ name: rspec
54
35
  requirement: !ruby/object:Gem::Requirement
55
36
  requirements:
56
37
  - - "~>"
57
38
  - !ruby/object:Gem::Version
58
39
  version: '3.4'
59
- name: rspec
60
- prerelease: false
61
40
  type: :development
41
+ prerelease: false
62
42
  version_requirements: !ruby/object:Gem::Requirement
63
43
  requirements:
64
44
  - - "~>"
@@ -71,6 +51,7 @@ extensions: []
71
51
  extra_rdoc_files: []
72
52
  files:
73
53
  - ".gitignore"
54
+ - ".travis-install-dependencies.sh"
74
55
  - ".travis.yml"
75
56
  - Gemfile
76
57
  - README.md
@@ -213,7 +194,7 @@ homepage: http://www.killbilling.org
213
194
  licenses:
214
195
  - Apache License (2.0)
215
196
  metadata: {}
216
- post_install_message:
197
+ post_install_message:
217
198
  rdoc_options:
218
199
  - "--exclude"
219
200
  - "."
@@ -230,9 +211,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
211
  - !ruby/object:Gem::Version
231
212
  version: '0'
232
213
  requirements: []
233
- rubyforge_project:
234
- rubygems_version: 2.4.8
235
- signing_key:
214
+ rubyforge_project:
215
+ rubygems_version: 2.6.13
216
+ signing_key:
236
217
  specification_version: 4
237
218
  summary: Kill Bill client library.
238
219
  test_files: []