Class: Courier::SendMessageResponse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_id:, additional_properties: nil) ⇒ SendMessageResponse

Parameters:

  • request_id (String)

    A successful call to ‘POST /send` returns a `202` status code along with a `requestId` in the response body. For send requests that have a single recipient, the `requestId` is assigned to the derived message as its message_id. Therefore the `requestId` can be supplied to the Message’s API for single recipient messages. For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier assigns a unique id to each derived message as its ‘message_id`. Therefore the `requestId` cannot be supplied to the Message’s API for single-recipient messages.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



14
15
16
17
18
19
20
21
# File 'lib/trycourier/types/send_message_response.rb', line 14

def initialize(request_id:, additional_properties: nil)
  # @type [String] A successful call to `POST /send` returns a `202` status code along with a `requestId` in the response body.
  #   For send requests that have a single recipient, the `requestId` is assigned to the derived message as its message_id. Therefore the `requestId` can be supplied to the Message's API for single recipient messages.
  #   For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier assigns a unique id to each derived message as its `message_id`. Therefore the `requestId` cannot be supplied to the Message's API for single-recipient messages.
  @request_id = request_id
  # @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.



7
8
9
# File 'lib/trycourier/types/send_message_response.rb', line 7

def additional_properties
  @additional_properties
end

#request_idObject (readonly)

Returns the value of attribute request_id.



7
8
9
# File 'lib/trycourier/types/send_message_response.rb', line 7

def request_id
  @request_id
end

Class Method Details

.from_json(json_object:) ⇒ SendMessageResponse

Deserialize a JSON object to an instance of SendMessageResponse

Parameters:

  • json_object (JSON)

Returns:



27
28
29
30
31
32
# File 'lib/trycourier/types/send_message_response.rb', line 27

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  request_id = struct.requestId
  new(request_id: request_id, 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)


45
46
47
# File 'lib/trycourier/types/send_message_response.rb', line 45

def self.validate_raw(obj:)
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of SendMessageResponse to a JSON object

Returns:

  • (JSON)


37
38
39
# File 'lib/trycourier/types/send_message_response.rb', line 37

def to_json(*_args)
  { "requestId": @request_id }.to_json
end