Class: Courier::Bulk::InboundBulkMessageUser

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/bulk/types/inbound_bulk_message_user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil) ⇒ Bulk::InboundBulkMessageUser

Parameters:

  • preferences (Commons::RecipientPreferences) (defaults to: nil)
  • profile (Object) (defaults to: nil)
  • recipient (String) (defaults to: nil)
  • data (Object) (defaults to: nil)
  • to (Send::UserRecipient) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 19

def initialize(preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil)
  # @type [Commons::RecipientPreferences]
  @preferences = preferences
  # @type [Object]
  @profile = profile
  # @type [String]
  @recipient = recipient
  # @type [Object]
  @data = data
  # @type [Send::UserRecipient]
  @to = to
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def additional_properties
  @additional_properties
end

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def data
  @data
end

#preferencesObject (readonly)

Returns the value of attribute preferences.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def preferences
  @preferences
end

#profileObject (readonly)

Returns the value of attribute profile.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def profile
  @profile
end

#recipientObject (readonly)

Returns the value of attribute recipient.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def recipient
  @recipient
end

#toObject (readonly)

Returns the value of attribute to.



10
11
12
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10

def to
  @to
end

Class Method Details

.from_json(json_object:) ⇒ Bulk::InboundBulkMessageUser

Deserialize a JSON object to an instance of InboundBulkMessageUser

Parameters:

  • json_object (JSON)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 38

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["preferences"].nil?
    preferences = nil
  else
    preferences = parsed_json["preferences"].to_json
    preferences = Commons::RecipientPreferences.from_json(json_object: preferences)
  end
  profile = struct.profile
  recipient = struct.recipient
  data = struct.data
  if parsed_json["to"].nil?
    to = nil
  else
    to = parsed_json["to"].to_json
    to = Send::UserRecipient.from_json(json_object: to)
  end
  new(preferences: preferences, profile: profile, recipient: recipient, data: data, to: to,
      additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


71
72
73
74
75
76
77
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 71

def self.validate_raw(obj:)
  obj.preferences.nil? || Commons::RecipientPreferences.validate_raw(obj: obj.preferences)
  obj.profile&.is_a?(Object) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.")
  obj.recipient&.is_a?(String) != false || raise("Passed value for field obj.recipient is not the expected type, validation failed.")
  obj.data&.is_a?(Object) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
  obj.to.nil? || Send::UserRecipient.validate_raw(obj: obj.to)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of InboundBulkMessageUser to a JSON object

Returns:

  • (JSON)


63
64
65
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 63

def to_json(*_args)
  { "preferences": @preferences, "profile": @profile, "recipient": @recipient, "data": @data, "to": @to }.to_json
end