bunny_app 2.4.0 → 2.5.0

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
  SHA256:
3
- metadata.gz: a804e6c2ed27d42bce0095ca83a626ea784344eb6a7fa0533ebedaa29c0e83f6
4
- data.tar.gz: 738ea16a8669e5dd954d39cf51ff9cad4b3f16ee8776b13bc0519ca35f901582
3
+ metadata.gz: 00eca4966ed34106d628843766d2f00f2e8a53b7611154ade889825d0add544c
4
+ data.tar.gz: 6994edecbd4d80b5b0e6dc53e79603629ca7ff85b1cf799f9bb9bab310ba52b1
5
5
  SHA512:
6
- metadata.gz: a9f8de180c86a45db4ea12ca23cefc957e2be83b464af1c6aa7e80c32bb5a18b7a1071e9a496c7270757cd7c6c1c5293ae80497446f93935d1d14d2bfeebeeb7
7
- data.tar.gz: 9d70f3ec0074f403c6dae3790818fce2484cdd29cf775dea7d057de13adccddbe7947242b38307872c1766ab673c6e476775bee1472f68a0e949be836157b745
6
+ metadata.gz: e2f422c3846e990cd2a35bc0b0b7ace22e099228cf54cca3641a3dc8915f3aec1a0681e31a1ff0c2db579e27b422fbffad0305d48eb25373488e024e27284c5d
7
+ data.tar.gz: 43a366d65b9f131444e08b7cc1caa9ec6c83a0feb8803e16560d2450d64fbbe406db89030d5781b69c3e602d5ea9b947267b2f4d62d24c59ab3255cc77be452b
data/README.md CHANGED
@@ -169,14 +169,37 @@ tenant = BunnyApp::Tenant.create(
169
169
  )
170
170
  ```
171
171
 
172
- Returns a hash with `id`, `code`, `name`, and `platform`.
172
+ Returns a hash with `id`, `code`, `name`, `subdomain`, `lastLogin`, and `platform`.
173
+
174
+ ### Update a tenant
175
+
176
+ Either `id` or `code` must be provided to identify the tenant. If only `code` is given, a lookup is performed first to resolve the ID.
177
+
178
+ ```ruby
179
+ # Identify by id
180
+ tenant = BunnyApp::Tenant.update(
181
+ id: '456123',
182
+ name: 'Acme Corp',
183
+ subdomain: 'acme',
184
+ last_login: '2024-06-01T12:00:00Z'
185
+ )
186
+
187
+ # Identify by code
188
+ tenant = BunnyApp::Tenant.update(
189
+ code: 'acme-123',
190
+ name: 'Acme Corp',
191
+ subdomain: 'acme'
192
+ )
193
+ ```
194
+
195
+ Only the fields you provide will be sent. Returns a hash with `id`, `code`, `name`, `subdomain`, `lastLogin`, and `platform`.
173
196
 
174
197
  ### Find a tenant by code
175
198
 
176
199
  ```ruby
177
200
  tenant = BunnyApp::Tenant.find_by(code: 'acme-123')
178
201
  # => { "id" => "1", "code" => "acme-123", "name" => "Acme Corp",
179
- # "subdomain" => "acme", "account" => { "id" => "456", ... } }
202
+ # "subdomain" => "acme", "lastLogin" => "...", "account" => { "id" => "456", ... } }
180
203
  ```
181
204
 
182
205
  Returns `nil` if no tenant is found.
@@ -7,6 +7,8 @@ module BunnyApp
7
7
  code
8
8
  id
9
9
  name
10
+ subdomain
11
+ lastLogin
10
12
  platform {
11
13
  id
12
14
  name
@@ -25,6 +27,7 @@ module BunnyApp
25
27
  code
26
28
  name
27
29
  subdomain
30
+ lastLogin
28
31
  account {
29
32
  id
30
33
  name
@@ -34,6 +37,26 @@ module BunnyApp
34
37
  }
35
38
  GRAPHQL
36
39
 
40
+ @tenant_update_mutation = <<-GRAPHQL
41
+ mutation tenantUpdate ($id: ID, $code: String, $attributes: TenantAttributes!) {
42
+ tenantUpdate (id: $id, code: $code, attributes: $attributes) {
43
+ errors
44
+ tenant {
45
+ code
46
+ id
47
+ name
48
+ subdomain
49
+ lastLogin
50
+ platform {
51
+ id
52
+ name
53
+ code
54
+ }
55
+ }
56
+ }
57
+ }
58
+ GRAPHQL
59
+
37
60
  def self.create(name:, code:, account_id:, platform_code: 'main')
38
61
  variables = {
39
62
  attributes: {
@@ -50,10 +73,26 @@ module BunnyApp
50
73
  res['data']['tenantCreate']['tenant']
51
74
  end
52
75
 
76
+ def self.update(id: nil, code: nil, **attrs)
77
+ raise ArgumentError, 'id or code is required' unless id || code
78
+
79
+ attributes = {
80
+ name: attrs[:name],
81
+ code: attrs[:code],
82
+ subdomain: attrs[:subdomain],
83
+ lastLogin: attrs[:last_login]
84
+ }.compact
85
+
86
+ variables = { id:, code:, attributes: }
87
+
88
+ res = Client.new.query(@tenant_update_mutation, variables)
89
+ raise ResponseError, res['data']['tenantUpdate']['errors'].join(',') if res['data']['tenantUpdate']['errors']
90
+
91
+ res['data']['tenantUpdate']['tenant']
92
+ end
93
+
53
94
  def self.find_by(code:)
54
- variables = {
55
- code:
56
- }
95
+ variables = { code: }
57
96
 
58
97
  res = Client.new.query(@tenant_query, variables)
59
98
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunnyApp
4
- VERSION = '2.4.0'
4
+ VERSION = '2.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bunny
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-04-13 00:00:00.000000000 Z
12
+ date: 2026-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty