Class: Samsara::Types::RecipientObjectRequestBody

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

Overview

Recipient of an Action. One of userId contactId or roleId needs to be set.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contact_id: OMIT, notification_types: OMIT, role_id: OMIT, type:, user_id: OMIT, additional_properties: nil) ⇒ Samsara::Types::RecipientObjectRequestBody



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 36

def initialize(contact_id: OMIT, notification_types: OMIT, role_id: OMIT, type:, user_id: OMIT, additional_properties: nil)
  @contact_id = contact_id if contact_id != OMIT
  @notification_types = notification_types if notification_types != OMIT
  @role_id = role_id if role_id != OMIT
  @type = type
  @user_id = user_id if user_id != OMIT
  @additional_properties = additional_properties
  @_field_set = { "contactId": contact_id, "notificationTypes": notification_types, "roleId": role_id, "type": type, "userId": user_id }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



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

def additional_properties
  @additional_properties
end

#contact_id ⇒ String (readonly)



12
13
14
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 12

def contact_id
  @contact_id
end

#notification_types ⇒ Array<Samsara::Types::RecipientObjectRequestBodyNotificationTypesItem> (readonly)



14
15
16
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 14

def notification_types
  @notification_types
end

#role_id ⇒ String (readonly)



16
17
18
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 16

def role_id
  @role_id
end

#type ⇒ Samsara::Types::RecipientObjectRequestBodyType (readonly)



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

def type
  @type
end

#user_id ⇒ String (readonly)



20
21
22
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 20

def user_id
  @user_id
end

Class Method Details

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



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  contact_id = parsed_json["contactId"]
  notification_types = parsed_json["notificationTypes"]
  role_id = parsed_json["roleId"]
  type = parsed_json["type"]
  user_id = parsed_json["userId"]
  new(
    contact_id: contact_id,
    notification_types: notification_types,
    role_id: role_id,
    type: type,
    user_id: user_id,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



80
81
82
83
84
85
86
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 80

def self.validate_raw(obj:)
  obj.contact_id&.is_a?(String) != false || raise("Passed value for field obj.contact_id is not the expected type, validation failed.")
  obj.notification_types&.is_a?(Array) != false || raise("Passed value for field obj.notification_types is not the expected type, validation failed.")
  obj.role_id&.is_a?(String) != false || raise("Passed value for field obj.role_id is not the expected type, validation failed.")
  obj.type.is_a?(Samsara::Types::RecipientObjectRequestBodyType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String



71
72
73
# File 'lib/samsara_api/types/recipient_object_request_body.rb', line 71

def to_json
  @_field_set&.to_json
end