Class: Algolia::InsightsClient
- Inherits:
-
Object
- Object
- Algolia::InsightsClient
- Defined in:
- lib/algolia/api/insights_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Class Method Summary collapse
Instance Method Summary collapse
-
#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API.
-
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API.
-
#custom_get(path, parameters = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API.
-
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API.
-
#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API.
-
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API.
-
#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API.
-
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API.
-
#delete_user_token(user_token, request_options = {}) ⇒ nil
Delete user token.
-
#delete_user_token_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Delete user token.
-
#initialize(config = nil) ⇒ InsightsClient
constructor
A new instance of InsightsClient.
-
#push_events(insights_events, request_options = {}) ⇒ EventsResponse
Send events.
-
#push_events_with_http_info(insights_events, request_options = {}) ⇒ Http::Response
Send events.
Constructor Details
#initialize(config = nil) ⇒ InsightsClient
Returns a new instance of InsightsClient.
7 8 9 10 11 12 13 |
# File 'lib/algolia/api/insights_client.rb', line 7 def initialize(config = nil) raise '`config` is missing.' if config.nil? raise '`app_id` is missing.' if config.app_id.nil? || config.app_id == '' raise '`api_key` is missing.' if config.api_key.nil? || config.api_key == '' @api_client = Algolia::ApiClient.new(config) end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
5 6 7 |
# File 'lib/algolia/api/insights_client.rb', line 5 def api_client @api_client end |
Class Method Details
.create(app_id, api_key, region = nil, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/algolia/api/insights_client.rb', line 15 def self.create(app_id, api_key, region = nil, opts = {}) hosts = [] regions = ['de', 'us'] if region.is_a?(Hash) && (opts.nil? || opts.empty?) opts = region region = nil end raise "`region` must be one of the following: #{regions.join(', ')}" if !region.nil? && (!region.is_a?(String) || !regions.include?(region)) hosts << Transport::StatefulHost.new(region.nil? ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.sub!('{region}', region), accept: CallType::READ | CallType::WRITE) config = Algolia::Configuration.new(app_id, api_key, hosts, 'Insights', opts) create_with_config(config) end |
.create_with_config(config) ⇒ Object
32 33 34 |
# File 'lib/algolia/api/insights_client.rb', line 32 def self.create_with_config(config) new(config) end |
Instance Method Details
#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
74 75 76 77 |
# File 'lib/algolia/api/insights_client.rb', line 74 def custom_delete(path, parameters = nil, = {}) response = custom_delete_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || 'Object') end |
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/algolia/api/insights_client.rb', line 42 def custom_delete_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_delete`." end path = '/1{path}'.sub('{' + 'path' + '}', path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :'InsightsClient.custom_delete', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:DELETE, path, ) end |
#custom_get(path, parameters = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
117 118 119 120 |
# File 'lib/algolia/api/insights_client.rb', line 117 def custom_get(path, parameters = nil, = {}) response = custom_get_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || 'Object') end |
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/algolia/api/insights_client.rb', line 85 def custom_get_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_get`." end path = '/1{path}'.sub('{' + 'path' + '}', path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :'InsightsClient.custom_get', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
162 163 164 165 |
# File 'lib/algolia/api/insights_client.rb', line 162 def custom_post(path, parameters = nil, body = nil, = {}) response = custom_post_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || 'Object') end |
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/algolia/api/insights_client.rb', line 129 def custom_post_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_post`." end path = '/1{path}'.sub('{' + 'path' + '}', path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :'InsightsClient.custom_post', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:POST, path, ) end |
#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
207 208 209 210 |
# File 'lib/algolia/api/insights_client.rb', line 207 def custom_put(path, parameters = nil, body = nil, = {}) response = custom_put_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || 'Object') end |
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Send requests to the Algolia REST API. This method allow you to send requests to the Algolia REST API.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/algolia/api/insights_client.rb', line 174 def custom_put_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_put`." end path = '/1{path}'.sub('{' + 'path' + '}', path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :'InsightsClient.custom_put', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:PUT, path, ) end |
#delete_user_token(user_token, request_options = {}) ⇒ nil
Delete user token. Delete all events related to a certain user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
259 260 261 262 |
# File 'lib/algolia/api/insights_client.rb', line 259 def delete_user_token(user_token, = {}) delete_user_token_with_http_info(user_token, ) nil end |
#delete_user_token_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Delete user token. Delete all events related to a certain user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/algolia/api/insights_client.rb', line 217 def delete_user_token_with_http_info(user_token, = {}) # verify the required parameter 'user_token' is set if @api_client.config.client_side_validation && user_token.nil? raise ArgumentError, "Parameter `user_token` is required when calling `delete_user_token`." end if @api_client.config.client_side_validation && user_token.to_s.length > 129 raise ArgumentError, 'invalid value for "user_token" when calling InsightsClient.delete_user_token, the character length must be smaller than or equal to 129.' end if @api_client.config.client_side_validation && user_token.to_s.length < 1 raise ArgumentError, 'invalid value for "user_token" when calling InsightsClient.delete_user_token, the character length must be great than or equal to 1.' end pattern = %r{[a-zA-Z0-9_=/+]{1,129}} if @api_client.config.client_side_validation && user_token !~ pattern raise ArgumentError, "invalid value for 'user_token' when calling InsightsClient.delete_user_token, must conform to the pattern #{pattern}." end path = '/1/usertokens/{userToken}'.sub('{' + 'userToken' + '}', @api_client.encode_uri(user_token.to_s)) query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :'InsightsClient.delete_user_token', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:DELETE, path, ) end |
#push_events(insights_events, request_options = {}) ⇒ EventsResponse
Send events. Send a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
299 300 301 302 |
# File 'lib/algolia/api/insights_client.rb', line 299 def push_events(insights_events, = {}) response = push_events_with_http_info(insights_events, ) @api_client.deserialize(response.body, [:debug_return_type] || 'Insights::EventsResponse') end |
#push_events_with_http_info(insights_events, request_options = {}) ⇒ Http::Response
Send events. Send a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/algolia/api/insights_client.rb', line 269 def push_events_with_http_info(insights_events, = {}) # verify the required parameter 'insights_events' is set if @api_client.config.client_side_validation && insights_events.nil? raise ArgumentError, "Parameter `insights_events` is required when calling `push_events`." end path = '/1/events' query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(insights_events) = .merge( :operation => :'InsightsClient.push_events', :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:POST, path, ) end |