onesignal 5.17.0 → 5.18.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +3 -3
  5. data/docs/DefaultApi.md +192 -20
  6. data/docs/EmailMetrics.md +34 -0
  7. data/docs/EmailProviderMetrics.md +20 -0
  8. data/docs/EmailProviderMetricsEvent.md +20 -0
  9. data/docs/EmailProviderMetricsResponse.md +18 -0
  10. data/docs/EmailProviderMetricsTimeseriesResponse.md +18 -0
  11. data/lib/onesignal/api/default_api.rb +183 -0
  12. data/lib/onesignal/api_client.rb +24 -1
  13. data/lib/onesignal/configuration.rb +4 -2
  14. data/lib/onesignal/models/email_metrics.rb +300 -0
  15. data/lib/onesignal/models/email_provider_metrics.rb +229 -0
  16. data/lib/onesignal/models/email_provider_metrics_event.rb +229 -0
  17. data/lib/onesignal/models/email_provider_metrics_response.rb +222 -0
  18. data/lib/onesignal/models/email_provider_metrics_timeseries_response.rb +222 -0
  19. data/lib/onesignal/version.rb +1 -1
  20. data/lib/onesignal.rb +5 -0
  21. data/spec/api/default_api_spec.rb +32 -0
  22. data/spec/api_client_spec.rb +6 -6
  23. data/spec/models/email_metrics_spec.rb +81 -0
  24. data/spec/models/email_provider_metrics_event_spec.rb +39 -0
  25. data/spec/models/email_provider_metrics_response_spec.rb +33 -0
  26. data/spec/models/email_provider_metrics_spec.rb +39 -0
  27. data/spec/models/email_provider_metrics_timeseries_response_spec.rb +33 -0
  28. data/vendor/bundle/ruby/3.2.0/cache/date-3.6.0.gem +0 -0
  29. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
  30. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.6.0/date_core.so +0 -0
  31. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.6.0/gem_make.out +26 -0
  32. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{date-3.5.1 → date-3.6.0}/mkmf.log +55 -2
  33. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.4/gem_make.out +5 -5
  34. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.4/mkmf.log +3 -3
  35. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  36. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/gem_make.out +5 -5
  37. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  38. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
  39. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/Makefile +1 -1
  40. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_core.c +293 -77
  41. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_parse.c +14 -4
  42. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_strptime.c +13 -13
  43. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/extconf.rb +6 -0
  44. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/lib/date.rb +1 -1
  45. data/vendor/bundle/ruby/3.2.0/gems/date-3.6.0/lib/date_core.so +0 -0
  46. data/vendor/bundle/ruby/3.2.0/specifications/{date-3.5.1.gemspec → date-3.6.0.gemspec} +3 -3
  47. metadata +43 -23
  48. data/vendor/bundle/ruby/3.2.0/cache/date-3.5.1.gem +0 -0
  49. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/date_core.so +0 -0
  50. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +0 -24
  51. data/vendor/bundle/ruby/3.2.0/gems/date-3.5.1/lib/date_core.so +0 -0
  52. /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{date-3.5.1 → date-3.6.0}/gem.build_complete +0 -0
  53. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/BSDL +0 -0
  54. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/COPYING +0 -0
  55. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/README.md +0 -0
  56. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_strftime.c +0 -0
  57. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_tmx.h +0 -0
  58. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/prereq.mk +0 -0
  59. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/zonetab.h +0 -0
  60. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/zonetab.list +0 -0
@@ -2023,6 +2023,189 @@ module OneSignal
2023
2023
  return data, status_code, headers
2024
2024
  end
2025
2025
 
2026
+ # Get email inbox provider metrics
2027
+ # Email delivery, opens, clicks, bounces, failures, and spam complaints broken down by inbox provider (Gmail, Outlook, Yahoo, Apple, and more) to pinpoint where deliverability problems are coming from. Metrics are reported for a single sending domain over the requested time range. `start` must be before `end` and no more than 365 days ago. `providers` is empty when the domain is not found for the app or is not currently active for sending.
2028
+ # @param app_id [String] Your OneSignal App ID in UUID v4 format.
2029
+ # @param domain [String] The sending domain to report on. Must be an email domain configured for this app.
2030
+ # @param start [Time] Start of the reporting window, as an ISO 8601 timestamp (for example, `2026-08-01T00:00:00Z`).
2031
+ # @param _end [Time] End of the reporting window, as an ISO 8601 timestamp (for example, `2026-08-08T00:00:00Z`).
2032
+ # @param [Hash] opts the optional parameters
2033
+ # @return [EmailProviderMetricsResponse]
2034
+ def get_email_provider_metrics(app_id, domain, start, _end, opts = {})
2035
+ data, _status_code, _headers = get_email_provider_metrics_with_http_info(app_id, domain, start, _end, opts)
2036
+ data
2037
+ end
2038
+
2039
+ # Get email inbox provider metrics
2040
+ # Email delivery, opens, clicks, bounces, failures, and spam complaints broken down by inbox provider (Gmail, Outlook, Yahoo, Apple, and more) to pinpoint where deliverability problems are coming from. Metrics are reported for a single sending domain over the requested time range. `start` must be before `end` and no more than 365 days ago. `providers` is empty when the domain is not found for the app or is not currently active for sending.
2041
+ # @param app_id [String] Your OneSignal App ID in UUID v4 format.
2042
+ # @param domain [String] The sending domain to report on. Must be an email domain configured for this app.
2043
+ # @param start [Time] Start of the reporting window, as an ISO 8601 timestamp (for example, `2026-08-01T00:00:00Z`).
2044
+ # @param _end [Time] End of the reporting window, as an ISO 8601 timestamp (for example, `2026-08-08T00:00:00Z`).
2045
+ # @param [Hash] opts the optional parameters
2046
+ # @return [Array<(EmailProviderMetricsResponse, Integer, Hash)>] EmailProviderMetricsResponse data, response status code and response headers
2047
+ def get_email_provider_metrics_with_http_info(app_id, domain, start, _end, opts = {})
2048
+ if @api_client.config.debugging
2049
+ @api_client.config.logger.debug 'Calling API: DefaultApi.get_email_provider_metrics ...'
2050
+ end
2051
+ # verify the required parameter 'app_id' is set
2052
+ if @api_client.config.client_side_validation && app_id.nil?
2053
+ fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_email_provider_metrics"
2054
+ end
2055
+ # verify the required parameter 'domain' is set
2056
+ if @api_client.config.client_side_validation && domain.nil?
2057
+ fail ArgumentError, "Missing the required parameter 'domain' when calling DefaultApi.get_email_provider_metrics"
2058
+ end
2059
+ # verify the required parameter 'start' is set
2060
+ if @api_client.config.client_side_validation && start.nil?
2061
+ fail ArgumentError, "Missing the required parameter 'start' when calling DefaultApi.get_email_provider_metrics"
2062
+ end
2063
+ # verify the required parameter '_end' is set
2064
+ if @api_client.config.client_side_validation && _end.nil?
2065
+ fail ArgumentError, "Missing the required parameter '_end' when calling DefaultApi.get_email_provider_metrics"
2066
+ end
2067
+ # resource path
2068
+ local_var_path = '/apps/{app_id}/email_analytics/provider_metrics'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))
2069
+
2070
+ # query parameters
2071
+ query_params = opts[:query_params] || {}
2072
+ query_params[:'domain'] = domain
2073
+ query_params[:'start'] = start
2074
+ query_params[:'end'] = _end
2075
+
2076
+ # header parameters
2077
+ header_params = opts[:header_params] || {}
2078
+ # HTTP header 'Accept' (if needed)
2079
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
2080
+
2081
+ # form parameters
2082
+ form_params = opts[:form_params] || {}
2083
+
2084
+ # http body (model)
2085
+ post_body = opts[:debug_body]
2086
+
2087
+ # return_type
2088
+ return_type = opts[:debug_return_type] || 'EmailProviderMetricsResponse'
2089
+
2090
+ # auth_names
2091
+ auth_names = opts[:debug_auth_names] || ['rest_api_key']
2092
+
2093
+ new_options = opts.merge(
2094
+ :operation => :"DefaultApi.get_email_provider_metrics",
2095
+ :header_params => header_params,
2096
+ :query_params => query_params,
2097
+ :form_params => form_params,
2098
+ :body => post_body,
2099
+ :auth_names => auth_names,
2100
+ :return_type => return_type
2101
+ )
2102
+
2103
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
2104
+ if @api_client.config.debugging
2105
+ @api_client.config.logger.debug "API called: DefaultApi#get_email_provider_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2106
+ end
2107
+ return data, status_code, headers
2108
+ end
2109
+
2110
+ # Get email inbox provider metrics over time
2111
+ # Email delivery, opens, clicks, bounces, failures, and spam complaints for a sending domain over time, bucketed by hour, day, or month. Use `providers[]` to narrow the totals to specific inbox providers (Gmail, Outlook, Yahoo, Apple, and more) and track how deliverability to them changes. Each event's metrics are totaled across the requested providers, or across all providers when none are given. `start` must be before `end` and no more than 365 days ago, or 60 days ago for `hourly` granularity. `events` is empty when the domain is not found for the app or is not currently active for sending.
2112
+ # @param app_id [String] Your OneSignal App ID in UUID v4 format.
2113
+ # @param domain [String] The sending domain to report on. Must be an email domain configured for this app.
2114
+ # @param start [Time] Start of the reporting window, as an ISO 8601 timestamp (for example, &#x60;2026-08-01T00:00:00Z&#x60;).
2115
+ # @param _end [Time] End of the reporting window, as an ISO 8601 timestamp (for example, &#x60;2026-08-08T00:00:00Z&#x60;).
2116
+ # @param granularity [String] The size of each time bucket. Hourly data is only available for the last 60 days.
2117
+ # @param [Hash] opts the optional parameters
2118
+ # @option opts [Array<String>] :providers Inbox providers to include in the totals. Omit to include all providers. Accepted values: &#x60;apple&#x60;, &#x60;att&#x60;, &#x60;canadian&#x60;, &#x60;chinese&#x60;, &#x60;comcast&#x60;, &#x60;free_fr&#x60;, &#x60;french&#x60;, &#x60;german&#x60;, &#x60;gmail&#x60;, &#x60;google_workspace&#x60;, &#x60;googlers&#x60;, &#x60;inbox_lv&#x60;, &#x60;italian&#x60;, &#x60;japanese&#x60;, &#x60;outlook_365&#x60;, &#x60;outlook_eu&#x60;, &#x60;outlook_us&#x60;, &#x60;proton&#x60;, &#x60;rackspace&#x60;, &#x60;russian&#x60;, &#x60;uk&#x60;, &#x60;united_online&#x60;, &#x60;yahoo_eu&#x60;, &#x60;yahoo_us&#x60;, &#x60;other_eu&#x60;, &#x60;other_us&#x60;, and &#x60;other&#x60;. Example: providers[]&#x3D;gmail&amp;providers[]&#x3D;yahoo_us
2119
+ # @return [EmailProviderMetricsTimeseriesResponse]
2120
+ def get_email_provider_metrics_timeseries(app_id, domain, start, _end, granularity, opts = {})
2121
+ data, _status_code, _headers = get_email_provider_metrics_timeseries_with_http_info(app_id, domain, start, _end, granularity, opts)
2122
+ data
2123
+ end
2124
+
2125
+ # Get email inbox provider metrics over time
2126
+ # Email delivery, opens, clicks, bounces, failures, and spam complaints for a sending domain over time, bucketed by hour, day, or month. Use &#x60;providers[]&#x60; to narrow the totals to specific inbox providers (Gmail, Outlook, Yahoo, Apple, and more) and track how deliverability to them changes. Each event&#39;s metrics are totaled across the requested providers, or across all providers when none are given. &#x60;start&#x60; must be before &#x60;end&#x60; and no more than 365 days ago, or 60 days ago for &#x60;hourly&#x60; granularity. &#x60;events&#x60; is empty when the domain is not found for the app or is not currently active for sending.
2127
+ # @param app_id [String] Your OneSignal App ID in UUID v4 format.
2128
+ # @param domain [String] The sending domain to report on. Must be an email domain configured for this app.
2129
+ # @param start [Time] Start of the reporting window, as an ISO 8601 timestamp (for example, &#x60;2026-08-01T00:00:00Z&#x60;).
2130
+ # @param _end [Time] End of the reporting window, as an ISO 8601 timestamp (for example, &#x60;2026-08-08T00:00:00Z&#x60;).
2131
+ # @param granularity [String] The size of each time bucket. Hourly data is only available for the last 60 days.
2132
+ # @param [Hash] opts the optional parameters
2133
+ # @option opts [Array<String>] :providers Inbox providers to include in the totals. Omit to include all providers. Accepted values: &#x60;apple&#x60;, &#x60;att&#x60;, &#x60;canadian&#x60;, &#x60;chinese&#x60;, &#x60;comcast&#x60;, &#x60;free_fr&#x60;, &#x60;french&#x60;, &#x60;german&#x60;, &#x60;gmail&#x60;, &#x60;google_workspace&#x60;, &#x60;googlers&#x60;, &#x60;inbox_lv&#x60;, &#x60;italian&#x60;, &#x60;japanese&#x60;, &#x60;outlook_365&#x60;, &#x60;outlook_eu&#x60;, &#x60;outlook_us&#x60;, &#x60;proton&#x60;, &#x60;rackspace&#x60;, &#x60;russian&#x60;, &#x60;uk&#x60;, &#x60;united_online&#x60;, &#x60;yahoo_eu&#x60;, &#x60;yahoo_us&#x60;, &#x60;other_eu&#x60;, &#x60;other_us&#x60;, and &#x60;other&#x60;. Example: providers[]&#x3D;gmail&amp;providers[]&#x3D;yahoo_us
2134
+ # @return [Array<(EmailProviderMetricsTimeseriesResponse, Integer, Hash)>] EmailProviderMetricsTimeseriesResponse data, response status code and response headers
2135
+ def get_email_provider_metrics_timeseries_with_http_info(app_id, domain, start, _end, granularity, opts = {})
2136
+ if @api_client.config.debugging
2137
+ @api_client.config.logger.debug 'Calling API: DefaultApi.get_email_provider_metrics_timeseries ...'
2138
+ end
2139
+ # verify the required parameter 'app_id' is set
2140
+ if @api_client.config.client_side_validation && app_id.nil?
2141
+ fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_email_provider_metrics_timeseries"
2142
+ end
2143
+ # verify the required parameter 'domain' is set
2144
+ if @api_client.config.client_side_validation && domain.nil?
2145
+ fail ArgumentError, "Missing the required parameter 'domain' when calling DefaultApi.get_email_provider_metrics_timeseries"
2146
+ end
2147
+ # verify the required parameter 'start' is set
2148
+ if @api_client.config.client_side_validation && start.nil?
2149
+ fail ArgumentError, "Missing the required parameter 'start' when calling DefaultApi.get_email_provider_metrics_timeseries"
2150
+ end
2151
+ # verify the required parameter '_end' is set
2152
+ if @api_client.config.client_side_validation && _end.nil?
2153
+ fail ArgumentError, "Missing the required parameter '_end' when calling DefaultApi.get_email_provider_metrics_timeseries"
2154
+ end
2155
+ # verify the required parameter 'granularity' is set
2156
+ if @api_client.config.client_side_validation && granularity.nil?
2157
+ fail ArgumentError, "Missing the required parameter 'granularity' when calling DefaultApi.get_email_provider_metrics_timeseries"
2158
+ end
2159
+ # verify enum value
2160
+ allowable_values = ["hourly", "daily", "monthly"]
2161
+ if @api_client.config.client_side_validation && !allowable_values.include?(granularity)
2162
+ fail ArgumentError, "invalid value for \"granularity\", must be one of #{allowable_values}"
2163
+ end
2164
+ # resource path
2165
+ local_var_path = '/apps/{app_id}/email_analytics/provider_metrics_timeseries'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))
2166
+
2167
+ # query parameters
2168
+ query_params = opts[:query_params] || {}
2169
+ query_params[:'domain'] = domain
2170
+ query_params[:'start'] = start
2171
+ query_params[:'end'] = _end
2172
+ query_params[:'granularity'] = granularity
2173
+ query_params[:'providers[]'] = @api_client.build_collection_param(opts[:'providers'], :multi) if !opts[:'providers'].nil?
2174
+
2175
+ # header parameters
2176
+ header_params = opts[:header_params] || {}
2177
+ # HTTP header 'Accept' (if needed)
2178
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
2179
+
2180
+ # form parameters
2181
+ form_params = opts[:form_params] || {}
2182
+
2183
+ # http body (model)
2184
+ post_body = opts[:debug_body]
2185
+
2186
+ # return_type
2187
+ return_type = opts[:debug_return_type] || 'EmailProviderMetricsTimeseriesResponse'
2188
+
2189
+ # auth_names
2190
+ auth_names = opts[:debug_auth_names] || ['rest_api_key']
2191
+
2192
+ new_options = opts.merge(
2193
+ :operation => :"DefaultApi.get_email_provider_metrics_timeseries",
2194
+ :header_params => header_params,
2195
+ :query_params => query_params,
2196
+ :form_params => form_params,
2197
+ :body => post_body,
2198
+ :auth_names => auth_names,
2199
+ :return_type => return_type
2200
+ )
2201
+
2202
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
2203
+ if @api_client.config.debugging
2204
+ @api_client.config.logger.debug "API called: DefaultApi#get_email_provider_metrics_timeseries\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2205
+ end
2206
+ return data, status_code, headers
2207
+ end
2208
+
2026
2209
  # Get email reputation statistics
