Class: Samsara::Types::RecipientObjectResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/recipient_object_response_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::RecipientObjectResponseBody

Parameters:

  • contact_id (String) (defaults to: OMIT)

    The ID of the contact.

  • notification_types (Array<Samsara::Types::RecipientObjectResponseBodyNotificationTypesItem>) (defaults to: OMIT)

    How the user/contact/role should be notified.

  • role_id (String) (defaults to: OMIT)

    The ID of the role.

  • type (Samsara::Types::RecipientObjectResponseBodyType)

    The type of recipients Valid values: ‘user`, `contact`, `role`

  • user_id (String) (defaults to: OMIT)

    The ID of the user.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/samsara_api/types/recipient_object_response_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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#contact_idString (readonly)

Returns The ID of the contact.

Returns:

  • (String)

    The ID of the contact.



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

def contact_id
  @contact_id
end

#notification_typesArray<Samsara::Types::RecipientObjectResponseBodyNotificationTypesItem> (readonly)

Returns How the user/contact/role should be notified.

Returns:



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

def notification_types
  @notification_types
end

#role_idString (readonly)

Returns The ID of the role.

Returns:

  • (String)

    The ID of the role.



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

def role_id
  @role_id
end

#typeSamsara::Types::RecipientObjectResponseBodyType (readonly)

Returns The type of recipients Valid values: ‘user`, `contact`, `role`.

Returns:



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

def type
  @type
end

#user_idString (readonly)

Returns The ID of the user.

Returns:

  • (String)

    The ID of the user.



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

def user_id
  @user_id
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/samsara_api/types/recipient_object_response_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

Parameters:

  • obj (Object)

Returns:

  • (Void)


80
81
82
83
84
85
86
# File 'lib/samsara_api/types/recipient_object_response_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::RecipientObjectResponseBodyType) != 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_jsonString

Returns:

  • (String)


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

def to_json
  @_field_set&.to_json
end