ka-ching-client 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 6d21504fd6fba444a7181caffae081ca69ba4474d6560f765054a117a7ae37cf
4
- data.tar.gz: 469d2e8cc8a200c561707ce1b9ba4f4a0b40ed4f7fd30b1267444d6c5e40d77e
3
+ metadata.gz: '096acd110efe41626adbb730494ba86247e0c20614b294ba1bfa4d4dd7d420d9'
4
+ data.tar.gz: ea47b6fcb5d16b2a42a0a198c4c397eb0ebabc05f6d9755bc3a2fa31793aa982
5
5
  SHA512:
6
- metadata.gz: c6936213efd58b765f085f3f8ed663c4b6b03eff0d2d1001a9d7a07fe5ff868be6e5aaa01a74dd7d9f567d7fc4e231f3d8f280bbf7b2393f502db561345afe2b
7
- data.tar.gz: b69b366c3439ec9d5c8d0144a7bfb78a4404495a74f03bfd6f0167a906e14ac71efd1dedbafb9757e34d456c467e0d1f9a3b143667b213f372bfd1d4538c73a1
6
+ metadata.gz: 19d9b84a3e2a5c4872fe9fe0ed2746140d9da84afa925f1ef7554d2d048bd087d1032c272030269c01e8d742dfa953597561f503d0d7e50ed0e99ecede67e311
7
+ data.tar.gz: cb4701e66c2a1e922379a4fec71ec935982d0021dcdb7601b61bec19bbd1ad3217b55f024a01cf4bdd5028d64e9d341b6a705b57dc9a1be9c700d8155fc96489
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0] - 2023-06-27
9
+
10
+ Matches ka-ching-backend version bump to v0.3.0.
11
+
12
+ ## [0.2.1] - 2023-06-24
13
+
14
+ - [#8](https://github.com/simonneutert/ka-ching-client/pull/8) adds ability to reset the tenant database `admin#reset!` - [@simonneutert](https://github.com/simonneutert).
15
+
8
16
  ## [0.2.0] - 2023-06-20
9
17
 
10
18
  - [#6](https://github.com/simonneutert/ka-ching-client/pull/6) tests endpoints for lockings to backend API `active`/`inactive` - [@simonneutert](https://github.com/simonneutert).
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ group :development, :test do
9
9
  gem 'minitest-vcr', '~> 1.4'
10
10
  gem 'pry', '~> 0.14.2'
11
11
  gem 'rake', '~> 13.0'
12
- gem 'rubocop', '~> 1.52'
12
+ gem 'rubocop', '~> 1.53'
13
13
  gem 'rubocop-minitest', '~> 0.31.0'
14
14
  gem 'rubocop-performance', '~> 1.18'
15
15
  gem 'solargraph', '~> 0.49.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ka-ching-client (0.2.0)
4
+ ka-ching-client (0.3.0)
5
5
  faraday (~> 2.7.4)
6
6
  httpx (>= 0.22.4, < 0.25.0)
7
7
 
@@ -18,7 +18,7 @@ GEM
18
18
  rexml
19
19
  diff-lcs (1.5.0)
20
20
  e2mmap (0.1.0)
21
- faraday (2.7.6)
21
+ faraday (2.7.7)
22
22
  faraday-net_http (>= 2.0, < 3.1)
23
23
  ruby2_keywords (>= 0.0.4)
24
24
  faraday-net_http (3.0.2)
@@ -32,6 +32,7 @@ GEM
32
32
  rexml
33
33
  kramdown-parser-gfm (1.1.0)
34
34
  kramdown (~> 2.0)
35
+ language_server-protocol (3.17.0.3)
35
36
  method_source (1.0.0)
36
37
  mini_portile2 (2.8.2)
37
38
  minispec-metadata (2.0.0)
@@ -56,7 +57,7 @@ GEM
56
57
  coderay (~> 1.1)
57
58
  method_source (~> 1.0)
58
59
  public_suffix (5.0.1)
59
- racc (1.7.0)
60
+ racc (1.7.1)
60
61
  rainbow (3.1.1)
61
62
  rake (13.0.6)
62
63
  rbs (2.8.4)
@@ -64,8 +65,9 @@ GEM
64
65
  reverse_markdown (2.1.1)
65
66
  nokogiri
66
67
  rexml (3.2.5)
67
- rubocop (1.52.1)
68
+ rubocop (1.53.1)
68
69
  json (~> 2.3)
70
+ language_server-protocol (>= 3.17.0)
69
71
  parallel (~> 1.10)
70
72
  parser (>= 3.2.2.3)
71
73
  rainbow (>= 2.2.2, < 4.0)
@@ -120,7 +122,7 @@ DEPENDENCIES
120
122
  minitest-vcr (~> 1.4)
121
123
  pry (~> 0.14.2)
122
124
  rake (~> 13.0)
123
- rubocop (~> 1.52)
125
+ rubocop (~> 1.53)
124
126
  rubocop-minitest (~> 0.31.0)
125
127
  rubocop-performance (~> 1.18)
126
128
  solargraph (~> 0.49.0)
data/README.md CHANGED
@@ -34,6 +34,7 @@ KaChing::Client is a Ruby API client for the [KaChing Backend project / simonneu
34
34
  - [details](#details)
35
35
  - [create!](#create)
36
36
  - [drop!](#drop-1)
37
+ - [reset!](#reset)
37
38
  - [Development](#development)
38
39
  - [Contributing](#contributing)
39
40
  - [License](#license)
@@ -267,7 +268,7 @@ All tenants related endpoints.
267
268
  Get all tenants paginated.
268
269
 
269
270
  ```ruby
270
- res = client.v1.tenants.all(page: 1)
271
+ res = client.v1.tenants.all(page: 1, per_page: 1000)
271
272
  ```
272
273
 
273
274
  #### active
@@ -275,7 +276,7 @@ res = client.v1.tenants.all(page: 1)
275
276
  Get all active tenants paginated.
276
277
 
277
278
  ```ruby
278
- res = client.v1.tenants.active(page: 1)
279
+ res = client.v1.tenants.active(page: 1, per_page: 1000)
279
280
  ```
280
281
 
281
282
  #### inactive
@@ -283,7 +284,7 @@ res = client.v1.tenants.active(page: 1)
283
284
  Get all inactive tenants paginated.
284
285
 
285
286
  ```ruby
286
- res = client.v1.tenants.inactive(page: 1)
287
+ res = client.v1.tenants.inactive(page: 1, per_page: 1000)
287
288
  ```
288
289
 
289
290
  ### Admin
@@ -314,6 +315,14 @@ Drop/Delete a tenant database.
314
315
  res = client.v1.admin.drop!(tenant_account_id: 'testuser_1')
315
316
  ```
316
317
 
318
+ #### reset!
319
+
320
+ Reset a tenant database.
321
+
322
+ ```ruby
323
+ res = client.v1.admin.reset!(tenant_account_id: 'testuser_1')
324
+ ```
325
+
317
326
  ## Development
318
327
 
319
328
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -50,6 +50,22 @@ module KaChing
50
50
  JSON.parse(res.body)
51
51
  end
52
52
 
53
+ #
54
+ # resets a tenant database
55
+ #
56
+ # @param [String] tenant_account_id without its database namespace
57
+ #
58
+ # @return [Hash] containing the details of the response
59
+ #
60
+ def reset!(tenant_account_id:)
61
+ reset_url = "#{build_url(tenant_account_id: tenant_account_id)}/reset"
62
+ res = post(reset_url) do |req|
63
+ req.headers['Content-Type'] = 'application/json'
64
+ end
65
+ yield res if block_given?
66
+ JSON.parse(res.body)
67
+ end
68
+
53
69
  #
54
70
  # drops a tenant database
55
71
  #
@@ -22,10 +22,11 @@ module KaChing
22
22
  #
23
23
  # @return [Array<Hash>] An array of tenant detail hashes
24
24
  #
25
- def all(page: 1)
25
+ def all(page: 1, per_page: 1000)
26
26
  all_url = build_url
27
- res = get("#{all_url}/all/#{page}") do |req|
27
+ res = get("#{all_url}/all") do |req|
28
28
  req.headers['Content-Type'] = 'application/json'
29
+ req.body = { page: page, per_page: per_page }.to_json
29
30
  end
30
31
  yield res if block_given?
31
32
  JSON.parse(res.body)
@@ -40,8 +41,9 @@ module KaChing
40
41
  #
41
42
  def active(page: 1)
42
43
  active_url = build_url
43
- res = get("#{active_url}/active/#{page}}") do |req|
44
+ res = get("#{active_url}/active") do |req|
44
45
  req.headers['Content-Type'] = 'application/json'
46
+ req.body = { page: page, per_page: per_page }.to_json
45
47
  end
46
48
  yield res if block_given?
47
49
  JSON.parse(res.body)
@@ -56,8 +58,9 @@ module KaChing
56
58
  #
57
59
  def inactive(page: 1)
58
60
  inactive_url = build_url
59
- res = get("#{inactive_url}/all/#{page}}") do |req|
61
+ res = get("#{inactive_url}/inactive}") do |req|
60
62
  req.headers['Content-Type'] = 'application/json'
63
+ req.body = { page: page, per_page: per_page }.to_json
61
64
  end
62
65
  yield res if block_given?
63
66
  JSON.parse(res.body)
@@ -65,8 +68,12 @@ module KaChing
65
68
 
66
69
  private
67
70
 
68
- def build_url
69
- "#{@api_url}/tenants"
71
+ def build_url(tenant_account_id: nil)
72
+ if tenant_account_id
73
+ "#{@api_url}/tenants/#{tenant_account_id}"
74
+ else
75
+ "#{@api_url}/tenants"
76
+ end
70
77
  end
71
78
  end
72
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KaChing
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ka-ching-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Neutert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-20 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday