bunny_app 1.30.0 → 2.0.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 +4 -4
- data/README.md +2 -2
- data/lib/bunny_app/client.rb +7 -1
- data/lib/bunny_app/{usage.rb → feature_usage.rb} +4 -3
- data/lib/bunny_app/platform.rb +4 -3
- data/lib/bunny_app/portal_session.rb +2 -1
- data/lib/bunny_app/subscription.rb +20 -1
- data/lib/bunny_app/tenant.rb +40 -7
- data/lib/bunny_app/version.rb +1 -1
- data/lib/bunny_app.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef0fdf58b7fc7c4973466ba5c722802b73b2d94529087aa3dd1332290f2c044
|
4
|
+
data.tar.gz: 8903c12d6412863560b7f25b6be25c2580a0b01cc8f8d9451b121e810b93333c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95f160e2ed4c9b90a498310efd2dffc0909a825bb60ea3c8707c2bb2b7343b6e565561b046186c9874467c3cceaaef6795c696bbc8c969506aa18255ccd28d1
|
7
|
+
data.tar.gz: 8a4e13af567f9cfd02f99135ca9fdd72bbf0a1e9787137944b6f3c22aef529f4c9ac8a2d35bd5991c96c9284a0ff4150b5a60b018757f0f24c70847984bc8180
|
data/README.md
CHANGED
@@ -89,11 +89,11 @@ If you have usage based billing or just want to track feature usage then use thi
|
|
89
89
|
|
90
90
|
```ruby
|
91
91
|
# Usage is tracked as if it just happened
|
92
|
-
response = BunnyApp::
|
92
|
+
response = BunnyApp::FeatureUsage.create(
|
93
93
|
quantity: 5, feature_code: 'products', tenant_code: '2')
|
94
94
|
|
95
95
|
# Usage is tracked using the date supplied
|
96
|
-
response = BunnyApp::
|
96
|
+
response = BunnyApp::FeatureUsage.create(
|
97
97
|
quantity: 5, feature_code: 'products', tenant_code: '2', usage_at: '2022-03-10')
|
98
98
|
```
|
99
99
|
|
data/lib/bunny_app/client.rb
CHANGED
@@ -19,6 +19,8 @@ module BunnyApp
|
|
19
19
|
'Content-Type' => 'application/json',
|
20
20
|
'Authorization' => "Bearer #{BunnyApp.access_token}"
|
21
21
|
}
|
22
|
+
|
23
|
+
@headers['host'] = host_header unless host_header.nil?
|
22
24
|
end
|
23
25
|
|
24
26
|
def fetch_access_token
|
@@ -59,7 +61,7 @@ module BunnyApp
|
|
59
61
|
case res.code.to_s
|
60
62
|
when /2[0-9][0-9]/ # HTTP 2xx
|
61
63
|
response_body = JSON.parse(res.body)
|
62
|
-
raise ResponseError, response_body['errors'] if response_body['errors']
|
64
|
+
raise ResponseError, (response_body['errors'].map { |error| error['message'] }) if response_body['errors']
|
63
65
|
|
64
66
|
response_body
|
65
67
|
|
@@ -89,5 +91,9 @@ module BunnyApp
|
|
89
91
|
def verify_ssl
|
90
92
|
return true unless ENV['IGNORE_SSL']
|
91
93
|
end
|
94
|
+
|
95
|
+
def host_header
|
96
|
+
ENV.fetch('BUNNY_HOST_HEADER', nil)
|
97
|
+
end
|
92
98
|
end
|
93
99
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module BunnyApp
|
2
|
-
class
|
2
|
+
class FeatureUsage
|
3
3
|
@feature_usage_create_mutation = <<-'GRAPHQL'
|
4
4
|
mutation featureUsageCreate ($attributes: FeatureUsageAttributes!) {
|
5
5
|
featureUsageCreate (attributes: $attributes) {
|
@@ -23,7 +23,7 @@ module BunnyApp
|
|
23
23
|
}
|
24
24
|
GRAPHQL
|
25
25
|
|
26
|
-
def self.
|
26
|
+
def self.create(quantity:, feature_code:, tenant_code:, usage_at: nil)
|
27
27
|
variables = {
|
28
28
|
attributes: {
|
29
29
|
quantity:,
|
@@ -34,7 +34,8 @@ module BunnyApp
|
|
34
34
|
|
35
35
|
variables[:attributes][:usageAt] = usage_at unless usage_at.nil?
|
36
36
|
|
37
|
-
Client.new.query(@feature_usage_create_mutation, variables)
|
37
|
+
res = Client.new.query(@feature_usage_create_mutation, variables)
|
38
|
+
res['data']['featureUsageCreate']['featureUsage']
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
data/lib/bunny_app/platform.rb
CHANGED
@@ -16,12 +16,13 @@ module BunnyApp
|
|
16
16
|
def self.create(name:, code:)
|
17
17
|
variables = {
|
18
18
|
attributes: {
|
19
|
-
name
|
20
|
-
code:
|
19
|
+
name:,
|
20
|
+
code:
|
21
21
|
}
|
22
22
|
}
|
23
23
|
|
24
|
-
Client.new.query(@platform_create_mutation, variables)
|
24
|
+
res = Client.new.query(@platform_create_mutation, variables)
|
25
|
+
res['data']['platformCreate']['platform']
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -38,6 +38,14 @@ module BunnyApp
|
|
38
38
|
}
|
39
39
|
GRAPHQL
|
40
40
|
|
41
|
+
@subscription_cancel_mutation = <<-'GRAPHQL'
|
42
|
+
mutation subscriptionCancel ($ids: [ID!]!) {
|
43
|
+
subscriptionCancel (ids: $ids) {
|
44
|
+
errors
|
45
|
+
}
|
46
|
+
}
|
47
|
+
GRAPHQL
|
48
|
+
|
41
49
|
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
42
50
|
def self.create(price_list_code:, options: {})
|
43
51
|
variables = {
|
@@ -67,7 +75,18 @@ module BunnyApp
|
|
67
75
|
}
|
68
76
|
end
|
69
77
|
|
70
|
-
Client.new.query(@subscription_create_mutation, variables)
|
78
|
+
res = Client.new.query(@subscription_create_mutation, variables)
|
79
|
+
res['data']['subscriptionCreate']['subscription']
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.cancel(subscription_id:)
|
83
|
+
variables = {
|
84
|
+
ids: [subscription_id]
|
85
|
+
}
|
86
|
+
|
87
|
+
Client.new.query(@subscription_cancel_mutation, variables)
|
88
|
+
|
89
|
+
true
|
71
90
|
end
|
72
91
|
end
|
73
92
|
end
|
data/lib/bunny_app/tenant.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module BunnyApp
|
2
2
|
class Tenant
|
3
3
|
@tenant_create_mutation = <<-'GRAPHQL'
|
4
|
-
mutation tenantCreate ($attributes: TenantAttributes
|
5
|
-
tenantCreate (attributes: $attributes
|
4
|
+
mutation tenantCreate ($attributes: TenantAttributes!) {
|
5
|
+
tenantCreate (attributes: $attributes) {
|
6
6
|
tenant {
|
7
7
|
code
|
8
8
|
id
|
@@ -18,17 +18,50 @@ module BunnyApp
|
|
18
18
|
}
|
19
19
|
GRAPHQL
|
20
20
|
|
21
|
-
|
21
|
+
@tenant_query = <<-'GRAPHQL'
|
22
|
+
query tenant ($code: String!) {
|
23
|
+
tenant (code: $code) {
|
24
|
+
id
|
25
|
+
code
|
26
|
+
name
|
27
|
+
subdomain
|
28
|
+
account {
|
29
|
+
id
|
30
|
+
name
|
31
|
+
billingDay
|
32
|
+
}
|
33
|
+
latestProvisioningChange {
|
34
|
+
change
|
35
|
+
createdAt
|
36
|
+
features
|
37
|
+
id
|
38
|
+
updatedAt
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
GRAPHQL
|
43
|
+
|
44
|
+
def self.create(name:, code:, account_id:, platform_code: 'main')
|
22
45
|
variables = {
|
23
46
|
attributes: {
|
24
47
|
name:,
|
25
48
|
code:,
|
26
|
-
platformCode: platform_code
|
27
|
-
|
28
|
-
|
49
|
+
platformCode: platform_code,
|
50
|
+
accountId: account_id
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
res = Client.new.query(@tenant_create_mutation, variables)
|
55
|
+
res['data']['tenantCreate']['tenant']
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.find_by(code:)
|
59
|
+
variables = {
|
60
|
+
code:
|
29
61
|
}
|
30
62
|
|
31
|
-
Client.new.query(@
|
63
|
+
res = Client.new.query(@tenant_query, variables)
|
64
|
+
res['data']['tenant']
|
32
65
|
end
|
33
66
|
end
|
34
67
|
end
|
data/lib/bunny_app/version.rb
CHANGED
data/lib/bunny_app.rb
CHANGED
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:
|
4
|
+
version: 2.0.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: 2023-08-
|
12
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -139,11 +139,11 @@ files:
|
|
139
139
|
- lib/bunny_app.rb
|
140
140
|
- lib/bunny_app/client.rb
|
141
141
|
- lib/bunny_app/errors.rb
|
142
|
+
- lib/bunny_app/feature_usage.rb
|
142
143
|
- lib/bunny_app/platform.rb
|
143
144
|
- lib/bunny_app/portal_session.rb
|
144
145
|
- lib/bunny_app/subscription.rb
|
145
146
|
- lib/bunny_app/tenant.rb
|
146
|
-
- lib/bunny_app/usage.rb
|
147
147
|
- lib/bunny_app/version.rb
|
148
148
|
- lib/bunny_app/webhook.rb
|
149
149
|
- lib/generators/bunny_app/install_generator.rb
|