Class: Sendly::WhatsAppTemplate
- Inherits:
-
Object
- Object
- Sendly::WhatsAppTemplate
- Defined in:
- lib/sendly/whatsapp_resource.rb
Overview
A WhatsApp message template. Meta reviews every template (usually
24-48h) and may reclassify its category — the category on the record
is what drives per-message pricing. rejection_reason is set when the
status is "REJECTED"; warnings carries non-blocking submission
warnings on create responses.
Constant Summary collapse
- STATUSES =
%w[PENDING APPROVED REJECTED PAUSED DISABLED].freeze
- CATEGORIES =
%w[AUTHENTICATION UTILITY MARKETING].freeze
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#quality_rating ⇒ Object
readonly
Returns the value of attribute quality_rating.
-
#rejection_reason ⇒ Object
readonly
Returns the value of attribute rejection_reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #approved? ⇒ Boolean
-
#initialize(data) ⇒ WhatsAppTemplate
constructor
A new instance of WhatsAppTemplate.
- #pending? ⇒ Boolean
- #rejected? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ WhatsAppTemplate
Returns a new instance of WhatsAppTemplate.
151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/sendly/whatsapp_resource.rb', line 151 def initialize(data) @id = data["id"] @name = data["name"] @language = data["language"] @category = data["category"] @status = data["status"] @quality_rating = data["qualityRating"] || data["quality_rating"] @rejection_reason = data["rejectionReason"] || data["rejection_reason"] @created_at = data["createdAt"] || data["created_at"] @updated_at = data["updatedAt"] || data["updated_at"] @warnings = data["warnings"] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def category @category end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def id @id end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def language @language end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def name @name end |
#quality_rating ⇒ Object (readonly)
Returns the value of attribute quality_rating.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def @quality_rating end |
#rejection_reason ⇒ Object (readonly)
Returns the value of attribute rejection_reason.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def rejection_reason @rejection_reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def status @status end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def updated_at @updated_at end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
145 146 147 |
# File 'lib/sendly/whatsapp_resource.rb', line 145 def warnings @warnings end |
Instance Method Details
#approved? ⇒ Boolean
168 169 170 |
# File 'lib/sendly/whatsapp_resource.rb', line 168 def approved? status == "APPROVED" end |
#pending? ⇒ Boolean
164 165 166 |
# File 'lib/sendly/whatsapp_resource.rb', line 164 def pending? status == "PENDING" end |
#rejected? ⇒ Boolean
172 173 174 |
# File 'lib/sendly/whatsapp_resource.rb', line 172 def rejected? status == "REJECTED" end |
#to_h ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/sendly/whatsapp_resource.rb', line 176 def to_h { id: id, name: name, language: language, category: category, status: status, quality_rating: , rejection_reason: rejection_reason, created_at: created_at, updated_at: updated_at, warnings: warnings }.compact end |