Class: Whatsapp::MessageTemplates::Response::Node
- Inherits:
-
Object
- Object
- Whatsapp::MessageTemplates::Response::Node
- Defined in:
- lib/ruby/whatsapp/message_templates/response/node.rb
Overview
A full template as Meta returns it, from reading one template or from each element of a list.
components is deliberately left as raw hashes rather than rebuilt into the
Component classes. Those classes validate a payload being written, whereas
this is Meta's own echo of it: it carries fields the write side does not model,
and running write-side rules over data we did not author would raise on
perfectly valid responses. Read it as data; build a new Template when you want
to change something.
Source: https://developers.facebook.com/docs/graph-api/reference/whats-app-business-hsm/
Instance Attribute Summary collapse
- #category ⇒ String?
-
#components ⇒ Array<Hash>
Raw component hashes — see the class comment.
-
#correct_category ⇒ String?
The category Meta believes this should be.
- #cta_url_link_tracking_opted_out ⇒ Boolean?
- #id ⇒ String?
- #language ⇒ String?
-
#library_template_name ⇒ String?
Set when the template was cloned from the library.
- #message_send_ttl_seconds ⇒ Integer?
- #name ⇒ String?
- #parameter_format ⇒ String?
-
#previous_category ⇒ String?
Set after an automatic recategorisation.
- #quality_score ⇒ QualityScore?
-
#rejected_reason ⇒ String?
One of Statuses::RejectedReasons::ALL.
-
#status ⇒ String?
One of Statuses::ALL.
- #sub_category ⇒ String?
Class Method Summary collapse
Instance Method Summary collapse
-
#approved? ⇒ Boolean
Whether the template can currently be sent.
-
#editable? ⇒ Boolean
Whether Whatsapp::MessageTemplates#update would be accepted for this template.
-
#initialize(id: nil, name: nil, status: nil, category: nil, language: nil, components: [], parameter_format: nil, sub_category: nil, rejected_reason: nil, quality_score: nil, previous_category: nil, correct_category: nil, message_send_ttl_seconds: nil, cta_url_link_tracking_opted_out: nil, library_template_name: nil) ⇒ Node
constructor
A new instance of Node.
- #paused? ⇒ Boolean
- #rejected? ⇒ Boolean
Constructor Details
#initialize(id: nil, name: nil, status: nil, category: nil, language: nil, components: [], parameter_format: nil, sub_category: nil, rejected_reason: nil, quality_score: nil, previous_category: nil, correct_category: nil, message_send_ttl_seconds: nil, cta_url_link_tracking_opted_out: nil, library_template_name: nil) ⇒ Node
Returns a new instance of Node.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 78 def initialize(id: nil, name: nil, status: nil, category: nil, language: nil, components: [], parameter_format: nil, sub_category: nil, rejected_reason: nil, quality_score: nil, previous_category: nil, correct_category: nil, message_send_ttl_seconds: nil, cta_url_link_tracking_opted_out: nil, library_template_name: nil) @id = id @name = name @status = status @category = category @language = language @components = components @parameter_format = parameter_format @sub_category = sub_category @rejected_reason = rejected_reason @quality_score = quality_score @previous_category = previous_category @correct_category = correct_category @message_send_ttl_seconds = @cta_url_link_tracking_opted_out = cta_url_link_tracking_opted_out @library_template_name = library_template_name end |
Instance Attribute Details
#category ⇒ String?
31 32 33 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 31 def category @category end |
#components ⇒ Array<Hash>
Returns Raw component hashes — see the class comment.
39 40 41 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 39 def components @components end |
#correct_category ⇒ String?
Returns The category Meta believes this should be.
63 64 65 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 63 def correct_category @correct_category end |
#cta_url_link_tracking_opted_out ⇒ Boolean?
71 72 73 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 71 def cta_url_link_tracking_opted_out @cta_url_link_tracking_opted_out end |
#id ⇒ String?
19 20 21 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 19 def id @id end |
#language ⇒ String?
35 36 37 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 35 def language @language end |
#library_template_name ⇒ String?
Returns Set when the template was cloned from the library.
75 76 77 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 75 def library_template_name @library_template_name end |
#message_send_ttl_seconds ⇒ Integer?
67 68 69 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 67 def @message_send_ttl_seconds end |
#name ⇒ String?
23 24 25 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 23 def name @name end |
#parameter_format ⇒ String?
43 44 45 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 43 def parameter_format @parameter_format end |
#previous_category ⇒ String?
Returns Set after an automatic recategorisation.
59 60 61 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 59 def previous_category @previous_category end |
#quality_score ⇒ QualityScore?
55 56 57 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 55 def quality_score @quality_score end |
#rejected_reason ⇒ String?
Returns One of Statuses::RejectedReasons::ALL.
51 52 53 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 51 def rejected_reason @rejected_reason end |
#status ⇒ String?
Returns One of Statuses::ALL.
27 28 29 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 27 def status @status end |
#sub_category ⇒ String?
47 48 49 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 47 def sub_category @sub_category end |
Class Method Details
.deserialize(data) ⇒ Node
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 102 def deserialize(data) data ||= {} new( id: data["id"], name: data["name"], status: data["status"], category: data["category"], language: data["language"], components: Array(data["components"]), parameter_format: data["parameter_format"], sub_category: data["sub_category"], rejected_reason: data["rejected_reason"], quality_score: data["quality_score"] && QualityScore.deserialize(data["quality_score"]), previous_category: data["previous_category"], correct_category: data["correct_category"], message_send_ttl_seconds: data["message_send_ttl_seconds"], cta_url_link_tracking_opted_out: data["cta_url_link_tracking_opted_out"], library_template_name: data["library_template_name"] ) end |
Instance Method Details
#approved? ⇒ Boolean
Returns Whether the template can currently be sent.
126 127 128 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 126 def approved? status == Statuses::APPROVED end |
#editable? ⇒ Boolean
Whether Whatsapp::MessageTemplates#update would be accepted for this template.
Status is the only part that can be checked locally. Approved templates are also rate limited to 10 edits per 30 days and 1 per 24 hours, which only the API can adjudicate.
146 147 148 |
# File 'lib/ruby/whatsapp/message_templates/response/node.rb', line 146 def editable? Statuses::EDITABLE.include?(status) end |