Class: Whatsapp::MessageTemplates::Response::Paging

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

Overview

Graph API cursor pagination for a template list.

Flattens the nested paging.cursors object, since the intermediate level carries no information of its own. 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(before: nil, after: nil) ⇒ Paging

Returns a new instance of Paging.

Parameters:

  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)


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

def initialize(before: nil, after: nil)
  @before = before
  @after = after
end

Instance Attribute Details

#afterString?

Returns Cursor for the next page.

Returns:

  • (String, nil)

    Cursor for the next page.



18
19
20
# File 'lib/ruby/whatsapp/message_templates/response/paging.rb', line 18

def after
  @after
end

#beforeString?

Returns Cursor for the previous page.

Returns:

  • (String, nil)

    Cursor for the previous page.



14
15
16
# File 'lib/ruby/whatsapp/message_templates/response/paging.rb', line 14

def before
  @before
end

Class Method Details

.deserialize(data) ⇒ Paging

Parameters:

  • data (Hash, nil)

    The raw paging object.

Returns:



30
31
32
33
34
# File 'lib/ruby/whatsapp/message_templates/response/paging.rb', line 30

def deserialize(data)
  cursors = (data || {})["cursors"] || {}

  new(before: cursors["before"], after: cursors["after"])
end