Class: Sendly::WhatsAppSignup

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

Overview

The status of a WhatsApp signup. business_account_id is nil until the human completes the connect step; failure_reasons is set when the status is "failed".

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ WhatsAppSignup

Returns a new instance of WhatsAppSignup.



41
42
43
44
45
46
47
48
# File 'lib/sendly/whatsapp_resource.rb', line 41

def initialize(data)
  @id = data["id"]
  @status = data["status"]
  @phone_number = data["phoneNumber"] || data["phone_number"]
  @business_account_id = data["businessAccountId"] || data["business_account_id"]
  @failure_reasons = data["failureReasons"] || data["failure_reasons"]
  @updated_at = data["updatedAt"] || data["updated_at"]
end

Instance Attribute Details

#business_account_idObject (readonly)

Returns the value of attribute business_account_id.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def 
  @business_account_id
end

#failure_reasonsObject (readonly)

Returns the value of attribute failure_reasons.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def failure_reasons
  @failure_reasons
end

#idObject (readonly)

Returns the value of attribute id.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def id
  @id
end

#phone_numberObject (readonly)

Returns the value of attribute phone_number.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def phone_number
  @phone_number
end

#statusObject (readonly)

Returns the value of attribute status.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



36
37
38
# File 'lib/sendly/whatsapp_resource.rb', line 36

def updated_at
  @updated_at
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/sendly/whatsapp_resource.rb', line 50

def active?
  status == "active"
end

#expired?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/sendly/whatsapp_resource.rb', line 58

def expired?
  status == "expired"
end

#failed?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/sendly/whatsapp_resource.rb', line 54

def failed?
  status == "failed"
end

#to_hObject



62
63
64
65
66
67
68
# File 'lib/sendly/whatsapp_resource.rb', line 62

def to_h
  {
    id: id, status: status, phone_number: phone_number,
    business_account_id: ,
    failure_reasons: failure_reasons, updated_at: updated_at
  }.compact
end