Class: Courier::Bulk::BulkMessageUserResponse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, message_id: nil, preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil) ⇒ Bulk::BulkMessageUserResponse

Parameters:

  • status (Bulk::BulkJobUserStatus)
  • message_id (String) (defaults to: nil)
  • 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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 22

def initialize(status:, message_id: nil, preferences: nil, profile: nil, recipient: nil, data: nil, to: nil,
               additional_properties: nil)
  # @type [Bulk::BulkJobUserStatus]
  @status = status
  # @type [String]
  @message_id = message_id
  # @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.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def additional_properties
  @additional_properties
end

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def data
  @data
end

#message_idObject (readonly)

Returns the value of attribute message_id.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def message_id
  @message_id
end

#preferencesObject (readonly)

Returns the value of attribute preferences.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def preferences
  @preferences
end

#profileObject (readonly)

Returns the value of attribute profile.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def profile
  @profile
end

#recipientObject (readonly)

Returns the value of attribute recipient.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def recipient
  @recipient
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def status
  @status
end

#toObject (readonly)

Returns the value of attribute to.



11
12
13
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 11

def to
  @to
end

Class Method Details

.from_json(json_object:) ⇒ Bulk::BulkMessageUserResponse

Deserialize a JSON object to an instance of BulkMessageUserResponse

Parameters:

  • json_object (JSON)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 46

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  status = struct.status
  message_id = struct.messageId
  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(status: status, message_id: message_id, 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)


89
90
91
92
93
94
95
96
97
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 89

def self.validate_raw(obj:)
  obj.status.is_a?(Bulk::BulkJobUserStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.message_id&.is_a?(String) != false || raise("Passed value for field obj.message_id is not the expected type, validation failed.")
  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 BulkMessageUserResponse to a JSON object

Returns:

  • (JSON)


73
74
75
76
77
78
79
80
81
82
83
# File 'lib/trycourier/bulk/types/bulk_message_user_response.rb', line 73

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