ka-ching-client 0.1.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: 2e16582171eb9b2444e49108b7aa5e5510f8d1b161083c246e4f0ef3d7b4403e
4
- data.tar.gz: a35cf46ed2c2cd17ca08c18807b3e2b1467b426e33cfddd4fa60a23a4d488aa5
3
+ metadata.gz: bac54083b8081e1e66eef09715fd734594f926efb9632d559c16939183aa9360
4
+ data.tar.gz: ccc12ba3b2bd625e9305ebac3a329d6038cb975615d79c7f32775344b9d19367
5
5
  SHA512:
6
- metadata.gz: 7ccca54c865747187c51e8b89a11b78fbb91296e3a60a3ded4a17df30b443e0d055963f782538f9c7e1e871135ecfc94eca94ffc8b7ea0868b05ccf6939a3d80
7
- data.tar.gz: c7effcd12a68700eeec10a980983aa2e1bda4ee86bb7b0f37902429e8cb6e62a62411b605213077029c1d04f347e97325d4d75323f768c1841f8f15501321ea9
6
+ metadata.gz: 62ec0f7c7f0724ab6b124f88c309d88d1394450ac81c1c797a390ed2cc3cdb4784a2c44993de9dbb3978dfe67c3573699c8f6344da064039e0171045fec41e14
7
+ data.tar.gz: e97d23adab7dc7e92a5a4d1947f5cf2467c5d459f47977e30c46ed692c908759401b7c8e90604d5974fb44f54086ba44d3568e513c093cbdef48101b3506b4ff
data/CHANGELOG.md CHANGED
@@ -5,4 +5,17 @@ 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
- ## [Unreleased] - yyyy-mm-dd
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
+
12
+ ## [0.2.0] - 2023-06-20
13
+
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).
15
+ - [#5](https://github.com/simonneutert/ka-ching-client/pull/5) adjusts endpoints for lockings to backend API - [@simonneutert](https://github.com/simonneutert).
16
+ - [#2](https://github.com/simonneutert/ka-ching-backend/pull/2) changes attribute/column from `realized` to `realized_at` [@simonneutert](https://github.com/simonneutert).
17
+ - [#1](https://github.com/simonneutert/ka-ching-client/pull/1) fixes entry in Readme after gem release - [simonneutert](https://github.com/simonneutert).
18
+
19
+ ## [0.1.0] - 2023-06-12
20
+
21
+ Initial release.
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
- gem 'minitest', '~> 5.0'
8
+ gem 'minitest', '~> 5.18'
9
9
  gem 'minitest-vcr', '~> 1.4'
10
10
  gem 'pry', '~> 0.14.2'
11
11
  gem 'rake', '~> 13.0'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ka-ching-client (0.1.0)
4
+ ka-ching-client (0.2.1)
5
5
  faraday (~> 2.7.4)
6
- httpx (>= 0.22.4, < 0.24.0)
6
+ httpx (>= 0.22.4, < 0.25.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -24,7 +24,7 @@ GEM
24
24
  faraday-net_http (3.0.2)
25
25
  hashdiff (1.0.1)
26
26
  http-2-next (0.5.1)
27
- httpx (0.23.4)
27
+ httpx (0.24.0)
28
28
  http-2-next (>= 0.4.1)
29
29
  jaro_winkler (1.5.6)
30
30
  json (2.6.3)
@@ -33,13 +33,17 @@ GEM
33
33
  kramdown-parser-gfm (1.1.0)
34
34
  kramdown (~> 2.0)
35
35
  method_source (1.0.0)
36
+ mini_portile2 (2.8.2)
36
37
  minispec-metadata (2.0.0)
37
38
  minitest
38
- minitest (5.18.0)
39
+ minitest (5.18.1)
39
40
  minitest-vcr (1.4.0)
40
41
  minispec-metadata (~> 2.0)
41
42
  minitest (>= 4.7.5)
42
43
  vcr (>= 2.9)
44
+ nokogiri (1.15.2)
45
+ mini_portile2 (~> 2.8.2)
46
+ racc (~> 1.4)
43
47
  nokogiri (1.15.2-arm64-darwin)
44
48
  racc (~> 1.4)
45
49
  nokogiri (1.15.2-x86_64-linux)
@@ -107,11 +111,12 @@ GEM
107
111
 
108
112
  PLATFORMS
109
113
  arm64-darwin-22
114
+ ruby
110
115
  x86_64-linux
111
116
 
112
117
  DEPENDENCIES
113
118
  ka-ching-client!
114
- minitest (~> 5.0)
119
+ minitest (~> 5.18)
115
120
  minitest-vcr (~> 1.4)
116
121
  pry (~> 0.14.2)
117
122
  rake (~> 13.0)
data/README.md CHANGED
@@ -20,28 +20,27 @@ KaChing::Client is a Ruby API client for the [KaChing Backend project / simonneu
20
20
  - [unlock!](#unlock)
21
21
  - [all paginated](#all-paginated)
22
22
  - [of\_year](#of_year)
23
- - [of\_year\_month](#of_year_month)
24
- - [of\_year\_month\_day](#of_year_month_day)
23
+ - [active](#active)
24
+ - [inactive](#inactive)
25
25
  - [AuditLogs](#auditlogs)
26
26
  - [of\_year](#of_year-1)
27
- - [of\_year\_month](#of_year_month-1)
28
- - [of\_year\_month\_day](#of_year_month_day-1)
27
+ - [of\_year\_month](#of_year_month)
28
+ - [of\_year\_month\_day](#of_year_month_day)
29
29
  - [Tenants](#tenants)
30
30
  - [all](#all)
31
- - [active](#active)
32
- - [inactive](#inactive)
31
+ - [active](#active-1)
32
+ - [inactive](#inactive-1)
33
33
  - [Admin](#admin)
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)
40
41
 
41
42
  ## Installation
42
43
 
43
- TODO: Replace `ka-ching-client` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
44
-
45
44
  Install the gem and add to the application's Gemfile by executing:
46
45
 
47
46
  $ bundle add ka-ching-client
@@ -189,7 +188,7 @@ Get all lockings for a tenant paginated.
189
188
  res = client.v1.lockings.all(
190
189
  tenant_account_id: 'testuser_1',
191
190
  page: 1,
192
- per_page: 10
191
+ per_page: 10,
193
192
  )
194
193
  ```
195
194
 
@@ -201,28 +200,25 @@ Get lockings for a tenant by year.
201
200
  res = client.v1.lockings.of_year(tenant_account_id: 'testuser_1', year: 2019)
202
201
  ```
203
202
 
204
- #### of_year_month
203
+ #### active
205
204
 
206
- Get lockings for a tenant by year and month.
205
+ Get active lockings for a tenant for a year.
207
206
 
208
207
  ```ruby
209
- res = client.v1.lockings.of_year(
208
+ res = client.v1.lockings.active(
210
209
  tenant_account_id: 'testuser_1',
211
210
  year: 2019,
212
- month: 11
213
211
  )
214
212
  ```
215
213
 
216
- #### of_year_month_day
214
+ #### inactive
217
215
 
218
- Get lockings for a tenant by year, month and day.
216
+ Get inactive lockings for a tenant for a year.
219
217
 
220
218
  ```ruby
221
- res = client.v1.lockings.of_year(
219
+ res = client.v1.lockings.inactive(
222
220
  tenant_account_id: 'testuser_1',
223
221
  year: 2019,
224
- month: 11,
225
- day: 21
226
222
  )
227
223
  ```
228
224
 
@@ -272,7 +268,7 @@ All tenants related endpoints.
272
268
  Get all tenants paginated.
273
269
 
274
270
  ```ruby
275
- res = client.v1.tenants.all(page: 1)
271
+ res = client.v1.tenants.all(page: 1, per_page: 1000)
276
272
  ```
277
273
 
278
274
  #### active
@@ -280,7 +276,7 @@ res = client.v1.tenants.all(page: 1)
280
276
  Get all active tenants paginated.
281
277
 
282
278
  ```ruby
283
- res = client.v1.tenants.active(page: 1)
279
+ res = client.v1.tenants.active(page: 1, per_page: 1000)
284
280
  ```
285
281
 
286
282
  #### inactive
@@ -288,7 +284,7 @@ res = client.v1.tenants.active(page: 1)
288
284
  Get all inactive tenants paginated.
289
285
 
290
286
  ```ruby
291
- res = client.v1.tenants.inactive(page: 1)
287
+ res = client.v1.tenants.inactive(page: 1, per_page: 1000)
292
288
  ```
293
289
 
294
290
  ### Admin
@@ -319,6 +315,14 @@ Drop/Delete a tenant database.
319
315
  res = client.v1.admin.drop!(tenant_account_id: 'testuser_1')
320
316
  ```
321
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
+
322
326
  ## Development
323
327
 
324
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.
data/UPGRADING.md ADDED
@@ -0,0 +1,8 @@
1
+ # Upgrading ka-ching-client
2
+
3
+ ## 0.1.0 to 0.2.0
4
+
5
+ ### Changes
6
+
7
+ * [#5](https://github.com/simonneutert/ka-ching-client/pull/5) Endpoints for lockings do not support `of_year_month` and `of_year_month_day` anymore. Therefor `active` and `inactive` were added to `Lockings` endpoints.
8
+ - [#1](https://github.com/simonneutert/ka-ching-client/pull/1) attribute/column was `realized` and is from now on `realized_at`.
@@ -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
  #
@@ -94,33 +94,25 @@ module KaChing
94
94
  JSON.parse(res.body)
95
95
  end
96
96
 
97
- #
98
- # Get all lockings for a given year in month
99
- #
100
- # @yield [Faraday::Response] The response from the server
101
- # @return [Hash]
102
- #
103
- def of_year_month(tenant_account_id:, year:, month:, page: 1, per_page: 100)
104
- res = get(build_url(tenant_account_id: tenant_account_id),
105
- { year: year, month: month, page: page, per_page: per_page }) do |req|
97
+ def active(tenant_account_id:, year: nil, page: 1, per_page: 100)
98
+ params = { page: page, per_page: per_page }
99
+ body_params = { active: 'true' }
100
+ body_params.merge!({ year: year }) if year
101
+ res = get(build_url(tenant_account_id: tenant_account_id), params) do |req|
106
102
  req.headers['Content-Type'] = 'application/json'
107
- req.body = { year: year, month: month }.to_json
103
+ req.body = body_params.to_json
108
104
  end
109
105
  yield res if block_given?
110
106
  JSON.parse(res.body)
111
107
  end
112
108
 
113
- #
114
- # Get all lockings for a given year in month at day
115
- #
116
- # @yield [Faraday::Response] The response from the server
117
- # @return [Hash]
118
- #
119
- def of_year_month_day(tenant_account_id:, year:, month:, day:)
120
- res = get(build_url(tenant_account_id: tenant_account_id).to_s,
121
- { year: year, month: month, day: day, page: page, per_page: per_page }) do |req|
109
+ def inactive(tenant_account_id:, year: nil, page: 1, per_page: 100)
110
+ params = { page: page, per_page: per_page }
111
+ body_params = { inactive: 'true' }
112
+ body_params.merge!({ year: year }) if year
113
+ res = get(build_url(tenant_account_id: tenant_account_id), params) do |req|
122
114
  req.headers['Content-Type'] = 'application/json'
123
- req.body = { year: year, month: month, day: day }.to_json
115
+ req.body = body_params.to_json
124
116
  end
125
117
  yield res if block_given?
126
118
  JSON.parse(res.body)
@@ -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.1.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.1.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-12 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
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.22.4
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 0.24.0
36
+ version: 0.25.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.22.4
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.24.0
46
+ version: 0.25.0
47
47
  description: This gem is a client for the ka-ching API.
48
48
  email:
49
49
  - simonneutert@users.noreply.github.com
@@ -61,6 +61,7 @@ files:
61
61
  - LICENSE.txt
62
62
  - README.md
63
63
  - Rakefile
64
+ - UPGRADING.md
64
65
  - lib/ka-ching-client.rb
65
66
  - lib/ka_ching/api_client.rb
66
67
  - lib/ka_ching/api_v1/admin.rb
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  - !ruby/object:Gem::Version
95
96
  version: '0'
96
97
  requirements: []
97
- rubygems_version: 3.4.13
98
+ rubygems_version: 3.4.14
98
99
  signing_key:
99
100
  specification_version: 4
100
101
  summary: This gem is a client for the ka-ching API.