Class: Samsara::Types::WebhookResponseResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/webhook_response_response_body.rb

Overview

The response for POST/GET/PATCH a webhook

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_headers: OMIT, event_types: OMIT, id:, name:, secret_key:, url:, version:, additional_properties: nil) ⇒ Samsara::Types::WebhookResponseResponseBody

Parameters:

  • version (Samsara::Types::WebhookResponseResponseBodyVersion)

    The version of the webhook. Valid values: ‘2018-01-01`, `2021-06-09`

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 55

def initialize(custom_headers: OMIT, event_types: OMIT, id:, name:, secret_key:, url:, version:, additional_properties: nil)
  @custom_headers = custom_headers if custom_headers != OMIT
  @event_types = event_types if event_types != OMIT
  @id = id
  @name = name
  @secret_key = secret_key
  @url = url
  @version = version
  @additional_properties = additional_properties
  @_field_set = { "customHeaders": custom_headers, "eventTypes": event_types, "id": id, "name": name, "secretKey": secret_key, "url": url, "version": version }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



33
34
35
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 33

def additional_properties
  @additional_properties
end

#custom_headersArray<Samsara::Types::CustomHeadersObjectResponseBody> (readonly)

Returns The list of custom headers that users can include with their request.

Returns:



13
14
15
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 13

def custom_headers
  @custom_headers
end

#event_typesArray<Samsara::Types::WebhookResponseResponseBodyEventTypesItem> (readonly)

Returns The list of event types associated with a particular webhook.

Returns:



15
16
17
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 15

def event_types
  @event_types
end

#idObject (readonly)

the API. This is the id of the webhook. This is system generated.



18
19
20
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 18

def id
  @id
end

#nameObject (readonly)

API at any time.



22
23
24
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 22

def name
  @name
end

#secret_keyObject (readonly)

dashboard and the API.



25
26
27
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 25

def secret_key
  @secret_key
end

#urlObject (readonly)

API at any time.



29
30
31
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 29

def url
  @url
end

#versionSamsara::Types::WebhookResponseResponseBodyVersion (readonly)

Returns The version of the webhook. Valid values: ‘2018-01-01`, `2021-06-09`.

Returns:



31
32
33
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 31

def version
  @version
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::WebhookResponseResponseBody

Parameters:

  • json_object (String)

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 72

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  custom_headers = parsed_json["customHeaders"]&.map do | item |
  item = item.to_json
  Samsara::Types::CustomHeadersObjectResponseBody.from_json(json_object: item)
end
  event_types = parsed_json["eventTypes"]
  id = parsed_json["id"]
  name = parsed_json["name"]
  secret_key = parsed_json["secretKey"]
  url = parsed_json["url"]
  version = parsed_json["version"]
  new(
    custom_headers: custom_headers,
    event_types: event_types,
    id: id,
    name: name,
    secret_key: secret_key,
    url: url,
    version: version,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


108
109
110
111
112
113
114
115
116
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 108

def self.validate_raw(obj:)
  obj.custom_headers&.is_a?(Array) != false || raise("Passed value for field obj.custom_headers is not the expected type, validation failed.")
  obj.event_types&.is_a?(Array) != false || raise("Passed value for field obj.event_types is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.secret_key.is_a?(String) != false || raise("Passed value for field obj.secret_key is not the expected type, validation failed.")
  obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
  obj.version.is_a?(Samsara::Types::WebhookResponseResponseBodyVersion) != false || raise("Passed value for field obj.version is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


99
100
101
# File 'lib/samsara_api/types/webhook_response_response_body.rb', line 99

def to_json
  @_field_set&.to_json
end