2027
2210
  # 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.
2028
2211
  # @param app_id [String] Your OneSignal App ID in UUID v4 format.
@@ -89,13 +89,14 @@ 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.17.0'
92
+ opts[:header_params]['OS-Usage-Data'] = 'kind=sdk, sdk-name=onesignal-ruby, version=5.18.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] || {}
96
96
  follow_location = opts[:follow_location] || true
97
97
 
98
98
  update_params_for_auth! header_params, query_params, opts[:auth_names]
99
+ query_params = serialize_query_params(query_params)
99
100
 
100
101
  # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
101
102
  _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
@@ -388,5 +389,27 @@ module OneSignal
388
389
  fail "unknown collection format: #{collection_format.inspect}"
389
390
  end
390
391
  end
392
+
393
+ # Serialize query parameter values for the wire.
394
+ # Time, DateTime and Date values are sent as ISO 8601 (Time#to_s is not),
395
+ # including inside arrays; other values are passed through unchanged.
396
+ # @param [Hash] query_params Query parameters
397
+ # @return [Hash] Query parameters with serialized values
398
+ def serialize_query_params(query_params)
399
+ query_params.transform_values { |value| serialize_query_value(value) }
400
+ end
401
+
402
+ # @param [Object] value Query parameter value
403
+ # @return [Object] ISO 8601 string for Time/Date values, the value otherwise
404
+ def serialize_query_value(value)
405
+ case value
406
+ when Array
407
+ value.map { |item| serialize_query_value(item) }
408
+ when Time, Date
409
+ value.iso8601
410
+ else
411
+ value
412
+ end
413
+ end
391
414
  end
