Class: FlowChat::Config::WhatsappConfig
- Inherits:
-
Object
- Object
- FlowChat::Config::WhatsappConfig
- Defined in:
- lib/flow_chat/config.rb
Defined Under Namespace
Classes: LADDER_LIMITS_SHAPE
Instance Attribute Summary collapse
-
#api_base_url ⇒ Object
api_base_url is writable, unlike the limits beside it.
-
#max_buttons ⇒ Object
readonly
Returns the value of attribute max_buttons.
-
#max_list_rows ⇒ Object
readonly
Returns the value of attribute max_list_rows.
Instance Method Summary collapse
-
#initialize ⇒ WhatsappConfig
constructor
A new instance of WhatsappConfig.
-
#ladder_limits ⇒ Object
Bridges max_buttons/max_list_rows to the shape FlowChat::Meta::ChoiceLadder expects, so the renderer and the choice mapper can both ask it which rung a count lands on instead of each re-deriving the same two-threshold comparison independently.
Constructor Details
#initialize ⇒ WhatsappConfig
Returns a new instance of WhatsappConfig.
121 122 123 124 125 126 127 |
# File 'lib/flow_chat/config.rb', line 121 def initialize @api_base_url = "https://graph.facebook.com/v23.0" # Meta: "You cannot have more than 3 buttons in an interactive message." @max_buttons = 3 # Meta: "up to 10 sections, with up to 10 rows for all sections combined". @max_list_rows = 10 end |
Instance Attribute Details
#api_base_url ⇒ Object
api_base_url is writable, unlike the limits beside it. Those are facts about the platform that an application cannot change by disagreeing. The version in the host is a choice, and one an application has to be able to make: Meta retires a version roughly every two years and pins the webhook payloads it sends to whatever the app's dashboard says, so an application straddling two versions must be able to close the gap without waiting for a release here.
118 119 120 |
# File 'lib/flow_chat/config.rb', line 118 def api_base_url @api_base_url end |
#max_buttons ⇒ Object (readonly)
Returns the value of attribute max_buttons.
119 120 121 |
# File 'lib/flow_chat/config.rb', line 119 def @max_buttons end |
#max_list_rows ⇒ Object (readonly)
Returns the value of attribute max_list_rows.
119 120 121 |
# File 'lib/flow_chat/config.rb', line 119 def max_list_rows @max_list_rows end |
Instance Method Details
#ladder_limits ⇒ Object
Bridges max_buttons/max_list_rows to the shape FlowChat::Meta::ChoiceLadder expects, so the renderer and the choice mapper can both ask it which rung a count lands on instead of each re-deriving the same two-threshold comparison independently.
WhatsApp's list has no further structure the way Messenger's carousel has elements and buttons per element - it is just a flat row cap - so it is modelled as a single element holding every row (max_buttons_per_element: 1) purely to fit ChoiceLadder's carousel_capacity formula (elements * buttons_per_element). That shape stays private to this adapter rather than becoming max_buttons/max_list_rows' own public meaning, since "carousel" and "buttons per element" describe nothing WhatsApp actually has.
142 143 144 |
# File 'lib/flow_chat/config.rb', line 142 def ladder_limits LADDER_LIMITS_SHAPE.new(, max_list_rows, 1) end |