Class: Courier::Bulk::InboundBulkMessageV1

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(brand: nil, data: nil, event: nil, locale: nil, override: nil, additional_properties: nil) ⇒ Bulk::InboundBulkMessageV1

Parameters:

  • brand (String) (defaults to: nil)

    A unique identifier that represents the brand that should be used for rendering the notification.

  • data (Hash{String => String}) (defaults to: nil)

    JSON that includes any data you want to pass to a message template. The data will populate the corresponding template variables.

  • event (String) (defaults to: nil)
  • locale (Hash{String => String}) (defaults to: nil)
  • override (Object) (defaults to: nil)

    JSON that is merged into the request sent by Courier to the provider to override properties or to gain access to features in the provider API that are not natively supported by Courier.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(brand: nil, data: nil, event: nil, locale: nil, override: nil, additional_properties: nil)
  # @type [String] A unique identifier that represents the brand that should be used
  #   for rendering the notification.
  @brand = brand
  # @type [Hash{String => String}] JSON that includes any data you want to pass to a message template.
  #   The data will populate the corresponding template variables.
  @data = data
  # @type [String]
  @event = event
  # @type [Hash{String => String}]
  @locale = locale
  # @type [Object] JSON that is merged into the request sent by Courier to the provider
  #   to override properties or to gain access to features in the provider
  #   API that are not natively supported by Courier.
  @override = override
  # @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.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def additional_properties
  @additional_properties
end

#brandObject (readonly)

Returns the value of attribute brand.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def brand
  @brand
end

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def data
  @data
end

#eventObject (readonly)

Returns the value of attribute event.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def event
  @event
end

#localeObject (readonly)

Returns the value of attribute locale.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def locale
  @locale
end

#overrideObject (readonly)

Returns the value of attribute override.



8
9
10
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 8

def override
  @override
end

Class Method Details

.from_json(json_object:) ⇒ Bulk::InboundBulkMessageV1

Deserialize a JSON object to an instance of InboundBulkMessageV1

Parameters:

  • json_object (JSON)

Returns:



44
45
46
47
48
49
50
51
52
53
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 44

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  brand = struct.brand
  data = struct.data
  event = struct.event
  locale = struct.locale
  override = struct.override
  new(brand: brand, data: data, event: event, locale: locale, override: override, 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)


66
67
68
69
70
71
72
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 66

def self.validate_raw(obj:)
  obj.brand&.is_a?(String) != false || raise("Passed value for field obj.brand is not the expected type, validation failed.")
  obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
  obj.event&.is_a?(String) != false || raise("Passed value for field obj.event is not the expected type, validation failed.")
  obj.locale&.is_a?(Hash) != false || raise("Passed value for field obj.locale is not the expected type, validation failed.")
  obj.override&.is_a?(Object) != false || raise("Passed value for field obj.override is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of InboundBulkMessageV1 to a JSON object

Returns:

  • (JSON)


58
59
60
# File 'lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb', line 58

def to_json(*_args)
  { "brand": @brand, "data": @data, "event": @event, "locale": @locale, "override": @override }.to_json
end