killbill-client 3.0.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +15 -109
  3. data/.github/CONTRIBUTING.md +20 -0
  4. data/.github/FUNDING.yml +3 -0
  5. data/.github/workflows/ci.yml +145 -0
  6. data/.github/workflows/release.yml +46 -0
  7. data/README.md +32 -1
  8. data/bin/retry +21 -0
  9. data/docker/docker-compose.ci.mysql.yml +21 -0
  10. data/docker/docker-compose.ci.postgresql.yml +21 -0
  11. data/killbill_client.gemspec +2 -1
  12. data/lib/killbill_client.rb +2 -0
  13. data/lib/killbill_client/api/api.rb +1 -1
  14. data/lib/killbill_client/api/net_http_adapter.rb +13 -2
  15. data/lib/killbill_client/models/account.rb +3 -5
  16. data/lib/killbill_client/models/credit.rb +5 -5
  17. data/lib/killbill_client/models/custom_field.rb +17 -0
  18. data/lib/killbill_client/models/gen/invoice_attributes.rb +1 -0
  19. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +1 -0
  20. data/lib/killbill_client/models/gen/overdue_state_attributes.rb +0 -1
  21. data/lib/killbill_client/models/gen/require_gen.rb +52 -53
  22. data/lib/killbill_client/models/gen/subscription_attributes.rb +1 -0
  23. data/lib/killbill_client/models/helpers/custom_field_helper.rb +1 -1
  24. data/lib/killbill_client/models/invoice.rb +4 -7
  25. data/lib/killbill_client/models/subscription.rb +10 -0
  26. data/lib/killbill_client/version.rb +1 -16
  27. data/spec/killbill_client/http_adapter_spec.rb +32 -0
  28. data/spec/killbill_client/remote/model_spec.rb +15 -11
  29. metadata +25 -8
  30. data/lib/killbill_client/models/gen/block_price_override_attributes.rb +0 -37
  31. data/lib/killbill_client/models/gen/credit_attributes.rb +0 -43
  32. data/lib/killbill_client/models/gen/phase_price_override_attributes.rb +0 -39
  33. data/lib/killbill_client/models/gen/tier_price_override_attributes.rb +0 -34
  34. data/lib/killbill_client/models/gen/usage_price_override_attributes.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ddae95b2a38eea5300104fce0e92606184bed34
4
- data.tar.gz: 669f913923892eef204cb64ddff346dfe9fb76b2
3
+ metadata.gz: 03e77573407a78aef2165e380bc7e1d0f672b53d
4
+ data.tar.gz: 27e12ebd3c57f128cdd181c16e77e19d4be9daa5
5
5
  SHA512:
6
- metadata.gz: 2c95bcc347ce08c76f84ab3a306227cc3829a3f5462a91f8738343e2d9ea01b868186c8e6f460ce1bc5e91b256b3caf8cf35f5bc94dd393f19a0e3d2c78c7ef4
7
- data.tar.gz: cc831b9690d0e06d2b0b2ca0dcaacd19bb5f42bf4ca601b28215bec2379fccfe3197ca3ea7a533c20f491b7e1a3ee944560fbc47db316c6d190fef7dca5a6d3b
6
+ metadata.gz: 88715661ffaa19c983d3c0ba9a091cbd4c8cd9a242675de0e44a43c8d9cbf6aad172620a1902d545c6d6ec0964cf161bcb5793b7f69f7a2cb50cc8315db2994b
7
+ data.tar.gz: 5d199dffd09feffc3a02c83b9e886c29ba84c6d8317603146eff9e931d708cb69aed72c763b9ac5c38de46ac6632ad697c9c4ce94ceee83128fe2cfbdddf3ad1
data/.circleci/config.yml CHANGED
@@ -5,90 +5,10 @@ defaults: &defaults
5
5
 
6
6
  version: 2
7
7
  jobs:
