onesignal 5.15.0 → 5.16.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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/docs/DefaultApi.md +77 -0
- data/docs/EmailReputationResponse.md +22 -0
- data/docs/EmailReputationWindow.md +20 -0
- data/lib/onesignal/api/default_api.rb +63 -0
- data/lib/onesignal/api_client.rb +1 -1
- data/lib/onesignal/models/email_reputation_response.rb +237 -0
- data/lib/onesignal/models/email_reputation_window.rb +230 -0
- data/lib/onesignal/version.rb +1 -1
- data/lib/onesignal.rb +2 -0
- data/spec/api/default_api_spec.rb +12 -0
- data/spec/models/email_reputation_response_spec.rb +45 -0
- data/spec/models/email_reputation_window_spec.rb +39 -0
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/mkmf.log +3 -3
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
- metadata +100 -92
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec6437db60463bed7b865d5ac5059a48bd9352d83634200102457c5bad51cb1c
|
|
4
|
+
data.tar.gz: db39d74d08c633d7546b1686be1ca8bbb2d750d5296b5d2d8f47edba1f9ec4f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e32af171e6615a73118e0fd1ac82a15912b8314d33e550e597d130d8db305230d1f25864b564933bd9f3e2a7f9f30a9a3ac3fd1a7b3f02f6ffc1016d7f30ff6f
|
|
7
|
+
data.tar.gz: 559f6275009040ad7b539bb7dfa140f2315561f09908c1e8b34d0e350661c16d143d718c21adc53f6359c306c8ff516f0d23a51cc3cfd0cef86d6b9cb0be5458
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.15.0](https://github.com/OneSignal/onesignal-ruby-api/compare/v5.14.0...v5.15.0) (2026-08-31)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add v5.15.0 package updates ([0d7db86](https://github.com/OneSignal/onesignal-ruby-api/commit/0d7db869ab72f1a7d32eb9ff1d35af94b5c0f705))
|
|
8
|
+
* add v5.15.0 package updates ([#128](https://github.com/OneSignal/onesignal-ruby-api/issues/128)) ([eca3f92](https://github.com/OneSignal/onesignal-ruby-api/commit/eca3f92f539d3dbb7833bff193ff7430177a32f2)), closes [OneSignal/api-client-libraries#459](https://github.com/OneSignal/api-client-libraries/issues/459)
|
|
9
|
+
|
|
3
10
|
## [5.14.0](https://github.com/OneSignal/onesignal-ruby-api/compare/v5.13.0...v5.14.0) (2026-08-28)
|
|
4
11
|
|
|
5
12
|
### Features
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -6,15 +6,15 @@ OneSignal - the Ruby gem for OneSignal
|
|
|
6
6
|
|
|
7
7
|
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
|
8
8
|
|
|
9
|
-
- API version: 5.
|
|
10
|
-
- Package version: 5.
|
|
9
|
+
- API version: 5.16.0
|
|
10
|
+
- Package version: 5.16.0
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
Add to your `Gemfile`:
|
|
15
15
|
|
|
16
16
|
```ruby
|
|
17
|
-
gem 'onesignal', '~> 5.
|
|
17
|
+
gem 'onesignal', '~> 5.16.0'
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Then run `bundle install`.
|
data/docs/DefaultApi.md
CHANGED
|
@@ -31,6 +31,7 @@ All URIs are relative to *https://api.onesignal.com*
|
|
|
31
31
|
| [**get_aliases_by_subscription**](DefaultApi.md#get_aliases_by_subscription) | **GET** /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
|
|
32
32
|
| [**get_app**](DefaultApi.md#get_app) | **GET** /apps/{app_id} | View an app |
|
|
33
33
|
| [**get_apps**](DefaultApi.md#get_apps) | **GET** /apps | View apps |
|
|
34
|
+
| [**get_email_reputation**](DefaultApi.md#get_email_reputation) | **GET** /apps/{app_id}/email_analytics/delivery_metrics | Get email reputation statistics |
|
|
34
35
|
| [**get_notification**](DefaultApi.md#get_notification) | **GET** /notifications/{notification_id} | View notification |
|
|
35
36
|
| [**get_notification_history**](DefaultApi.md#get_notification_history) | **POST** /notifications/{notification_id}/history | Notification History |
|
|
36
37
|
| [**get_notifications**](DefaultApi.md#get_notifications) | **GET** /notifications | View notifications |
|
|
@@ -2279,6 +2280,82 @@ This endpoint does not need any parameter.
|
|
|
2279
2280
|
- **Accept**: application/json
|
|
2280
2281
|
|
|
2281
2282
|
|
|
2283
|
+
## get_email_reputation
|
|
2284
|
+
|
|
2285
|
+
> <EmailReputationResponse> get_email_reputation(app_id)
|
|
2286
|
+
|
|
2287
|
+
Get email reputation statistics
|
|
2288
|
+
|
|
2289
|
+
The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period.
|
|
2290
|
+
|
|
2291
|
+
### Examples
|
|
2292
|
+
|
|
2293
|
+
```ruby
|
|
2294
|
+
require 'onesignal'
|
|
2295
|
+
# setup authorization
|
|
2296
|
+
OneSignal.configure do |config|
|
|
2297
|
+
# Configure Bearer authorization: rest_api_key
|
|
2298
|
+
config.rest_api_key = 'YOUR_REST_API_KEY'
|
|
2299
|
+
|
|
2300
|
+
end
|
|
2301
|
+
|
|
2302
|
+
api_instance = OneSignal::DefaultApi.new
|
|
2303
|
+
app_id = 'YOUR_APP_ID' # String | Your OneSignal App ID in UUID v4 format.
|
|
2304
|
+
|
|
2305
|
+
begin
|
|
2306
|
+
# Get email reputation statistics
|
|
2307
|
+
result = api_instance.get_email_reputation(app_id)
|
|
2308
|
+
p result
|
|
2309
|
+
rescue OneSignal::ApiError => e
|
|
2310
|
+
puts "Error when calling DefaultApi->get_email_reputation: #{e}"
|
|
2311
|
+
puts "Status Code: #{e.code}"
|
|
2312
|
+
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
|
|
2313
|
+
# the raw body remains on `e.response_body`.
|
|
2314
|
+
puts "Error Messages: #{e.error_messages}"
|
|
2315
|
+
puts "Response Body: #{e.response_body}"
|
|
2316
|
+
end
|
|
2317
|
+
```
|
|
2318
|
+
|
|
2319
|
+
#### Using the get_email_reputation_with_http_info variant
|
|
2320
|
+
|
|
2321
|
+
This returns an Array which contains the response data, status code and headers.
|
|
2322
|
+
|
|
2323
|
+
> <Array(<EmailReputationResponse>, Integer, Hash)> get_email_reputation_with_http_info(app_id)
|
|
2324
|
+
|
|
2325
|
+
```ruby
|
|
2326
|
+
begin
|
|
2327
|
+
# Get email reputation statistics
|
|
2328
|
+
data, status_code, headers = api_instance.get_email_reputation_with_http_info(app_id)
|
|
2329
|
+
p status_code # => 2xx
|
|
2330
|
+
p headers # => { ... }
|
|
2331
|
+
p data # => <EmailReputationResponse>
|
|
2332
|
+
rescue OneSignal::ApiError => e
|
|
2333
|
+
puts "Error when calling DefaultApi->get_email_reputation_with_http_info: #{e}"
|
|
2334
|
+
puts "Status Code: #{e.code}"
|
|
2335
|
+
puts "Response Body: #{e.response_body}"
|
|
2336
|
+
end
|
|
2337
|
+
```
|
|
2338
|
+
|
|
2339
|
+
### Parameters
|
|
2340
|
+
|
|
2341
|
+
| Name | Type | Description | Notes |
|
|
2342
|
+
| ---- | ---- | ----------- | ----- |
|
|
2343
|
+
| **app_id** | **String** | Your OneSignal App ID in UUID v4 format. | |
|
|
2344
|
+
|
|
2345
|
+
### Return type
|
|
2346
|
+
|
|
2347
|
+
[**EmailReputationResponse**](EmailReputationResponse.md)
|
|
2348
|
+
|
|
2349
|
+
### Authorization
|
|
2350
|
+
|
|
2351
|
+
[rest_api_key](https://github.com/OneSignal/onesignal-ruby-api#configuration)
|
|
2352
|
+
|
|
2353
|
+
### HTTP request headers
|
|
2354
|
+
|
|
2355
|
+
- **Content-Type**: Not defined
|
|
2356
|
+
- **Accept**: application/json
|
|
2357
|
+
|
|
2358
|
+
|
|
2282
2359
|
## get_notification
|
|
2283
2360
|
|
|
2284
2361
|
> <NotificationWithMeta> get_notification(app_id, notification_id)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# OneSignal::EmailReputationResponse
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **last_24_hours** | [**EmailReputationWindow**](EmailReputationWindow.md) | | [optional] |
|
|
8
|
+
| **last_7_days** | [**EmailReputationWindow**](EmailReputationWindow.md) | | [optional] |
|
|
9
|
+
| **last_30_days** | [**EmailReputationWindow**](EmailReputationWindow.md) | | [optional] |
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
require 'onesignal'
|
|
15
|
+
|
|
16
|
+
instance = OneSignal::EmailReputationResponse.new(
|
|
17
|
+
last_24_hours: nil,
|
|
18
|
+
last_7_days: nil,
|
|
19
|
+
last_30_days: nil
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# OneSignal::EmailReputationWindow
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **bounce_rate** | **Float** | The fraction of successfully delivered emails that hard or soft bounced during the window. | [optional] |
|
|
8
|
+
| **complaint_rate** | **Float** | The fraction of successfully delivered emails that recipients reported as spam during the window. | [optional] |
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
require 'onesignal'
|
|
14
|
+
|
|
15
|
+
instance = OneSignal::EmailReputationWindow.new(
|
|
16
|
+
bounce_rate: 0.02,
|
|
17
|
+
complaint_rate: 0.001
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
@@ -1947,6 +1947,69 @@ module OneSignal
|
|
|
1947
1947
|
return data, status_code, headers
|
|
1948
1948
|
end
|
|
1949
1949
|
|
|
1950
|
+
# Get email reputation statistics
|
|
1951
|
+
# The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period.
|
|
1952
|
+
# @param app_id [String] Your OneSignal App ID in UUID v4 format.
|
|
1953
|
+
# @param [Hash] opts the optional parameters
|
|
1954
|
+
# @return [EmailReputationResponse]
|
|
1955
|
+
def get_email_reputation(app_id, opts = {})
|
|
1956
|
+
data, _status_code, _headers = get_email_reputation_with_http_info(app_id, opts)
|
|
1957
|
+
data
|
|
1958
|
+
end
|
|
1959
|
+
|
|
1960
|
+
# Get email reputation statistics
|
|
1961
|
+
# The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period.
|
|
1962
|
+
# @param app_id [String] Your OneSignal App ID in UUID v4 format.
|
|
1963
|
+
# @param [Hash] opts the optional parameters
|
|
1964
|
+
# @return [Array<(EmailReputationResponse, Integer, Hash)>] EmailReputationResponse data, response status code and response headers
|
|
1965
|
+
def get_email_reputation_with_http_info(app_id, opts = {})
|
|
1966
|
+
if @api_client.config.debugging
|
|
1967
|
+
@api_client.config.logger.debug 'Calling API: DefaultApi.get_email_reputation ...'
|
|
1968
|
+
end
|
|
1969
|
+
# verify the required parameter 'app_id' is set
|
|
1970
|
+
if @api_client.config.client_side_validation && app_id.nil?
|
|
1971
|
+
fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_email_reputation"
|
|
1972
|
+
end
|
|
1973
|
+
# resource path
|
|
1974
|
+
local_var_path = '/apps/{app_id}/email_analytics/delivery_metrics'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))
|
|
1975
|
+
|
|
1976
|
+
# query parameters
|
|
1977
|
+
query_params = opts[:query_params] || {}
|
|
1978
|
+
|
|
1979
|
+
# header parameters
|
|
1980
|
+
header_params = opts[:header_params] || {}
|
|
1981
|
+
# HTTP header 'Accept' (if needed)
|
|
1982
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
1983
|
+
|
|
1984
|
+
# form parameters
|
|
1985
|
+
form_params = opts[:form_params] || {}
|
|
1986
|
+
|
|
1987
|
+
# http body (model)
|
|
1988
|
+
post_body = opts[:debug_body]
|
|
1989
|
+
|
|
1990
|
+
# return_type
|
|
1991
|
+
return_type = opts[:debug_return_type] || 'EmailReputationResponse'
|
|
1992
|
+
|
|
1993
|
+
# auth_names
|
|
1994
|
+
auth_names = opts[:debug_auth_names] || ['rest_api_key']
|
|
1995
|
+
|
|
1996
|
+
new_options = opts.merge(
|
|
1997
|
+
:operation => :"DefaultApi.get_email_reputation",
|
|
1998
|
+
:header_params => header_params,
|
|
1999
|
+
:query_params => query_params,
|
|
2000
|
+
:form_params => form_params,
|
|
2001
|
+
:body => post_body,
|
|
2002
|
+
:auth_names => auth_names,
|
|
2003
|
+
:return_type => return_type
|
|
2004
|
+
)
|
|
2005
|
+
|
|
2006
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
2007
|
+
if @api_client.config.debugging
|
|
2008
|
+
@api_client.config.logger.debug "API called: DefaultApi#get_email_reputation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
2009
|
+
end
|
|
2010
|
+
return data, status_code, headers
|
|
2011
|
+
end
|
|
2012
|
+
|
|
1950
2013
|
# View notification
|
|
1951
2014
|
# View the details of a single notification and outcomes associated with it
|
|
1952
2015
|
# @param app_id [String]
|
data/lib/onesignal/api_client.rb
CHANGED
|
@@ -89,7 +89,7 @@ module OneSignal
|
|
|
89
89
|
url = build_request_url(path, opts)
|
|
90
90
|
http_method = http_method.to_sym.downcase
|
|
91
91
|
|
|
92
|
-
opts[:header_params]['OS-Usage-Data'] = 'kind=sdk, sdk-name=onesignal-ruby, version=5.
|
|
92
|
+
opts[:header_params]['OS-Usage-Data'] = 'kind=sdk, sdk-name=onesignal-ruby, version=5.16.0'
|
|
93
93
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
|
94
94
|
query_params = opts[:query_params] || {}
|
|
95
95
|
form_params = opts[:form_params] || {}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#OneSignal
|
|
3
|
+
|
|
4
|
+
#A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
|
5
|
+
|
|
6
|
+
Contact: devrel@onesignal.com
|
|
7
|
+
Generated by: https://openapi-generator.tech
|
|
8
|
+
OpenAPI Generator version: 6.0.0-SNAPSHOT
|
|
9
|
+
|
|
10
|
+
=end
|
|
11
|
+
|
|
12
|
+
require 'date'
|
|
13
|
+
require 'time'
|
|
14
|
+
|
|
15
|
+
module OneSignal
|
|
16
|
+
# App-wide email bounce and spam complaint rates, broken out by time window. `last_24_hours`, `last_7_days`, and `last_30_days` each hold the bounce and complaint rates for email delivered in that window.
|
|
17
|
+
class EmailReputationResponse
|
|
18
|
+
attr_accessor :last_24_hours
|
|
19
|
+
|
|
20
|
+
attr_accessor :last_7_days
|
|
21
|
+
|
|
22
|
+
attr_accessor :last_30_days
|
|
23
|
+
|
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
|
+
def self.attribute_map
|
|
26
|
+
{
|
|
27
|
+
:'last_24_hours' => :'last_24_hours',
|
|
28
|
+
:'last_7_days' => :'last_7_days',
|
|
29
|
+
:'last_30_days' => :'last_30_days'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns all the JSON keys this model knows about
|
|
34
|
+
def self.acceptable_attributes
|
|
35
|
+
attribute_map.values
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Attribute type mapping.
|
|
39
|
+
def self.openapi_types
|
|
40
|
+
{
|
|
41
|
+
:'last_24_hours' => :'EmailReputationWindow',
|
|
42
|
+
:'last_7_days' => :'EmailReputationWindow',
|
|
43
|
+
:'last_30_days' => :'EmailReputationWindow'
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# List of attributes with nullable: true
|
|
48
|
+
def self.openapi_nullable
|
|
49
|
+
Set.new([
|
|
50
|
+
])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Initializes the object
|
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
55
|
+
def initialize(attributes = {})
|
|
56
|
+
if (!attributes.is_a?(Hash))
|
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailReputationResponse` initialize method"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
61
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
62
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailReputationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
64
|
+
end
|
|
65
|
+
h[k.to_sym] = v
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if attributes.key?(:'last_24_hours')
|
|
69
|
+
self.last_24_hours = attributes[:'last_24_hours']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
if attributes.key?(:'last_7_days')
|
|
73
|
+
self.last_7_days = attributes[:'last_7_days']
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
if attributes.key?(:'last_30_days')
|
|
77
|
+
self.last_30_days = attributes[:'last_30_days']
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
82
|
+
# @return Array for valid properties with the reasons
|
|
83
|
+
def list_invalid_properties
|
|
84
|
+
invalid_properties = Array.new
|
|
85
|
+
invalid_properties
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Check to see if the all the properties in the model are valid
|
|
89
|
+
# @return true if the model is valid
|
|
90
|
+
def valid?
|
|
91
|
+
true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Checks equality by comparing each attribute.
|
|
95
|
+
# @param [Object] Object to be compared
|
|
96
|
+
def ==(o)
|
|
97
|
+
return true if self.equal?(o)
|
|
98
|
+
self.class == o.class &&
|
|
99
|
+
last_24_hours == o.last_24_hours &&
|
|
100
|
+
last_7_days == o.last_7_days &&
|
|
101
|
+
last_30_days == o.last_30_days
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @see the `==` method
|
|
105
|
+
# @param [Object] Object to be compared
|
|
106
|
+
def eql?(o)
|
|
107
|
+
self == o
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Calculates hash code according to all attributes.
|
|
111
|
+
# @return [Integer] Hash code
|
|
112
|
+
def hash
|
|
113
|
+
[last_24_hours, last_7_days, last_30_days].hash
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Builds the object from hash
|
|
117
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
118
|
+
# @return [Object] Returns the model itself
|
|
119
|
+
def self.build_from_hash(attributes)
|
|
120
|
+
new.build_from_hash(attributes)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Builds the object from hash
|
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
125
|
+
# @return [Object] Returns the model itself
|
|
126
|
+
def build_from_hash(attributes)
|
|
127
|
+
return nil unless attributes.is_a?(Hash)
|
|
128
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
129
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
130
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
131
|
+
self.send("#{key}=", nil)
|
|
132
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
133
|
+
# check to ensure the input is an array given that the attribute
|
|
134
|
+
# is documented as an array but the input is not
|
|
135
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
136
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
137
|
+
end
|
|
138
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
139
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
self
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Deserializes the data based on type
|
|
147
|
+
# @param string type Data type
|
|
148
|
+
# @param string value Value to be deserialized
|
|
149
|
+
# @return [Object] Deserialized data
|
|
150
|
+
def _deserialize(type, value)
|
|
151
|
+
case type.to_sym
|
|
152
|
+
when :Time
|
|
153
|
+
Time.parse(value)
|
|
154
|
+
when :Date
|
|
155
|
+
Date.parse(value)
|
|
156
|
+
when :String
|
|
157
|
+
value.to_s
|
|
158
|
+
when :Integer
|
|
159
|
+
value.to_i
|
|
160
|
+
when :Float
|
|
161
|
+
value.to_f
|
|
162
|
+
when :Boolean
|
|
163
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
164
|
+
true
|
|
165
|
+
else
|
|
166
|
+
false
|
|
167
|
+
end
|
|
168
|
+
when :Object
|
|
169
|
+
# generic object (usually a Hash), return directly
|
|
170
|
+
value
|
|
171
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
172
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
173
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
174
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
175
|
+
k_type = Regexp.last_match[:k_type]
|
|
176
|
+
v_type = Regexp.last_match[:v_type]
|
|
177
|
+
{}.tap do |hash|
|
|
178
|
+
value.each do |k, v|
|
|
179
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
else # model
|
|
183
|
+
# models (e.g. Pet) or oneOf
|
|
184
|
+
klass = OneSignal.const_get(type)
|
|
185
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Returns the string representation of the object
|
|
190
|
+
# @return [String] String presentation of the object
|
|
191
|
+
def to_s
|
|
192
|
+
to_hash.to_s
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
|
197
|
+
def to_body
|
|
198
|
+
to_hash
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Returns the object in the form of hash
|
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
|
203
|
+
def to_hash
|
|
204
|
+
hash = {}
|
|
205
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
206
|
+
value = self.send(attr)
|
|
207
|
+
if value.nil?
|
|
208
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
209
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
hash[param] = _to_hash(value)
|
|
213
|
+
end
|
|
214
|
+
hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Outputs non-array value in the form of hash
|
|
218
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
219
|
+
# @param [Object] value Any valid value
|
|
220
|
+
# @return [Hash] Returns the value in the form of hash
|
|
221
|
+
def _to_hash(value)
|
|
222
|
+
if value.is_a?(Array)
|
|
223
|
+
value.compact.map { |v| _to_hash(v) }
|
|
224
|
+
elsif value.is_a?(Hash)
|
|
225
|
+
{}.tap do |hash|
|
|
226
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
227
|
+
end
|
|
228
|
+
elsif value.respond_to? :to_hash
|
|
229
|
+
value.to_hash
|
|
230
|
+
else
|
|
231
|
+
value
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
end
|