Class: Courier::Bulk::InboundBulkContentMessage

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

Overview

The message property has the following primary top-level properties. They define the destination and content of the message. Additional advanced configuration fields [are defined below](www.courier.com/docs/reference/send/message/#other-message-properties).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) ⇒ Bulk::InboundBulkContentMessage

Parameters:

  • content (Send::Content)

    Describes the content of the message in a way that will work for email, push, chat, or any channel. Either this or template must be specified.

  • data (Send::MESSAGE_DATA) (defaults to: nil)

    An arbitrary object that includes any data you want to pass to the message. The data will populate the corresponding template or elements variables.

  • brand_id (String) (defaults to: nil)
  • channels (Send::MESSAGE_CHANNELS) (defaults to: nil)

    “Define run-time configuration for one or more channels. If you don’t specify channels, the default configuration for each channel will be used. Valid ChannelId’s are: email, sms, push, inbox, direct_message, banner, and webhook.”

  • context (Send::MessageContext) (defaults to: nil)

    Context to load with this recipient. Will override any context set on message.context.

  • metadata (Send::MessageMetadata) (defaults to: nil)

    Metadata such as utm tracking attached with the notification through this channel.

  • providers (Send::MESSAGE_PROVIDERS) (defaults to: nil)

    An object whose keys are valid provider identifiers which map to an object.

  • routing (Send::Routing) (defaults to: nil)
  • timeout (Send::Timeout) (defaults to: nil)

    Time in ms to attempt the channel before failing over to the next available channel.

  • delay (Send::Delay) (defaults to: nil)

    Defines the time to wait before delivering the message.

  • expiry (Send::Expiry) (defaults to: nil)

    “Expiry allows you to set an absolute or relative time in which a message expires. Note: This is only valid for the Courier Inbox channel as of 12-08-2022.”

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



39
40
41
42
43
44
45
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/inbound_bulk_content_message.rb', line 39

def initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil,
               routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil)
  # @type [Send::Content] Describes the content of the message in a way that will work for email, push,
  #   chat, or any channel. Either this or template must be specified.
  @content = content
  # @type [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message.
  #   The data will populate the corresponding template or elements variables.
  @data = data
  # @type [String]
  @brand_id = brand_id
  # @type [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."
  @channels = channels
  # @type [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context.
  @context = context
  # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel.
  @metadata = 
  # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object.
  @providers = providers
  # @type [Send::Routing]
  @routing = routing
  # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel.
  @timeout = timeout
  # @type [Send::Delay] Defines the time to wait before delivering the message.
  @delay = delay
  # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires.
  #   Note: This is only valid for the Courier Inbox channel as of 12-08-2022."
  @expiry = expiry
  # @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.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def additional_properties
  @additional_properties
end

#brand_idObject (readonly)

Returns the value of attribute brand_id.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def brand_id
  @brand_id
end

#channelsObject (readonly)

Returns the value of attribute channels.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def channels
  @channels
end

#contentObject (readonly)

Returns the value of attribute content.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def content
  @content
end

#contextObject (readonly)

Returns the value of attribute context.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def context
  @context
end

#dataObject (readonly)

Returns the value of attribute data.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def data
  @data
end

#delayObject (readonly)

Returns the value of attribute delay.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def delay
  @delay
end

#expiryObject (readonly)

Returns the value of attribute expiry.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def expiry
  @expiry
end

#metadataObject (readonly)

Returns the value of attribute metadata.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def 
  @metadata
end

#providersObject (readonly)

Returns the value of attribute providers.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def providers
  @providers
end

#routingObject (readonly)

Returns the value of attribute routing.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def routing
  @routing
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



20
21
22
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 20

def timeout
  @timeout
end

Class Method Details

.from_json(json_object:) ⇒ Bulk::InboundBulkContentMessage

Deserialize a JSON object to an instance of InboundBulkContentMessage

Parameters:

  • json_object (JSON)

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 74

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["content"].nil?
    content = nil
  else
    content = parsed_json["content"].to_json
    content = Send::Content.from_json(json_object: content)
  end
  data = struct.data
  brand_id = struct.brand_id
  channels = struct.channels
  if parsed_json["context"].nil?
    context = nil
  else
    context = parsed_json["context"].to_json
    context = Send::MessageContext.from_json(json_object: context)
  end
  if parsed_json["metadata"].nil?
     = nil
  else
     = parsed_json["metadata"].to_json
     = Send::MessageMetadata.from_json(json_object: )
  end
  providers = struct.providers
  if parsed_json["routing"].nil?
    routing = nil
  else
    routing = parsed_json["routing"].to_json
    routing = Send::Routing.from_json(json_object: routing)
  end
  if parsed_json["timeout"].nil?
    timeout = nil
  else
    timeout = parsed_json["timeout"].to_json
    timeout = Send::Timeout.from_json(json_object: timeout)
  end
  if parsed_json["delay"].nil?
    delay = nil
  else
    delay = parsed_json["delay"].to_json
    delay = Send::Delay.from_json(json_object: delay)
  end
  if parsed_json["expiry"].nil?
    expiry = nil
  else
    expiry = parsed_json["expiry"].to_json
    expiry = Send::Expiry.from_json(json_object: expiry)
  end
  new(content: content, data: data, brand_id: brand_id, channels: channels, context: context, metadata: ,
      providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, 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)


150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 150

def self.validate_raw(obj:)
  Send::Content.validate_raw(obj: obj.content)
  obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
  obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.")
  obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.")
  obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context)
  obj..nil? || Send::MessageMetadata.validate_raw(obj: obj.)
  obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.")
  obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing)
  obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout)
  obj.delay.nil? || Send::Delay.validate_raw(obj: obj.delay)
  obj.expiry.nil? || Send::Expiry.validate_raw(obj: obj.expiry)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of InboundBulkContentMessage to a JSON object

Returns:

  • (JSON)


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/trycourier/bulk/types/inbound_bulk_content_message.rb', line 130

def to_json(*_args)
  {
    "content": @content,
    "data": @data,
    "brand_id": @brand_id,
    "channels": @channels,
    "context": @context,
    "metadata": @metadata,
    "providers": @providers,
    "routing": @routing,
    "timeout": @timeout,
    "delay": @delay,
    "expiry": @expiry
  }.to_json
end