Class: Courier::Send::IProfilePreferences

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notifications:, categories: nil, template_id: nil, additional_properties: nil) ⇒ Send::IProfilePreferences

Parameters:

  • categories (Send::I_PREFERENCES) (defaults to: nil)
  • notifications (Send::I_PREFERENCES)
  • template_id (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



16
17
18
19
20
21
22
23
24
25
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 16

def initialize(notifications:, categories: nil, template_id: nil, additional_properties: nil)
  # @type [Send::I_PREFERENCES]
  @categories = categories
  # @type [Send::I_PREFERENCES]
  @notifications = notifications
  # @type [String]
  @template_id = template_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.



9
10
11
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 9

def additional_properties
  @additional_properties
end

#categoriesObject (readonly)

Returns the value of attribute categories.



9
10
11
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 9

def categories
  @categories
end

#notificationsObject (readonly)

Returns the value of attribute notifications.



9
10
11
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 9

def notifications
  @notifications
end

#template_idObject (readonly)

Returns the value of attribute template_id.



9
10
11
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 9

def template_id
  @template_id
end

Class Method Details

.from_json(json_object:) ⇒ Send::IProfilePreferences

Deserialize a JSON object to an instance of IProfilePreferences

Parameters:

  • json_object (JSON)

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 31

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  categories = struct.categories
  notifications = struct.notifications
  template_id = struct.templateId
  new(categories: categories, notifications: notifications, template_id: template_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)


52
53
54
55
56
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 52

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

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of IProfilePreferences to a JSON object

Returns:

  • (JSON)


44
45
46
# File 'lib/trycourier/send/types/i_profile_preferences.rb', line 44

def to_json(*_args)
  { "categories": @categories, "notifications": @notifications, "templateId": @template_id }.to_json
end