Class: Pinnacle::CardRcsMessage
- Inherits:
-
Object
- Object
- Pinnacle::CardRcsMessage
- Defined in:
- lib/rcs/types/card_rcs_message.rb
Overview
The content of the message
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#cards ⇒ Array<Pinnacle::Card>
readonly
Array of one containing the card to be sent.
-
#quick_replies ⇒ Array<Pinnacle::Action>
readonly
Array of quick replies attached to the card.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::CardRcsMessage
Deserialize a JSON object to an instance of CardRcsMessage.
-
.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(cards:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::CardRcsMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CardRcsMessage to a JSON object.
Constructor Details
#initialize(cards:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::CardRcsMessage
27 28 29 30 31 32 33 34 |
# File 'lib/rcs/types/card_rcs_message.rb', line 27 def initialize(cards:, quick_replies: OMIT, additional_properties: nil) @cards = cards @quick_replies = quick_replies if quick_replies != OMIT @additional_properties = additional_properties @_field_set = { "cards": cards, "quick_replies": quick_replies }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/rcs/types/card_rcs_message.rb', line 16 def additional_properties @additional_properties end |
#cards ⇒ Array<Pinnacle::Card> (readonly)
Returns Array of one containing the card to be sent.
12 13 14 |
# File 'lib/rcs/types/card_rcs_message.rb', line 12 def cards @cards end |
#quick_replies ⇒ Array<Pinnacle::Action> (readonly)
Returns Array of quick replies attached to the card. Maximum of 11 quick replies.
14 15 16 |
# File 'lib/rcs/types/card_rcs_message.rb', line 14 def quick_replies @quick_replies end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::CardRcsMessage
Deserialize a JSON object to an instance of CardRcsMessage
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rcs/types/card_rcs_message.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) cards = parsed_json["cards"]&.map do |item| item = item.to_json Pinnacle::Card.from_json(json_object: item) end quick_replies = parsed_json["quick_replies"]&.map do |item| item = item.to_json Pinnacle::Action.from_json(json_object: item) end new( cards: cards, quick_replies: quick_replies, 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.
71 72 73 74 |
# File 'lib/rcs/types/card_rcs_message.rb', line 71 def self.validate_raw(obj:) obj.cards.is_a?(Array) != false || raise("Passed value for field obj.cards is not the expected type, validation failed.") obj.quick_replies&.is_a?(Array) != false || raise("Passed value for field obj.quick_replies is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CardRcsMessage to a JSON object
61 62 63 |
# File 'lib/rcs/types/card_rcs_message.rb', line 61 def to_json(*_args) @_field_set&.to_json end |