Class: Courier::Profiles::AirshipProfile
- Inherits:
-
Object
- Object
- Courier::Profiles::AirshipProfile
- Defined in:
- lib/trycourier/profiles/types/airship_profile.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#device_types ⇒ Object
readonly
Returns the value of attribute device_types.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Profiles::AirshipProfile
Deserialize a JSON object to an instance of AirshipProfile.
-
.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(audience:, device_types:, additional_properties: nil) ⇒ Profiles::AirshipProfile constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of AirshipProfile to a JSON object.
Constructor Details
#initialize(audience:, device_types:, additional_properties: nil) ⇒ Profiles::AirshipProfile
16 17 18 19 20 21 22 23 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 16 def initialize(audience:, device_types:, additional_properties: nil) # @type [Profiles::AirshipProfileAudience] @audience = audience # @type [Array<Profiles::DEVICE_TYPE>] @device_types = device_types # @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.
10 11 12 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 10 def additional_properties @additional_properties end |
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
10 11 12 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 10 def audience @audience end |
#device_types ⇒ Object (readonly)
Returns the value of attribute device_types.
10 11 12 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 10 def device_types @device_types end |
Class Method Details
.from_json(json_object:) ⇒ Profiles::AirshipProfile
Deserialize a JSON object to an instance of AirshipProfile
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 29 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["audience"].nil? audience = nil else audience = parsed_json["audience"].to_json audience = Profiles::AirshipProfileAudience.from_json(json_object: audience) end device_types = struct.device_types new(audience: audience, device_types: device_types, 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.
53 54 55 56 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 53 def self.validate_raw(obj:) Profiles::AirshipProfileAudience.validate_raw(obj: obj.audience) obj.device_types.is_a?(Array) != false || raise("Passed value for field obj.device_types is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of AirshipProfile to a JSON object
45 46 47 |
# File 'lib/trycourier/profiles/types/airship_profile.rb', line 45 def to_json(*_args) { "audience": @audience, "device_types": @device_types }.to_json end |