Class: Sendly::TenDlcCampaign

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

Overview

A messaging campaign registered for carrier review. The status starts "pending" and moves to "active" (numbers can be assigned) or "failed" (see failure_reasons); the carrier network may later mark it "suspended" or "expired".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ TenDlcCampaign

Returns a new instance of TenDlcCampaign.



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/sendly/tendlc_resource.rb', line 97

def initialize(data)
  @id = data["id"]
  @brand_id = data["brandId"] || data["brand_id"]
  @use_case = data["useCase"] || data["use_case"]
  @sub_use_cases = data["subUseCases"] || data["sub_use_cases"] || []
  @description = data["description"]
  @status = data["status"]
  @sample_messages = data["sampleMessages"] || data["sample_messages"] || []
  @throughput = data["throughput"] ? TenDlcThroughput.new(data["throughput"]) : nil
  @failure_reasons = data["failureReasons"] || data["failure_reasons"]
  @created_at = data["createdAt"] || data["created_at"]
  @updated_at = data["updatedAt"] || data["updated_at"]
end

Instance Attribute Details

#brand_idObject (readonly)

Returns the value of attribute brand_id.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def brand_id
  @brand_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def description
  @description
end

#failure_reasonsObject (readonly)

Returns the value of attribute failure_reasons.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def failure_reasons
  @failure_reasons
end

#idObject (readonly)

Returns the value of attribute id.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def id
  @id
end

#sample_messagesObject (readonly)

Returns the value of attribute sample_messages.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def sample_messages
  @sample_messages
end

#statusObject (readonly)

Returns the value of attribute status.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def status
  @status
end

#sub_use_casesObject (readonly)

Returns the value of attribute sub_use_cases.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def sub_use_cases
  @sub_use_cases
end

#throughputObject (readonly)

Returns the value of attribute throughput.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def throughput
  @throughput
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def updated_at
  @updated_at
end

#use_caseObject (readonly)

Returns the value of attribute use_case.



93
94
95
# File 'lib/sendly/tendlc_resource.rb', line 93

def use_case
  @use_case
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/sendly/tendlc_resource.rb', line 115

def active?
  status == "active"
end

#failed?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/sendly/tendlc_resource.rb', line 119

def failed?
  status == "failed"
end

#pending?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/sendly/tendlc_resource.rb', line 111

def pending?
  status == "pending"
end

#to_hObject



123
124
125
126
127
128
129
130
131
# File 'lib/sendly/tendlc_resource.rb', line 123

def to_h
  {
    id: id, brand_id: brand_id, use_case: use_case,
    sub_use_cases: sub_use_cases, description: description,
    status: status, sample_messages: sample_messages,
    throughput: throughput&.to_h, failure_reasons: failure_reasons,
    created_at: created_at, updated_at: updated_at
  }.compact
end