activitysmith 1.12.0 → 1.14.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 +117 -11
- data/generated/activitysmith_openapi/api/push_notifications_api.rb +80 -2
- data/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +34 -4
- data/generated/activitysmith_openapi/models/billing_blocked_error.rb +296 -0
- data/generated/activitysmith_openapi/models/billing_blocked_error_trial_period.rb +237 -0
- data/generated/activitysmith_openapi/models/live_activity_end_response.rb +64 -4
- data/generated/activitysmith_openapi/models/live_activity_start_response.rb +35 -4
- data/generated/activitysmith_openapi/models/live_activity_stream_delete_response.rb +53 -4
- data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +54 -4
- data/generated/activitysmith_openapi/models/live_activity_update_response.rb +76 -4
- data/generated/activitysmith_openapi/models/push_interruption_level.rb +41 -0
- data/generated/activitysmith_openapi/models/push_notification_replace_request.rb +434 -0
- data/generated/activitysmith_openapi/models/push_notification_replace_response.rb +298 -0
- data/generated/activitysmith_openapi/models/push_notification_request.rb +64 -1
- data/generated/activitysmith_openapi/models/push_notification_response.rb +66 -4
- data/generated/activitysmith_openapi/version.rb +1 -1
- data/generated/activitysmith_openapi.rb +5 -0
- data/generated/openapi-source.json +2 -2
- data/lib/activitysmith/notifications.rb +21 -3
- data/lib/activitysmith/push_interruption_level.rb +10 -0
- data/lib/activitysmith/version.rb +1 -1
- data/lib/activitysmith.rb +1 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2ee0516e542f1c17496efa764ce0c069b86d2252c477b9627844324bbbb5dbc
|
|
4
|
+
data.tar.gz: 5d819aaac4d797aa055dee752a93a30d22014470ed3b8da62dc16144554650be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40b1fc816fb5ec2ab730e145c005a53543477d24d519b06b4666b574b94e5948bf4b66c6dea72669cbd3386a4f4490faa1831873d4034754a17619139845e145
|
|
7
|
+
data.tar.gz: a9e93c08d13d6f33ac83aa6ad2b185af99d981a9e35b08e81bc3a4751434312f2a51b13f1d6582008ecb75ac036382805a06f91d5d1718073e07b45c603dba7a
|
data/README.md
CHANGED
|
@@ -40,6 +40,22 @@ activitysmith.notifications.send(
|
|
|
40
40
|
)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### Custom Push Notification Icons
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
Set `icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. With a custom icon, iOS may omit the subtitle from the notification.
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
activitysmith.notifications.send(
|
|
51
|
+
{
|
|
52
|
+
title: "MRR just crossed $10,000 🎉",
|
|
53
|
+
message: "Up 18% this month from 31 new subscriptions.",
|
|
54
|
+
icon: "https://cdn.activitysmith.com/integrations/icons/stripe.png"
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
43
59
|
### Rich Push Notifications with Media
|
|
44
60
|
|
|
45
61
|

|
|
@@ -136,28 +152,122 @@ activitysmith.notifications.send(
|
|
|
136
152
|
)
|
|
137
153
|
```
|
|
138
154
|
|
|
155
|
+
### Push Notification Interruption Levels
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
Use `interruption_level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default.
|
|
160
|
+
|
|
161
|
+
| Value | Behavior |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| `passive` | Appears quietly in the notification list, without sound or waking the screen. |
|
|
164
|
+
| `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. |
|
|
165
|
+
| `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. |
|
|
166
|
+
|
|
167
|
+
See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior.
|
|
168
|
+
|
|
169
|
+
The SDK also exports these values as `ActivitySmith::PushInterruptionLevel::PASSIVE`, `ACTIVE`, and `TIME_SENSITIVE`.
|
|
170
|
+
|
|
171
|
+
#### Passive
|
|
172
|
+
|
|
173
|
+
```ruby
|
|
174
|
+
activitysmith.notifications.send(
|
|
175
|
+
{
|
|
176
|
+
title: "Daily summary",
|
|
177
|
+
message: "All scheduled jobs completed successfully.",
|
|
178
|
+
interruption_level: "passive"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Active (default)
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
activitysmith.notifications.send(
|
|
187
|
+
{
|
|
188
|
+
title: "Deployment complete",
|
|
189
|
+
message: "Your latest changes are live.",
|
|
190
|
+
interruption_level: "active"
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Removing the interruption level from this example produces the same delivery behavior.
|
|
196
|
+
|
|
197
|
+
#### Time Sensitive
|
|
198
|
+
|
|
199
|
+
```ruby
|
|
200
|
+
activitysmith.notifications.send(
|
|
201
|
+
{
|
|
202
|
+
title: "🚨 checkout-api is down",
|
|
203
|
+
message: "500 errors on 62% of requests. Customers can't complete payments.",
|
|
204
|
+
interruption_level: "time-sensitive"
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Replace a Push Notification
|
|
210
|
+
|
|
211
|
+
Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original.
|
|
212
|
+
|
|
213
|
+
Omit `metadata` or `tags` to keep their stored values.
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
sent = activitysmith.notifications.send(
|
|
217
|
+
{
|
|
218
|
+
title: "🚨 checkout-api is down",
|
|
219
|
+
message: "500 errors on 62% of requests."
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
activitysmith.notifications.replace(
|
|
224
|
+
sent.notification_id,
|
|
225
|
+
{
|
|
226
|
+
title: "✅ checkout-api recovered",
|
|
227
|
+
message: "Error rate is back to normal. Incident resolved."
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
```
|
|
231
|
+
|
|
139
232
|
## Live Activities
|
|
140
233
|
|
|
141
234
|
Choose the Live Activity type that matches what you want to show:
|
|
142
235
|
|
|
143
|
-
|
|
236
|
+

|
|
237
|
+
|
|
238
|
+
**Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.
|
|
239
|
+
|
|
240
|
+

|
|
144
241
|
|
|
145
|
-
|
|
242
|
+
**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
|
|
146
243
|
|
|
147
|
-
|
|
244
|
+

|
|
148
245
|
|
|
149
|
-
|
|
246
|
+
**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
|
|
150
247
|
|
|
151
|
-
|
|
248
|
+

|
|
152
249
|
|
|
153
|
-
|
|
250
|
+
**Metrics**: Track two related values with segmented bars, such as CPU and memory.
|
|
154
251
|
|
|
155
|
-
|
|
252
|
+

|
|
253
|
+
|
|
254
|
+
**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
|
|
255
|
+
|
|
256
|
+

|
|
257
|
+
|
|
258
|
+
**Progress**: Show percentage progress for jobs that move continuously toward completion.
|
|
259
|
+
|
|
260
|
+

|
|
261
|
+
|
|
262
|
+
**Timer**: Count down from a duration, or count up from 00:00 while a job runs.
|
|
156
263
|
|
|
157
264
|
### Start & Update Live Activity
|
|
158
265
|
|
|
159
266
|
Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it.
|
|
160
267
|
|
|
268
|
+
> [!WARNING]
|
|
269
|
+
> iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](https://activitysmith.com/docs/live-activity-stream#update-frequency-and-ios-limits)
|
|
270
|
+
|
|
161
271
|
#### Value
|
|
162
272
|
|
|
163
273
|

|
|
@@ -665,7 +775,3 @@ end
|
|
|
665
775
|
### [RubyGems Package](https://rubygems.org/gems/activitysmith)
|
|
666
776
|
|
|
667
777
|
Install the ActivitySmith Ruby SDK from RubyGems
|
|
668
|
-
|
|
669
|
-
### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-ruby)
|
|
670
|
-
|
|
671
|
-
View the Ruby SDK source on GitHub
|
|
@@ -19,8 +19,86 @@ module OpenapiClient
|
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
|
+
# Replace a push notification
|
|
23
|
+
# Replaces a Push Notification you already sent, using the `notification_id` from the send response. The replacement takes the original's place on the Lock Screen and in Notification Center instead of appearing as a second notification. It is delivered silently, with no sound or screen wake, to the same recipients as the original. Notification history is updated in place.
|
|
24
|
+
# @param notification_id [String] The `notification_id` returned when the Push Notification was sent.
|
|
25
|
+
# @param push_notification_replace_request [PushNotificationReplaceRequest]
|
|
26
|
+
# @param [Hash] opts the optional parameters
|
|
27
|
+
# @return [PushNotificationReplaceResponse]
|
|
28
|
+
def replace_push_notification(notification_id, push_notification_replace_request, opts = {})
|
|
29
|
+
data, _status_code, _headers = replace_push_notification_with_http_info(notification_id, push_notification_replace_request, opts)
|
|
30
|
+
data
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Replace a push notification
|
|
34
|
+
# Replaces a Push Notification you already sent, using the `notification_id` from the send response. The replacement takes the original's place on the Lock Screen and in Notification Center instead of appearing as a second notification. It is delivered silently, with no sound or screen wake, to the same recipients as the original. Notification history is updated in place.
|
|
35
|
+
# @param notification_id [String] The `notification_id` returned when the Push Notification was sent.
|
|
36
|
+
# @param push_notification_replace_request [PushNotificationReplaceRequest]
|
|
37
|
+
# @param [Hash] opts the optional parameters
|
|
38
|
+
# @return [Array<(PushNotificationReplaceResponse, Integer, Hash)>] PushNotificationReplaceResponse data, response status code and response headers
|
|
39
|
+
def replace_push_notification_with_http_info(notification_id, push_notification_replace_request, opts = {})
|
|
40
|
+
if @api_client.config.debugging
|
|
41
|
+
@api_client.config.logger.debug 'Calling API: PushNotificationsApi.replace_push_notification ...'
|
|
42
|
+
end
|
|
43
|
+
# verify the required parameter 'notification_id' is set
|
|
44
|
+
if @api_client.config.client_side_validation && notification_id.nil?
|
|
45
|
+
fail ArgumentError, "Missing the required parameter 'notification_id' when calling PushNotificationsApi.replace_push_notification"
|
|
46
|
+
end
|
|
47
|
+
if @api_client.config.client_side_validation && notification_id.to_s.length < 1
|
|
48
|
+
fail ArgumentError, 'invalid value for "notification_id" when calling PushNotificationsApi.replace_push_notification, the character length must be great than or equal to 1.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# verify the required parameter 'push_notification_replace_request' is set
|
|
52
|
+
if @api_client.config.client_side_validation && push_notification_replace_request.nil?
|
|
53
|
+
fail ArgumentError, "Missing the required parameter 'push_notification_replace_request' when calling PushNotificationsApi.replace_push_notification"
|
|
54
|
+
end
|
|
55
|
+
# resource path
|
|
56
|
+
local_var_path = '/push-notification/{notification_id}'.sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))
|
|
57
|
+
|
|
58
|
+
# query parameters
|
|
59
|
+
query_params = opts[:query_params] || {}
|
|
60
|
+
|
|
61
|
+
# header parameters
|
|
62
|
+
header_params = opts[:header_params] || {}
|
|
63
|
+
# HTTP header 'Accept' (if needed)
|
|
64
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
65
|
+
# HTTP header 'Content-Type'
|
|
66
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
67
|
+
if !content_type.nil?
|
|
68
|
+
header_params['Content-Type'] = content_type
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# form parameters
|
|
72
|
+
form_params = opts[:form_params] || {}
|
|
73
|
+
|
|
74
|
+
# http body (model)
|
|
75
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(push_notification_replace_request)
|
|
76
|
+
|
|
77
|
+
# return_type
|
|
78
|
+
return_type = opts[:debug_return_type] || 'PushNotificationReplaceResponse'
|
|
79
|
+
|
|
80
|
+
# auth_names
|
|
81
|
+
auth_names = opts[:debug_auth_names] || ['apiKeyAuth']
|
|
82
|
+
|
|
83
|
+
new_options = opts.merge(
|
|
84
|
+
:operation => :"PushNotificationsApi.replace_push_notification",
|
|
85
|
+
:header_params => header_params,
|
|
86
|
+
:query_params => query_params,
|
|
87
|
+
:form_params => form_params,
|
|
88
|
+
:body => post_body,
|
|
89
|
+
:auth_names => auth_names,
|
|
90
|
+
:return_type => return_type
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
|
94
|
+
if @api_client.config.debugging
|
|
95
|
+
@api_client.config.logger.debug "API called: PushNotificationsApi#replace_push_notification\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
96
|
+
end
|
|
97
|
+
return data, status_code, headers
|
|
98
|
+
end
|
|
99
|
+
|
|
22
100
|
# Send a push notification
|
|
23
|
-
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional tags to organize and filter notification history.
|
|
101
|
+
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
|
|
24
102
|
# @param push_notification_request [PushNotificationRequest]
|
|
25
103
|
# @param [Hash] opts the optional parameters
|
|
26
104
|
# @return [PushNotificationResponse]
|
|
@@ -30,7 +108,7 @@ module OpenapiClient
|
|
|
30
108
|
end
|
|
31
109
|
|
|
32
110
|
# Send a push notification
|
|
33
|
-
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional tags to organize and filter notification history.
|
|
111
|
+
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
|
|
34
112
|
# @param push_notification_request [PushNotificationRequest]
|
|
35
113
|
# @param [Hash] opts the optional parameters
|
|
36
114
|
# @return [Array<(PushNotificationResponse, Integer, Hash)>] PushNotificationResponse data, response status code and response headers
|
|
@@ -35,6 +35,15 @@ module OpenapiClient
|
|
|
35
35
|
|
|
36
36
|
attr_accessor :timestamp
|
|
37
37
|
|
|
38
|
+
# Number of device tokens targeted.
|
|
39
|
+
attr_accessor :devices_targeted
|
|
40
|
+
|
|
41
|
+
# Number of device tokens deactivated because APNs reported them unregistered.
|
|
42
|
+
attr_accessor :devices_deactivated
|
|
43
|
+
|
|
44
|
+
# Number of targeted device tokens APNs reported as unregistered.
|
|
45
|
+
attr_accessor :devices_unregistered
|
|
46
|
+
|
|
38
47
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
39
48
|
def self.attribute_map
|
|
40
49
|
{
|
|
@@ -45,7 +54,10 @@ module OpenapiClient
|
|
|
45
54
|
:'devices_notified' => :'devices_notified',
|
|
46
55
|
:'users_notified' => :'users_notified',
|
|
47
56
|
:'effective_channel_slugs' => :'effective_channel_slugs',
|
|
48
|
-
:'timestamp' => :'timestamp'
|
|
57
|
+
:'timestamp' => :'timestamp',
|
|
58
|
+
:'devices_targeted' => :'devices_targeted',
|
|
59
|
+
:'devices_deactivated' => :'devices_deactivated',
|
|
60
|
+
:'devices_unregistered' => :'devices_unregistered'
|
|
49
61
|
}
|
|
50
62
|
end
|
|
51
63
|
|
|
@@ -64,7 +76,10 @@ module OpenapiClient
|
|
|
64
76
|
:'devices_notified' => :'Integer',
|
|
65
77
|
:'users_notified' => :'Integer',
|
|
66
78
|
:'effective_channel_slugs' => :'Array<String>',
|
|
67
|
-
:'timestamp' => :'Time'
|
|
79
|
+
:'timestamp' => :'Time',
|
|
80
|
+
:'devices_targeted' => :'Integer',
|
|
81
|
+
:'devices_deactivated' => :'Integer',
|
|
82
|
+
:'devices_unregistered' => :'Integer'
|
|
68
83
|
}
|
|
69
84
|
end
|
|
70
85
|
|
|
@@ -134,6 +149,18 @@ module OpenapiClient
|
|
|
134
149
|
else
|
|
135
150
|
self.timestamp = nil
|
|
136
151
|
end
|
|
152
|
+
|
|
153
|
+
if attributes.key?(:'devices_targeted')
|
|
154
|
+
self.devices_targeted = attributes[:'devices_targeted']
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if attributes.key?(:'devices_deactivated')
|
|
158
|
+
self.devices_deactivated = attributes[:'devices_deactivated']
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
if attributes.key?(:'devices_unregistered')
|
|
162
|
+
self.devices_unregistered = attributes[:'devices_unregistered']
|
|
163
|
+
end
|
|
137
164
|
end
|
|
138
165
|
|
|
139
166
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -221,7 +248,10 @@ module OpenapiClient
|
|
|
221
248
|
devices_notified == o.devices_notified &&
|
|
222
249
|
users_notified == o.users_notified &&
|
|
223
250
|
effective_channel_slugs == o.effective_channel_slugs &&
|
|
224
|
-
timestamp == o.timestamp
|
|
251
|
+
timestamp == o.timestamp &&
|
|
252
|
+
devices_targeted == o.devices_targeted &&
|
|
253
|
+
devices_deactivated == o.devices_deactivated &&
|
|
254
|
+
devices_unregistered == o.devices_unregistered
|
|
225
255
|
end
|
|
226
256
|
|
|
227
257
|
# @see the `==` method
|
|
@@ -233,7 +263,7 @@ module OpenapiClient
|
|
|
233
263
|
# Calculates hash code according to all attributes.
|
|
234
264
|
# @return [Integer] Hash code
|
|
235
265
|
def hash
|
|
236
|
-
[success, badge, devices_updated, users_updated, devices_notified, users_notified, effective_channel_slugs, timestamp].hash
|
|
266
|
+
[success, badge, devices_updated, users_updated, devices_notified, users_notified, effective_channel_slugs, timestamp, devices_targeted, devices_deactivated, devices_unregistered].hash
|
|
237
267
|
end
|
|
238
268
|
|
|
239
269
|
# Builds the object from hash
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#ActivitySmith API
|
|
3
|
+
|
|
4
|
+
#Send push notifications and Live Activities to your own devices via a single API key.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.7.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module OpenapiClient
|
|
17
|
+
class BillingBlockedError
|
|
18
|
+
attr_accessor :error
|
|
19
|
+
|
|
20
|
+
attr_accessor :message
|
|
21
|
+
|
|
22
|
+
attr_accessor :trial_period
|
|
23
|
+
|
|
24
|
+
attr_accessor :upgrade_url
|
|
25
|
+
|
|
26
|
+
class EnumAttributeValidator
|
|
27
|
+
attr_reader :datatype
|
|
28
|
+
attr_reader :allowable_values
|
|
29
|
+
|
|
30
|
+
def initialize(datatype, allowable_values)
|
|
31
|
+
@allowable_values = allowable_values.map do |value|
|
|
32
|
+
case datatype.to_s
|
|
33
|
+
when /Integer/i
|
|
34
|
+
value.to_i
|
|
35
|
+
when /Float/i
|
|
36
|
+
value.to_f
|
|
37
|
+
else
|
|
38
|
+
value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def valid?(value)
|
|
44
|
+
!value || allowable_values.include?(value)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
49
|
+
def self.attribute_map
|
|
50
|
+
{
|
|
51
|
+
:'error' => :'error',
|
|
52
|
+
:'message' => :'message',
|
|
53
|
+
:'trial_period' => :'trial_period',
|
|
54
|
+
:'upgrade_url' => :'upgrade_url'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns all the JSON keys this model knows about
|
|
59
|
+
def self.acceptable_attributes
|
|
60
|
+
attribute_map.values
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Attribute type mapping.
|
|
64
|
+
def self.openapi_types
|
|
65
|
+
{
|
|
66
|
+
:'error' => :'String',
|
|
67
|
+
:'message' => :'String',
|
|
68
|
+
:'trial_period' => :'BillingBlockedErrorTrialPeriod',
|
|
69
|
+
:'upgrade_url' => :'String'
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# List of attributes with nullable: true
|
|
74
|
+
def self.openapi_nullable
|
|
75
|
+
Set.new([
|
|
76
|
+
])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Initializes the object
|
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
81
|
+
def initialize(attributes = {})
|
|
82
|
+
if (!attributes.is_a?(Hash))
|
|
83
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::BillingBlockedError` initialize method"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
87
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
88
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
89
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::BillingBlockedError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
90
|
+
end
|
|
91
|
+
h[k.to_sym] = v
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if attributes.key?(:'error')
|
|
95
|
+
self.error = attributes[:'error']
|
|
96
|
+
else
|
|
97
|
+
self.error = nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if attributes.key?(:'message')
|
|
101
|
+
self.message = attributes[:'message']
|
|
102
|
+
else
|
|
103
|
+
self.message = nil
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if attributes.key?(:'trial_period')
|
|
107
|
+
self.trial_period = attributes[:'trial_period']
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if attributes.key?(:'upgrade_url')
|
|
111
|
+
self.upgrade_url = attributes[:'upgrade_url']
|
|
112
|
+
else
|
|
113
|
+
self.upgrade_url = nil
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
118
|
+
# @return Array for valid properties with the reasons
|
|
119
|
+
def list_invalid_properties
|
|
120
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
121
|
+
invalid_properties = Array.new
|
|
122
|
+
if @error.nil?
|
|
123
|
+
invalid_properties.push('invalid value for "error", error cannot be nil.')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
if @message.nil?
|
|
127
|
+
invalid_properties.push('invalid value for "message", message cannot be nil.')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
if @upgrade_url.nil?
|
|
131
|
+
invalid_properties.push('invalid value for "upgrade_url", upgrade_url cannot be nil.')
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
invalid_properties
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Check to see if the all the properties in the model are valid
|
|
138
|
+
# @return true if the model is valid
|
|
139
|
+
def valid?
|
|
140
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
141
|
+
return false if @error.nil?
|
|
142
|
+
error_validator = EnumAttributeValidator.new('String', ["trial_expired", "trial_exhausted", "billing_overage_cap_reached"])
|
|
143
|
+
return false unless error_validator.valid?(@error)
|
|
144
|
+
return false if @message.nil?
|
|
145
|
+
return false if @upgrade_url.nil?
|
|
146
|
+
true
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
150
|
+
# @param [Object] error Object to be assigned
|
|
151
|
+
def error=(error)
|
|
152
|
+
validator = EnumAttributeValidator.new('String', ["trial_expired", "trial_exhausted", "billing_overage_cap_reached"])
|
|
153
|
+
unless validator.valid?(error)
|
|
154
|
+
fail ArgumentError, "invalid value for \"error\", must be one of #{validator.allowable_values}."
|
|
155
|
+
end
|
|
156
|
+
@error = error
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Checks equality by comparing each attribute.
|
|
160
|
+
# @param [Object] Object to be compared
|
|
161
|
+
def ==(o)
|
|
162
|
+
return true if self.equal?(o)
|
|
163
|
+
self.class == o.class &&
|
|
164
|
+
error == o.error &&
|
|
165
|
+
message == o.message &&
|
|
166
|
+
trial_period == o.trial_period &&
|
|
167
|
+
upgrade_url == o.upgrade_url
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# @see the `==` method
|
|
171
|
+
# @param [Object] Object to be compared
|
|
172
|
+
def eql?(o)
|
|
173
|
+
self == o
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Calculates hash code according to all attributes.
|
|
177
|
+
# @return [Integer] Hash code
|
|
178
|
+
def hash
|
|
179
|
+
[error, message, trial_period, upgrade_url].hash
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Builds the object from hash
|
|
183
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
184
|
+
# @return [Object] Returns the model itself
|
|
185
|
+
def self.build_from_hash(attributes)
|
|
186
|
+
return nil unless attributes.is_a?(Hash)
|
|
187
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
188
|
+
transformed_hash = {}
|
|
189
|
+
openapi_types.each_pair do |key, type|
|
|
190
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
191
|
+
transformed_hash["#{key}"] = nil
|
|
192
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
193
|
+
# check to ensure the input is an array given that the attribute
|
|
194
|
+
# is documented as an array but the input is not
|
|
195
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
196
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
197
|
+
end
|
|
198
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
199
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
new(transformed_hash)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Deserializes the data based on type
|
|
206
|
+
# @param string type Data type
|
|
207
|
+
# @param string value Value to be deserialized
|
|
208
|
+
# @return [Object] Deserialized data
|
|
209
|
+
def self._deserialize(type, value)
|
|
210
|
+
case type.to_sym
|
|
211
|
+
when :Time
|
|
212
|
+
Time.parse(value)
|
|
213
|
+
when :Date
|
|
214
|
+
Date.parse(value)
|
|
215
|
+
when :String
|
|
216
|
+
value.to_s
|
|
217
|
+
when :Integer
|
|
218
|
+
value.to_i
|
|
219
|
+
when :Float
|
|
220
|
+
value.to_f
|
|
221
|
+
when :Boolean
|
|
222
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
223
|
+
true
|
|
224
|
+
else
|
|
225
|
+
false
|
|
226
|
+
end
|
|
227
|
+
when :Object
|
|
228
|
+
# generic object (usually a Hash), return directly
|
|
229
|
+
value
|
|
230
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
231
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
232
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
233
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
234
|
+
k_type = Regexp.last_match[:k_type]
|
|
235
|
+
v_type = Regexp.last_match[:v_type]
|
|
236
|
+
{}.tap do |hash|
|
|
237
|
+
value.each do |k, v|
|
|
238
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
else # model
|
|
242
|
+
# models (e.g. Pet) or oneOf
|
|
243
|
+
klass = OpenapiClient.const_get(type)
|
|
244
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Returns the string representation of the object
|
|
249
|
+
# @return [String] String presentation of the object
|
|
250
|
+
def to_s
|
|
251
|
+
to_hash.to_s
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
255
|
+
# @return [Hash] Returns the object in the form of hash
|
|
256
|
+
def to_body
|
|
257
|
+
to_hash
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Returns the object in the form of hash
|
|
261
|
+
# @return [Hash] Returns the object in the form of hash
|
|
262
|
+
def to_hash
|
|
263
|
+
hash = {}
|
|
264
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
265
|
+
value = self.send(attr)
|
|
266
|
+
if value.nil?
|
|
267
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
268
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
hash[param] = _to_hash(value)
|
|
272
|
+
end
|
|
273
|
+
hash
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Outputs non-array value in the form of hash
|
|
277
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
278
|
+
# @param [Object] value Any valid value
|
|
279
|
+
# @return [Hash] Returns the value in the form of hash
|
|
280
|
+
def _to_hash(value)
|
|
281
|
+
if value.is_a?(Array)
|
|
282
|
+
value.compact.map { |v| _to_hash(v) }
|
|
283
|
+
elsif value.is_a?(Hash)
|
|
284
|
+
{}.tap do |hash|
|
|
285
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
286
|
+
end
|
|
287
|
+
elsif value.respond_to? :to_hash
|
|
288
|
+
value.to_hash
|
|
289
|
+
else
|
|
290
|
+
value
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
end
|