Class: Whatsapp::MessageTemplates::Response::Summary

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

Overview

The summary block of a template list.

Worth reading rather than ignoring: message_template_count against message_template_limit is the only way to see how close a WABA is to its template cap — 250 for an unverified business portfolio, up to 6,000 for a verified one with an approved display name. Hitting it turns every subsequent create into an error. 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(total_count: nil, message_template_count: nil, message_template_limit: nil, are_translations_complete: nil) ⇒ Summary

Returns a new instance of Summary.

Parameters:

  • total_count (Integer, nil) (defaults to: nil)
  • message_template_count (Integer, nil) (defaults to: nil)
  • message_template_limit (Integer, nil) (defaults to: nil)
  • are_translations_complete (Boolean, nil) (defaults to: nil)


35
36
37
38
39
40
41
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 35

def initialize(total_count: nil, message_template_count: nil, message_template_limit: nil,
  are_translations_complete: nil)
  @total_count = total_count
  @message_template_count = message_template_count
  @message_template_limit = message_template_limit
  @are_translations_complete = are_translations_complete
end

Instance Attribute Details

#are_translations_completeBoolean?

Returns:

  • (Boolean, nil)


29
30
31
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 29

def are_translations_complete
  @are_translations_complete
end

#message_template_countInteger?

Returns Templates currently on the account.

Returns:

  • (Integer, nil)

    Templates currently on the account.



21
22
23
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 21

def message_template_count
  @message_template_count
end

#message_template_limitInteger?

Returns The account's cap.

Returns:

  • (Integer, nil)

    The account's cap.



25
26
27
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 25

def message_template_limit
  @message_template_limit
end

#total_countInteger?

Returns:

  • (Integer, nil)


17
18
19
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 17

def total_count
  @total_count
end

Class Method Details

.deserialize(data) ⇒ Summary

Parameters:

  • data (Hash, nil)

    The raw summary object.

Returns:



46
47
48
49
50
51
52
53
54
55
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 46

def deserialize(data)
  data ||= {}

  new(
    total_count: data["total_count"],
    message_template_count: data["message_template_count"],
    message_template_limit: data["message_template_limit"],
    are_translations_complete: data["are_translations_complete"]
  )
end

Instance Method Details

#remainingInteger?

How many more templates the account can hold.

Returns:

  • (Integer, nil)

    nil when either figure is missing.



60
61
62
63
64
# File 'lib/ruby/whatsapp/message_templates/response/summary.rb', line 60

def remaining
  return if message_template_limit.nil? || message_template_count.nil?

  message_template_limit - message_template_count
end