Class: Pinnacle::CarouselRcsMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/carousel_rcs_message.rb

Overview

The content of the message

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cards:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::CarouselRcsMessage

Parameters:

  • cards (Array<Pinnacle::Card>)

    Array of cards to be sent

  • quick_replies (Array<Pinnacle::Action>) (defaults to: OMIT)

    Array of quick replies attached to the card. Maximum of 11 quick replies.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



27
28
29
30
31
32
33
34
# File 'lib/rcs/types/carousel_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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/rcs/types/carousel_rcs_message.rb', line 16

def additional_properties
  @additional_properties
end

#cardsArray<Pinnacle::Card> (readonly)

Returns Array of cards to be sent.

Returns:



12
13
14
# File 'lib/rcs/types/carousel_rcs_message.rb', line 12

def cards
  @cards
end

#quick_repliesArray<Pinnacle::Action> (readonly)

Returns Array of quick replies attached to the card. Maximum of 11 quick replies.

Returns:

  • (Array<Pinnacle::Action>)

    Array of quick replies attached to the card. Maximum of 11 quick replies.



14
15
16
# File 'lib/rcs/types/carousel_rcs_message.rb', line 14

def quick_replies
  @quick_replies
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::CarouselRcsMessage

Deserialize a JSON object to an instance of CarouselRcsMessage

Parameters:

  • json_object (String)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rcs/types/carousel_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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


71
72
73
74
# File 'lib/rcs/types/carousel_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 CarouselRcsMessage to a JSON object

Returns:

  • (String)


61
62
63
# File 'lib/rcs/types/carousel_rcs_message.rb', line 61

def to_json(*_args)
  @_field_set&.to_json
end