Class: Sendly::WhatsAppSignupSession

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/whatsapp_resource.rb

Overview

A newly started WhatsApp signup. Hand connect_url to a human — they open it in a browser and log in with Facebook to link their WhatsApp Business Account. Poll Sendly::WhatsAppSignupResource#get with id until the status is "active".

Constant Summary collapse

STATUSES =
%w[initiated registering active failed expired].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ WhatsAppSignupSession

Returns a new instance of WhatsAppSignupSession.



13
14
15
16
17
# File 'lib/sendly/whatsapp_resource.rb', line 13

def initialize(data)
  @id = data["id"]
  @connect_url = data["connectUrl"] || data["connect_url"]
  @status = data["status"]
end

Instance Attribute Details

#connect_urlObject (readonly)

Returns the value of attribute connect_url.



9
10
11
# File 'lib/sendly/whatsapp_resource.rb', line 9

def connect_url
  @connect_url
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/sendly/whatsapp_resource.rb', line 9

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/sendly/whatsapp_resource.rb', line 9

def status
  @status
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/sendly/whatsapp_resource.rb', line 19

def active?
  status == "active"
end

#failed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/sendly/whatsapp_resource.rb', line 23

def failed?
  status == "failed"
end

#to_hObject



27
28
29
# File 'lib/sendly/whatsapp_resource.rb', line 27

def to_h
  { id: id, connect_url: connect_url, status: status }.compact
end