Class: Whatsapp::MessageTemplates::Response::Created

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/message_templates/response/created.rb

Overview

The response to creating a template: {id, status, category}.

status is worth checking rather than assuming: a template built from scratch normally comes back PENDING and takes up to 24 hours to review, but a library clone or an authentication template is usually APPROVED immediately, and a category Meta disagrees with comes back REJECTED right away.

category is echoed back because Meta may have reassigned it — automatic recategorisation has been the default since 2025-04-09. Source: https://developers.facebook.com/docs/graph-api/reference/whats-app-business-account/message_templates/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, status: nil, category: nil) ⇒ Created

Returns a new instance of Created.

Parameters:

  • id (String, nil) (defaults to: nil)
  • status (String, nil) (defaults to: nil)
  • category (String, nil) (defaults to: nil)


32
33
34
35
36
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 32

def initialize(id: nil, status: nil, category: nil)
  @id = id
  @status = status
  @category = category
end

Instance Attribute Details

#categoryString?

Returns The category Meta actually assigned.

Returns:

  • (String, nil)

    The category Meta actually assigned.



27
28
29
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 27

def category
  @category
end

#idString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 19

def id
  @id
end

#statusString?

Returns:

  • (String, nil)


23
24
25
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 23

def status
  @status
end

Class Method Details

.deserialize(data) ⇒ Created

Parameters:

  • data (Hash, nil)

    The parsed response body.

Returns:



41
42
43
44
45
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 41

def deserialize(data)
  data ||= {}

  new(id: data["id"], status: data["status"], category: data["category"])
end

Instance Method Details

#approved?Boolean

Returns Whether the template is already sendable.

Returns:

  • (Boolean)

    Whether the template is already sendable.



49
50
51
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 49

def approved?
  status == Statuses::APPROVED
end

#pending?Boolean

Returns Whether the template is still in review.

Returns:

  • (Boolean)

    Whether the template is still in review.



54
55
56
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 54

def pending?
  status == Statuses::PENDING
end

#rejected?Boolean

Returns Whether the template failed review.

Returns:

  • (Boolean)

    Whether the template failed review.



59
60
61
# File 'lib/ruby/whatsapp/message_templates/response/created.rb', line 59

def rejected?
  status == Statuses::REJECTED
end