392
415
  end
@@ -102,7 +102,9 @@ module OneSignal
102
102
  attr_accessor :key_file
103
103
 
104
104
  # Set this to customize parameters encoding of array parameter with multi collectionFormat.
105
- # Default to nil.
105
+ # Defaults to :multi, which sends arrays as repeated keys (ids=a&ids=b), matching
106
+ # OpenAPI `style: form, explode: true`. nil falls back to Ethon's default
107
+ # (ids[0]=a&ids[1]=b).
106
108
  #
107
109
  # @see The params_encoding option of Ethon. Related source code:
108
110
  # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
@@ -128,7 +130,7 @@ module OneSignal
128
130
  @cert_file = nil
129
131
  @key_file = nil
130
132
  @timeout = 0
131
- @params_encoding = nil
133
+ @params_encoding = :multi
132
134
  @debugging = false
133
135
  @inject_format = false
134
136
  @force_ending_format = false
@@ -0,0 +1,300 @@
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
+ # Email delivery and engagement counts for the reporting window.
17
+ class EmailMetrics
18
+ # The number of emails sent.
19
+ attr_accessor :sent
20
+
21
+ # The number of emails successfully delivered.
22
+ attr_accessor :delivered
23
+
24
+ # The total number of email opens, including repeat opens by the same recipient.
25
+ attr_accessor :opened
26
+
27
+ # The total number of email link clicks, including repeat clicks by the same recipient.
28
+ attr_accessor :clicked
29
+
30
+ # The number of emails opened at least once.
31
+ attr_accessor :unique_opened
32
+
33
+ # The number of emails with at least one link click.
34
+ attr_accessor :unique_clicked
35
+
36
+ # The number of emails that failed to send.
37
+ attr_accessor :failed
38
+
39
+ # The number of emails that bounced.
40
+ attr_accessor :bounced
41
+
42
+ # The number of emails that recipients reported as spam.
43
+ attr_accessor :complained
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'sent' => :'sent',
49
+ :'delivered' => :'delivered',
50
+ :'opened' => :'opened',
51
+ :'clicked' => :'clicked',
52
+ :'unique_opened' => :'unique_opened',
53
+ :'unique_clicked' => :'unique_clicked',
54
+ :'failed' => :'failed',
55
+ :'bounced' => :'bounced',
56
+ :'complained' => :'complained'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'sent' => :'Integer',
69
+ :'delivered' => :'Integer',
70
+ :'opened' => :'Integer',
71
+ :'clicked' => :'Integer',
72
+ :'unique_opened' => :'Integer',
73
+ :'unique_clicked' => :'Integer',
74
+ :'failed' => :'Integer',
75
+ :'bounced' => :'Integer',
76
+ :'complained' => :'Integer'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailMetrics` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailMetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'sent')
102
+ self.sent = attributes[:'sent']
103
+ end
104
+
105
+ if attributes.key?(:'delivered')
106
+ self.delivered = attributes[:'delivered']
107
+ end
108
+
109
+ if attributes.key?(:'opened')
110
+ self.opened = attributes[:'opened']
111
+ end
112
+
113
+ if attributes.key?(:'clicked')
114
+ self.clicked = attributes[:'clicked']
115
+ end
116
+
117
+ if attributes.key?(:'unique_opened')
118
+ self.unique_opened = attributes[:'unique_opened']
119
+ end
120
+
121
+ if attributes.key?(:'unique_clicked')
122
+ self.unique_clicked = attributes[:'unique_clicked']
123
+ end
124
+
125
+ if attributes.key?(:'failed')
126
+ self.failed = attributes[:'failed']
127
+ end
128
+
129
+ if attributes.key?(:'bounced')
130
+ self.bounced = attributes[:'bounced']
131
+ end
132
+
133
+ if attributes.key?(:'complained')
134
+ self.complained = attributes[:'complained']
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ invalid_properties = Array.new
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ true
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ sent == o.sent &&
157
+ delivered == o.delivered &&
158
+ opened == o.opened &&
159
+ clicked == o.clicked &&
160
+ unique_opened == o.unique_opened &&
161
+ unique_clicked == o.unique_clicked &&
162
+ failed == o.failed &&
163
+ bounced == o.bounced &&
164
+ complained == o.complained
165
+ end
166
+
167
+ # @see the `==` method
168
+ # @param [Object] Object to be compared
169
+ def eql?(o)
170
+ self == o
171
+ end
172
+
173
+ # Calculates hash code according to all attributes.
174
+ # @return [Integer] Hash code
175
+ def hash
176
+ [sent, delivered, opened, clicked, unique_opened, unique_clicked, failed, bounced, complained].hash
177
+ end
178
+
179
+ # Builds the object from hash
180
+ # @param [Hash] attributes Model attributes in the form of hash
181
+ # @return [Object] Returns the model itself
182
+ def self.build_from_hash(attributes)
183
+ new.build_from_hash(attributes)
184
+ end
185
+
186
+ # Builds the object from hash
187
+ # @param [Hash] attributes Model attributes in the form of hash
188
+ # @return [Object] Returns the model itself
189
+ def build_from_hash(attributes)
190
+ return nil unless attributes.is_a?(Hash)
191
+ attributes = attributes.transform_keys(&:to_sym)
192
+ self.class.openapi_types.each_pair do |key, type|
193
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
194
+ self.send("#{key}=", nil)
195
+ elsif type =~ /\AArray<(.*)>/i
196
+ # check to ensure the input is an array given that the attribute
197
+ # is documented as an array but the input is not
198
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
199
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
200
+ end
201
+ elsif !attributes[self.class.attribute_map[key]].nil?
202
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
203
+ end
204
+ end
205
+
206
+ self
207
+ end
208
+
209
+ # Deserializes the data based on type
210
+ # @param string type Data type
211
+ # @param string value Value to be deserialized
212
+ # @return [Object] Deserialized data
213
+ def _deserialize(type, value)
214
+ case type.to_sym
215
+ when :Time
216
+ Time.parse(value)
217
+ when :Date
218
+ Date.parse(value)
219
+ when :String
220
+ value.to_s
221
+ when :Integer
222
+ value.to_i
223
+ when :Float
224
+ value.to_f
225
+ when :Boolean
226
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
227
+ true
228
+ else
229
+ false
230
+ end
231
+ when :Object
232
+ # generic object (usually a Hash), return directly
233
+ value
234
+ when /\AArray<(?<inner_type>.+)>\z/
235
+ inner_type = Regexp.last_match[:inner_type]
236
+ value.map { |v| _deserialize(inner_type, v) }
237
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
238
+ k_type = Regexp.last_match[:k_type]
239
+ v_type = Regexp.last_match[:v_type]
240
+ {}.tap do |hash|
241
+ value.each do |k, v|
242
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
243
+ end
244
+ end
245
+ else # model
246
+ # models (e.g. Pet) or oneOf
247
+ klass = OneSignal.const_get(type)
248
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
249
+ end
250
+ end
251
+
252
+ # Returns the string representation of the object
253
+ # @return [String] String presentation of the object
254
+ def to_s
255
+ to_hash.to_s
256
+ end
257
+
258
+ # to_body is an alias to to_hash (backward compatibility)
259
+ # @return [Hash] Returns the object in the form of hash
260
+ def to_body
261
+ to_hash
262
+ end
263
+
264
+ # Returns the object in the form of hash
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_hash
267
+ hash = {}
268
+ self.class.attribute_map.each_pair do |attr, param|
269
+ value = self.send(attr)
270
+ if value.nil?
271
+ is_nullable = self.class.openapi_nullable.include?(attr)
272
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
273
+ end
274
+
275
+ hash[param] = _to_hash(value)
276
+ end
277
+ hash
278
+ end
279
+
280
+ # Outputs non-array value in the form of hash
281
+ # For object, use to_hash. Otherwise, just return the value
282
+ # @param [Object] value Any valid value
283
+ # @return [Hash] Returns the value in the form of hash
284
+ def _to_hash(value)
285
+ if value.is_a?(Array)
286
+ value.compact.map { |v| _to_hash(v) }
287
+ elsif value.is_a?(Hash)
288
+ {}.tap do |hash|
289
+ value.each { |k, v| hash[k] = _to_hash(v) }
290
+ end
291
+ elsif value.respond_to? :to_hash
292
+ value.to_hash
293
+ else
294
+ value
295
+ end
296
+ end
297
+
298
+ end
299
+
300
+ end