ka-ching-client 0.2.0 → 0.2.1

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: bac54083b8081e1e66eef09715fd734594f926efb9632d559c16939183aa9360
4
+ data.tar.gz: ccc12ba3b2bd625e9305ebac3a329d6038cb975615d79c7f32775344b9d19367
5
5
  SHA512:
6
- metadata.gz: c6936213efd58b765f085f3f8ed663c4b6b03eff0d2d1001a9d7a07fe5ff868be6e5aaa01a74dd7d9f567d7fc4e231f3d8f280bbf7b2393f502db561345afe2b
7
- data.tar.gz: b69b366c3439ec9d5c8d0144a7bfb78a4404495a74f03bfd6f0167a906e14ac71efd1dedbafb9757e34d456c467e0d1f9a3b143667b213f372bfd1d4538c73a1
6
+ metadata.gz: 62ec0f7c7f0724ab6b124f88c309d88d1394450ac81c1c797a390ed2cc3cdb4784a2c44993de9dbb3978dfe67c3573699c8f6344da064039e0171045fec41e14
7
+ data.tar.gz: e97d23adab7dc7e92a5a4d1947f5cf2467c5d459f47977e30c46ed692c908759401b7c8e90604d5974fb44f54086ba44d3568e513c093cbdef48101b3506b4ff
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ 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.2.1] - 2023-06-24
9
+
10
+ - [#8](https://github.com/simonneutert/ka-ching-client/pull/8) adds ability to reset the tenant database `admin#reset!` - [@simonneutert](https://github.com/simonneutert).
11
+
8
12
  ## [0.2.0] - 2023-06-20
9
13
 
10
14
  - [#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.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.2.1)
5
5
  faraday (~> 2.7.4)
6
6
  httpx (>= 0.22.4, < 0.25.0)
7
7
 
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.2.1'
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.2.1
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-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday