bunny_app 2.4.0 → 2.6.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: f476e52c3d2d6d610cdafa7f6ccb102c82b3c11206898ef4eaa725b8a751d182
4
+ data.tar.gz: f918f29875935263188eac342da3454d2aa0256f2edfebd18355b073b30a751a
5
5
  SHA512:
6
- metadata.gz: a9f8de180c86a45db4ea12ca23cefc957e2be83b464af1c6aa7e80c32bb5a18b7a1071e9a496c7270757cd7c6c1c5293ae80497446f93935d1d14d2bfeebeeb7
7
- data.tar.gz: 9d70f3ec0074f403c6dae3790818fce2484cdd29cf775dea7d057de13adccddbe7947242b38307872c1766ab673c6e476775bee1472f68a0e949be836157b745
6
+ metadata.gz: 7fd7ebd366bd6b22090a5d92f27f369d7c738b03527b438170d4cf92e2ccc440770e43f3f723103639a63be9de983d7f2ffaa61f0aef79d369b7251a414303fc
7
+ data.tar.gz: 80b25b11940980d9fdc48f930b9d08aeaa7ffd3932d621cd0d614b5f9f85208c7017193cbee4233e49ba7954a97600d88fb897fd1797fc24682ff4524bfa56fb
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,31 @@ 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
+ # When id is the lookup key, code is treated as an attribute to update.
80
+ # When only code is provided, it is the lookup key.
81
+ lookup_code = id ? nil : code
82
+ update_code = id ? code : attrs[:code]
83
+
84
+ attributes = {
85
+ name: attrs[:name],
86
+ code: update_code,
87
+ subdomain: attrs[:subdomain],
88
+ lastLogin: attrs[:last_login]
89
+ }.compact
90
+
91
+ variables = { id:, code: lookup_code, attributes: }
92
+
93
+ res = Client.new.query(@tenant_update_mutation, variables)
94
+ raise ResponseError, res['data']['tenantUpdate']['errors'].join(',') if res['data']['tenantUpdate']['errors']
95
+
96
+ res['data']['tenantUpdate']['tenant']
97
+ end
98
+
53
99
  def self.find_by(code:)
54
- variables = {
55
- code:
56
- }
100
+ variables = { code: }
57
101
 
58
102
  res = Client.new.query(@tenant_query, variables)
59
103
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunnyApp
4
- VERSION = '2.4.0'
4
+ VERSION = '2.6.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.6.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