Class: Sendly::WhatsAppTemplate

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#categoryObject (readonly)

Returns the value of attribute category.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def category
  @category
end

#created_atObject (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

#idObject (readonly)

Returns the value of attribute id.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def id
  @id
end

#languageObject (readonly)

Returns the value of attribute language.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def name
  @name
end

#quality_ratingObject (readonly)

Returns the value of attribute quality_rating.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def quality_rating
  @quality_rating
end

#rejection_reasonObject (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

#statusObject (readonly)

Returns the value of attribute status.



145
146
147
# File 'lib/sendly/whatsapp_resource.rb', line 145

def status
  @status
end

#updated_atObject (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

#warningsObject (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

Returns:

  • (Boolean)


168
169
170
# File 'lib/sendly/whatsapp_resource.rb', line 168

def approved?
  status == "APPROVED"
end

#pending?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/sendly/whatsapp_resource.rb', line 164

def pending?
  status == "PENDING"
end

#rejected?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/sendly/whatsapp_resource.rb', line 172

def rejected?
  status == "REJECTED"
end

#to_hObject



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: quality_rating,
    rejection_reason: rejection_reason, created_at: created_at,
    updated_at: updated_at, warnings: warnings
  }.compact
end