Class: Courier::Audiences::Audience
- Inherits:
-
Object
- Object
- Courier::Audiences::Audience
- Defined in:
- lib/trycourier/audiences/types/audience.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Audiences::Audience
Deserialize a JSON object to an instance of Audience.
-
.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.
Instance Method Summary collapse
- #initialize(id:, name:, description:, filter:, created_at:, updated_at:, additional_properties: nil) ⇒ Audiences::Audience constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of Audience to a JSON object.
Constructor Details
#initialize(id:, name:, description:, filter:, created_at:, updated_at:, additional_properties: nil) ⇒ Audiences::Audience
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/trycourier/audiences/types/audience.rb', line 19 def initialize(id:, name:, description:, filter:, created_at:, updated_at:, additional_properties: nil) # @type [String] A unique identifier representing the audience_id @id = id # @type [String] The name of the audience @name = name # @type [String] A description of the audience @description = description # @type [Audiences::Filter] @filter = filter # @type [String] @created_at = created_at # @type [String] @updated_at = updated_at # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def additional_properties @additional_properties end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def description @description end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def filter @filter end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def name @name end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
9 10 11 |
# File 'lib/trycourier/audiences/types/audience.rb', line 9 def updated_at @updated_at end |
Class Method Details
.from_json(json_object:) ⇒ Audiences::Audience
Deserialize a JSON object to an instance of Audience
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/trycourier/audiences/types/audience.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id name = struct.name description = struct.description if parsed_json["filter"].nil? filter = nil else filter = parsed_json["filter"].to_json filter = Audiences::Filter.from_json(json_object: filter) end created_at = struct.created_at updated_at = struct.updated_at new(id: id, name: name, description: description, filter: filter, created_at: created_at, updated_at: updated_at, 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.
76 77 78 79 80 81 82 83 |
# File 'lib/trycourier/audiences/types/audience.rb', line 76 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") Audiences::Filter.validate_raw(obj: obj.filter) obj.created_at.is_a?(String) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.updated_at.is_a?(String) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of Audience to a JSON object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/trycourier/audiences/types/audience.rb', line 61 def to_json(*_args) { "id": @id, "name": @name, "description": @description, "filter": @filter, "created_at": @created_at, "updated_at": @updated_at }.to_json end |