8
- build-jruby-1.7.26:
9
- <<: *defaults
10
- docker:
11
- - image: killbill/kbbuild:0.5.0
12
- steps:
13
- - checkout
14
- - restore_cache:
15
- key: v2-dependencies-jruby-1.7.26-{{ .Branch }}-{{ checksum "killbill_client.gemspec" }}
16
- - run:
17
- name: Install gem dependencies
18
- command: |
19
- bundle install --jobs=4 --retry=3 --path=vendor/bundle
20
- - save_cache:
21
- paths:
22
- - Gemfile.lock
23
- - .bundle
24
- - vendor/bundle
25
- key: v2-dependencies-jruby-1.7.26-{{ .Branch }}-{{ checksum "killbill_client.gemspec" }}
26
-
27
- test-mysql-jruby-1.7.26:
28
- <<: *defaults
29
- docker:
30
- - image: killbill/kbbuild:0.5.0
31
- - image: killbill/killbill:0.19.18
32
- - image: killbill/mariadb:0.19
33
- environment:
34
- - MYSQL_ROOT_PASSWORD=root
35
- steps:
36
- - checkout
37
- - restore_cache:
38
- key: v2-dependencies-jruby-1.7.26-{{ .Branch }}-{{ checksum "killbill_client.gemspec" }}
39
- - run:
40
- name: Setup DDL
41
- command: |
42
- set +e
43
- count=0
44
- until mysqladmin ping -h 127.0.0.1 -u root --password=root --silent; do
45
- if [[ "$count" == "25" ]]; then
46
- exit 1
47
- fi
48
- (( count++ ))
49
- printf '.'
50
- sleep 5
51
- done
52
- set -e
53
- - run:
54
- name: Setup Kill Bill
55
- command: |
56
- set +e
57
- count=0
58
- until $(curl --output /dev/null --silent --fail http://127.0.0.1:8080/1.0/healthcheck); do
59
- if [[ "$count" == "25" ]]; then
60
- exit 1
61
- fi
62
- (( count++ ))
63
-
64
- printf '.'
65
- sleep 5
66
- done
67
- set -e
68
- curl -v \
69
- -X POST \
70
- -u admin:password \
71
- -H 'Content-Type: application/json' \
72
- -H 'X-Killbill-CreatedBy: CircleCI' \
73
- -d '{"apiKey": "bob", "apiSecret": "lazar"}' \
74
- "http://127.0.0.1:8080/1.0/kb/tenants?useGlobalDefault=true"
75
- - run:
76
- name: Run tests
77
- command: |
78
- mkdir /tmp/test-results
79
- bundle exec rspec --format documentation \
80
- --out /tmp/test-results/rspec.txt \
81
- $(circleci tests glob "spec/**/*_spec.rb")
82
- - store_test_results:
83
- path: /tmp/test-results
84
- - store_artifacts:
85
- path: /tmp/test-results
86
- destination: test-results
87
-
88
8
  build-ruby-2.2.2:
89
9
  <<: *defaults
90
10
  docker:
91
- - image: killbill/kbbuild:0.5.0
11
+ - image: killbill/kbbuild:0.6.0
92
12
  steps:
93
13
  - checkout
94
14
  - restore_cache:
@@ -109,9 +29,9 @@ jobs:
109
29
  test-mysql-ruby-2.2.2:
110
30
  <<: *defaults
111
31
  docker:
112
- - image: killbill/kbbuild:0.5.0
113
- - image: killbill/killbill:0.19.18
114
- - image: killbill/mariadb:0.19
32
+ - image: killbill/kbbuild:0.6.0
33
+ - image: killbill/killbill:0.21.9
34
+ - image: killbill/mariadb:0.21
115
35
  environment:
116
36
  - MYSQL_ROOT_PASSWORD=root
117
37
  steps:
@@ -172,7 +92,7 @@ jobs:
172
92
  build-ruby-2.4.2:
173
93
  <<: *defaults
174
94
  docker:
175
- - image: killbill/kbbuild:0.5.0
95
+ - image: killbill/kbbuild:0.6.0
176
96
  steps:
177
97
  - checkout
178
98
  - restore_cache:
@@ -193,9 +113,9 @@ jobs:
193
113
  test-mysql-ruby-2.4.2:
194
114
  <<: *defaults
195
115
  docker:
196
- - image: killbill/kbbuild:0.5.0
197
- - image: killbill/killbill:0.19.18
198
- - image: killbill/mariadb:0.19
116
+ - image: killbill/kbbuild:0.6.0
117
+ - image: killbill/killbill:0.21.9
118
+ - image: killbill/mariadb:0.21
199
119
  environment:
200
120
  - MYSQL_ROOT_PASSWORD=root
201
121
  steps:
@@ -256,7 +176,7 @@ jobs:
256
176
  build-jruby-9.1.14.0:
257
177
  <<: *defaults
258
178
  docker:
259
- - image: killbill/kbbuild:0.5.0
179
+ - image: killbill/kbbuild:0.6.0
260
180
  steps:
261
181
  - checkout
262
182
  - restore_cache:
@@ -277,9 +197,9 @@ jobs:
277
197
  test-mysql-jruby-9.1.14.0:
278
198
  <<: *defaults
279
199
  docker:
280
- - image: killbill/kbbuild:0.5.0
281
- - image: killbill/killbill:0.19.18
282
- - image: killbill/mariadb:0.19
200
+ - image: killbill/kbbuild:0.6.0
201
+ - image: killbill/killbill:0.21.9
202
+ - image: killbill/mariadb:0.21
283
203
  environment:
284
204
  - MYSQL_ROOT_PASSWORD=root
285
205
  steps:
@@ -340,32 +260,18 @@ workflows:
340
260
  version: 2
341
261
  build-and-test:
342
262
  jobs:
343
- # Kill Bill plugins
344
- - build-jruby-1.7.26
345
263
  # Self-contained KPM
346
- - build-ruby-2.2.2:
347
- requires:
348
- - build-jruby-1.7.26
264
+ - build-ruby-2.2.2
349
265
  # Kaui and other gems
350
- - build-ruby-2.4.2:
351
- requires:
352
- - build-jruby-1.7.26
266
+ - build-ruby-2.4.2
353
267
  # Self-contained Kaui
354
- - build-jruby-9.1.14.0:
355
- requires:
356
- - build-jruby-1.7.26
357
- - test-mysql-jruby-1.7.26:
358
- requires:
359
- - build-jruby-1.7.26
268
+ - build-jruby-9.1.14.0
360
269
  - test-mysql-ruby-2.2.2:
361
270
  requires:
362
271
  - build-ruby-2.2.2
363
- - test-mysql-jruby-1.7.26
364
272
  - test-mysql-ruby-2.4.2:
365
273
  requires:
366
274
  - build-ruby-2.4.2
367
- - test-mysql-jruby-1.7.26
368
275
  - test-mysql-jruby-9.1.14.0:
369
276
  requires:
370
277
  - build-jruby-9.1.14.0
371
- - test-mysql-jruby-1.7.26
@@ -0,0 +1,20 @@
1
+ ## How to contribute to Kill Bill
2
+
3
+ **Do not open up a GitHub issue before reaching out to our [Mailing-List](https://groups.google.com/forum/#!forum/killbilling-users)**. GitHub issues are primarily intended for tracking bug reports and fixes by the core team.
4
+
5
+ #### **Did you find a bug?**
6
+
7
+ In your [Mailing-List](https://groups.google.com/forum/#!forum/killbilling-users) post, specify:
8
+
9
+ * Step by step description on how to reproduce the issue
10
+ * [Account data and system dump](http://docs.killbill.io/0.19/debugging.html#_seeking_help) via KPM of an affected account
11
+
12
+ #### **Do you intend to add a new feature or change an existing one?**
13
+
14
+ Do not open an issue or pull request on GitHub until you have collected positive feedback about the change on the [Mailing-List](https://groups.google.com/forum/#!forum/killbilling-users).
15
+
16
+ When submitting code, make sure to add [new tests](http://docs.killbill.io/0.19/development.html#_navigating_the_kill_bill_codebase).
17
+
18
+ #### **Do you want to contribute to the Kill Bill documentation?**
19
+
20
+ Open a pull request on GitHub in the [killbill-docs](https://github.com/killbill/killbill-docs) repository.
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [killbill]
@@ -0,0 +1,145 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ workflow_dispatch:
6
+
7
+ env:
8
+ COMPOSE_DOCKER_CLI_BUILD: 1
9
+ DB_NAME: kaui
10
+ DOCKER_BUILDKIT: 1
11
+ JRUBY_OPTS: --2.0 -J-Xmx1024M
12
+ KB_ADDRESS: 127.0.0.1
13
+ KB_PORT: 8080
14
+ RAILS_ENV: test
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ include:
22
+ - ruby-version: '2.4.2'
23
+ database-adapter: 'mysql2'
24
+ database-user: 'root'
25
+ database-password: 'root'
26
+ database-port: '3306'
27
+ docker-compose-file: 'docker-compose.ci.mysql.yml'
28
+ - ruby-version: 'jruby-9.1.17.0'
29
+ database-adapter: 'mysql2'
30
+ database-user: 'root'
31
+ database-password: 'root'
32
+ database-port: '3306'
33
+ docker-compose-file: 'docker-compose.ci.mysql.yml'
34
+ - ruby-version: '2.4.2'
35
+ database-adapter: 'postgresql'
36
+ database-user: 'postgres'
37
+ database-password: 'postgres'
38
+ database-port: '5432'
39
+ docker-compose-file: 'docker-compose.ci.postgresql.yml'
40
+ - ruby-version: 'jruby-9.1.17.0'
41
+ database-adapter: 'postgresql'
42
+ database-user: 'postgres'
43
+ database-password: 'postgres'
44
+ database-port: '5432'
45
+ docker-compose-file: 'docker-compose.ci.postgresql.yml'
46
+ steps:
47
+ - name: Checkout code
48
+ uses: actions/checkout@v2
49
+ - name: Set up Ruby
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: ${{ matrix.ruby-version }}
53
+ bundler-cache: true
54
+ - name: Start stack
55
+ run: |
56
+ cd docker
57
+ docker-compose -p it -f ${{ matrix.docker-compose-file }} up --no-start
58
+ docker start it_db_1
59
+ - name: Wait for MySQL
60
+ if: ${{ matrix.docker-compose-file == 'docker-compose.ci.mysql.yml' }}
61
+ run: |
62
+ set +e
63
+ count=0
64
+ until mysqladmin ping -h 127.0.0.1 -u root --password=root --silent; do
65
+ if [[ "$count" == "25" ]]; then
66
+ exit 1
67
+ fi
68
+ (( count++ ))
69
+ printf '.'
70
+ sleep 5
71
+ done
72
+ set -e
73
+ - name: Wait for PostgreSQL
74
+ if: ${{ matrix.docker-compose-file == 'docker-compose.ci.postgresql.yml' }}
75
+ run: |
76
+ set +e
77
+ count=0
78
+ until $(psql -h 127.0.0.1 -U postgres -p 5432 -l > /dev/null); do
79
+ if [[ "$count" == "25" ]]; then
80
+ exit 1
81
+ fi
82
+ (( count++ ))
83
+ printf '.'
84
+ sleep 5
85
+ done
86
+ set -e
87
+ - name: Start Kill Bill
88
+ # Sometimes it gets stuck (if Kill Bill starts when the DB isn't ready?)
89
+ timeout-minutes: 4
90
+ run: |
91
+ docker start it_killbill_1
92
+ count=0
93
+ until $(curl --connect-timeout 10 --max-time 30 --output /dev/null --silent --fail http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck); do
94
+ if [[ "$count" == "180" ]]; then
95
+ exit 64
96
+ fi
97
+ count=$(( count + 1 ))
98
+ sleep 1
99
+ done
100
+ curl --connect-timeout 10 --max-time 30 -v \
101
+ -X POST \
102
+ -u admin:password \
103
+ -H 'Content-Type: application/json' \
104
+ -H 'X-Killbill-CreatedBy: GitHub' \
105
+ -d '{"apiKey": "bob", "apiSecret": "lazar"}' \
106
+ "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/tenants"
107
+ - name: Run fast tests
108
+ env:
109
+ DB_ADAPTER: ${{ matrix.database-adapter }}
110
+ DB_USER: ${{ matrix.database-user }}
111
+ DB_PASSWORD: ${{ matrix.database-password }}
112
+ DB_PORT: ${{ matrix.database-port }}
113
+ run: |
114
+ # Some flakiness unfortunately
115
+ ./bin/retry bundle exec rake test:spec
116
+ - name: Run remote tests
117
+ env:
118
+ DB_ADAPTER: ${{ matrix.database-adapter }}
119
+ DB_USER: ${{ matrix.database-user }}
120
+ DB_PASSWORD: ${{ matrix.database-password }}
121
+ DB_PORT: ${{ matrix.database-port }}
122
+ run: |
123
+ # Some flakiness unfortunately
124
+ ./bin/retry bundle exec rake test:remote:spec
125
+ - name: Debugging after failure
126
+ if: failure()
127
+ run: |
128
+ echo "[DEBUG] killbill healthcheck"
129
+ curl --connect-timeout 10 --max-time 30 -v http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck || true
130
+ echo "[DEBUG] hostname"
131
+ hostname
132
+ echo "[DEBUG] netstat -tulpn"
133
+ sudo netstat -tulpn
134
+ echo "[DEBUG] docker network ls"
135
+ docker network ls
136
+ echo "[DEBUG] docker ps -a"
137
+ docker ps -a
138
+ echo "[DEBUG] killbill env"
139
+ docker exec it_killbill_1 env || true
140
+ echo "[DEBUG] db env"
141
+ docker exec it_db_1 env || true
142
+ echo "[DEBUG] killbill logs"
143
+ docker logs -t --details it_killbill_1 || true
144
+ echo "[DEBUG] db logs"
145
+ docker logs -t --details it_db_1 || true
@@ -0,0 +1,46 @@
1
+ name: release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ target_version:
7
+ description: 'Target version: next [major|minor|patch|pre|release] or a given version number [x.x.x]'
8
+ required: true
9
+ default: 'patch'
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v2
17
+ - name: Setup git user
18
+ env:
19
+ BUILD_USER: ${{ secrets.BUILD_USER }}
20
+ BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
21
+ run: |
22
+ git config --global user.email "contact@killbill.io"
23
+ git config --global user.name "Kill Bill core team"
24
+ git config --global url."https://${BUILD_USER}:${BUILD_TOKEN}@github.com/".insteadOf "git@github.com:"
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: '2.4.2'
28
+ - name: Download Ruby dependencies
29
+ run: |
30
+ bundle install
31
+ - name: Tag repository
32
+ run: |
33
+ bundle exec gem bump -c -p -t -v ${{ github.event.inputs.target_version }}
34
+ - name: Release Gem
35
+ env:
36
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
37
+ run: |
38
+ mkdir -p ~/.gem
39
+ cat << EOF > ~/.gem/credentials
40
+ ---
41
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
42
+ EOF
43
+ chmod 0600 ~/.gem/credentials
44
+ bundle install
45
+ bundle exec gem release
46
+ rm -f ~/.gem/credentials
data/README.md CHANGED
@@ -11,7 +11,7 @@ Kill Bill compatibility
11
11
  | 0.x.y | 0.16.z |
12
12
  | 1.x.y | 0.18.z |
13
13
  | 2.x.y | 0.20.z |
14
- | 3.x.y | 0.21.z |
14
+ | 3.x.y | 0.22.z |
15
15
 
16
16
  Installation
17
17
  ------------
@@ -28,6 +28,37 @@ Alternatively, add the dependency in your Gemfile:
28
28
  gem 'killbill-client', '~> 1.0'
29
29
  ```
30
30
 
31
+ Authentication
32
+ --------------
33
+
34
+ A username and password can be set directly in the `options` hash (accepted by each API method):
35
+ ```ruby
36
+ options = {
37
+ :username => 'admin',
38
+ :password => 'password'
39
+ }
40
+ ```
41
+ These credentials are validated by Kill Bill either directly (users managed by Kill Bill) or via a third-party (LDAP, Okta, Auth0, etc.).
42
+
43
+ Alternatively, a bearer token can be passed as such:
44
+ ```ruby
45
+ options = {
46
+ :bearer => 'token'
47
+ }
48
+ ```
49
+ The security token would be validated by Kill bill via a third-party (e.g. Auth0).
50
+
51
+ By default, Kill Bill won't maintain sessions, except when calling the API `/1.0/kb/security/permissions` (`JSESSIONID`, present in the `Set-Cookie` response header).
52
+ This session id can be passed instead:
53
+ ```ruby
54
+ options = {
55
+ :session_id => 'JSESSIONID'
56
+ }
57
+ ```
58
+ Using this session mechanism is recommend for user interfaces or to minimize the runtime dependency with a third-party provider.
59
+
60
+ Note: if a timed out session is re-used (`last_access_time` older than 60 minutes by default), a `HTTP/1.1 401 Unauthorized` is returned with `Set-Cookie: JSESSIONID=deleteMe`, and the session is deleted from the database (and cache) on the server side.
61
+
31
62
  Examples
32
63
  --------
33
64