Class: Samsara::AsyncWebhooksClient
- Inherits:
-
Object
- Object
- Samsara::AsyncWebhooksClient
- Defined in:
- lib/samsara_api/webhooks/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(custom_headers: nil, event_types: nil, name:, url:, version: nil, request_options: nil) ⇒ Object
api.webhooks.create(name: "Webhook-123", url: "https://www.Webhook-123.com/webhook/listener").
-
#delete(id:, request_options: nil) ⇒ Object
api.webhooks.delete(id: "id").
-
#get(id:, request_options: nil) ⇒ Object
api.webhooks.get(id: "id").
- #initialize(request_client:) ⇒ Samsara::AsyncWebhooksClient constructor
-
#list(ids: nil, limit: nil, after: nil, request_options: nil) ⇒ Object
api.webhooks.list.
-
#patch(id:, custom_headers: nil, name: nil, url: nil, version: nil, request_options: nil) ⇒ Object
api.webhooks.patch(id: "id").
Constructor Details
#initialize(request_client:) ⇒ Samsara::AsyncWebhooksClient
284 285 286 |
# File 'lib/samsara_api/webhooks/client.rb', line 284 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Samsara::AsyncRequestClient (readonly)
279 280 281 |
# File 'lib/samsara_api/webhooks/client.rb', line 279 def request_client @request_client end |
Instance Method Details
#create(custom_headers: nil, event_types: nil, name:, url:, version: nil, request_options: nil) ⇒ Object
api.webhooks.create(name: "Webhook-123", url: "https://www.Webhook-123.com/webhook/listener")
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/samsara_api/webhooks/client.rb', line 373 def create(custom_headers: nil, event_types: nil, name:, url:, version: nil, request_options: nil) Async do response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), customHeaders: custom_headers, eventTypes: event_types, name: name, url: url, version: version }.compact req.url "#{@request_client.get_url(request_options: request_options)}/webhooks" end Samsara::Types::WebhooksPostWebhooksResponseBody.from_json(json_object: response.body) end end |
#delete(id:, request_options: nil) ⇒ Object
api.webhooks.delete(id: "id")
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/samsara_api/webhooks/client.rb', line 463 def delete(id:, request_options: nil) Async do response = @request_client.conn.delete do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: request_options)}/webhooks/#{id}" end end end |
#get(id:, request_options: nil) ⇒ Object
api.webhooks.get(id: "id")
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/samsara_api/webhooks/client.rb', line 417 def get(id:, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: request_options)}/webhooks/#{id}" end Samsara::Types::WebhooksGetWebhookResponseBody.from_json(json_object: response.body) end end |
#list(ids: nil, limit: nil, after: nil, request_options: nil) ⇒ Object
api.webhooks.list
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/samsara_api/webhooks/client.rb', line 318 def list(ids: nil, limit: nil, after: nil, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "ids": ids, "limit": limit, "after": after }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: request_options)}/webhooks" end Samsara::Types::WebhooksListWebhooksResponseBody.from_json(json_object: response.body) end end |
#patch(id:, custom_headers: nil, name: nil, url: nil, version: nil, request_options: nil) ⇒ Object
api.webhooks.patch(id: "id")
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/samsara_api/webhooks/client.rb', line 525 def patch(id:, custom_headers: nil, name: nil, url: nil, version: nil, request_options: nil) Async do response = @request_client.conn.patch do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), customHeaders: custom_headers, name: name, url: url, version: version }.compact req.url "#{@request_client.get_url(request_options: request_options)}/webhooks/#{id}" end Samsara::Types::WebhooksPatchWebhookResponseBody.from_json(json_object: response.body) end end |