Class: Sendly::Campaign
- Inherits:
-
Object
- Object
- Sendly::Campaign
- Defined in:
- lib/sendly/campaigns_resource.rb
Constant Summary collapse
- STATUSES =
%w[draft scheduled sending sent paused cancelled failed].freeze
Instance Attribute Summary collapse
-
#completed_at ⇒ Object
readonly
Returns the value of attribute completed_at.
-
#contact_list_ids ⇒ Object
readonly
Returns the value of attribute contact_list_ids.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#credits_used ⇒ Object
readonly
Returns the value of attribute credits_used.
-
#delivered_count ⇒ Object
readonly
Returns the value of attribute delivered_count.
-
#estimated_credits ⇒ Object
readonly
Returns the value of attribute estimated_credits.
-
#failed_count ⇒ Object
readonly
Returns the value of attribute failed_count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#recipient_count ⇒ Object
readonly
Returns the value of attribute recipient_count.
-
#scheduled_at ⇒ Object
readonly
Returns the value of attribute scheduled_at.
-
#sent_count ⇒ Object
readonly
Returns the value of attribute sent_count.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#template_id ⇒ Object
readonly
Returns the value of attribute template_id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #cancelled? ⇒ Boolean
- #draft? ⇒ Boolean
-
#initialize(data) ⇒ Campaign
constructor
A new instance of Campaign.
- #scheduled? ⇒ Boolean
- #sending? ⇒ Boolean
- #sent? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ Campaign
Returns a new instance of Campaign.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sendly/campaigns_resource.rb', line 12 def initialize(data) @id = data["id"] @name = data["name"] @text = data["text"] @template_id = data["template_id"] || data["templateId"] @contact_list_ids = data["contact_list_ids"] || data["contactListIds"] || [] @status = data["status"] @recipient_count = data["recipient_count"] || data["recipientCount"] || 0 @sent_count = data["sent_count"] || data["sentCount"] || 0 @delivered_count = data["delivered_count"] || data["deliveredCount"] || 0 @failed_count = data["failed_count"] || data["failedCount"] || 0 @estimated_credits = data["estimated_credits"] || data["estimatedCredits"] || 0 @credits_used = data["credits_used"] || data["creditsUsed"] || 0 @scheduled_at = parse_time(data["scheduled_at"] || data["scheduledAt"]) @timezone = data["timezone"] @started_at = parse_time(data["started_at"] || data["startedAt"]) @completed_at = parse_time(data["completed_at"] || data["completedAt"]) @created_at = parse_time(data["created_at"] || data["createdAt"]) @updated_at = parse_time(data["updated_at"] || data["updatedAt"]) end |
Instance Attribute Details
#completed_at ⇒ Object (readonly)
Returns the value of attribute completed_at.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def completed_at @completed_at end |
#contact_list_ids ⇒ Object (readonly)
Returns the value of attribute contact_list_ids.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def contact_list_ids @contact_list_ids end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def created_at @created_at end |
#credits_used ⇒ Object (readonly)
Returns the value of attribute credits_used.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def credits_used @credits_used end |
#delivered_count ⇒ Object (readonly)
Returns the value of attribute delivered_count.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def delivered_count @delivered_count end |
#estimated_credits ⇒ Object (readonly)
Returns the value of attribute estimated_credits.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def estimated_credits @estimated_credits end |
#failed_count ⇒ Object (readonly)
Returns the value of attribute failed_count.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def failed_count @failed_count end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def name @name end |
#recipient_count ⇒ Object (readonly)
Returns the value of attribute recipient_count.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def recipient_count @recipient_count end |
#scheduled_at ⇒ Object (readonly)
Returns the value of attribute scheduled_at.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def scheduled_at @scheduled_at end |
#sent_count ⇒ Object (readonly)
Returns the value of attribute sent_count.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def sent_count @sent_count end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def started_at @started_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def status @status end |
#template_id ⇒ Object (readonly)
Returns the value of attribute template_id.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def template_id @template_id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def text @text end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def timezone @timezone end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/sendly/campaigns_resource.rb', line 5 def updated_at @updated_at end |
Instance Method Details
#cancelled? ⇒ Boolean
49 50 51 |
# File 'lib/sendly/campaigns_resource.rb', line 49 def cancelled? status == "cancelled" end |
#draft? ⇒ Boolean
33 34 35 |
# File 'lib/sendly/campaigns_resource.rb', line 33 def draft? status == "draft" end |
#scheduled? ⇒ Boolean
37 38 39 |
# File 'lib/sendly/campaigns_resource.rb', line 37 def scheduled? status == "scheduled" end |
#sending? ⇒ Boolean
41 42 43 |
# File 'lib/sendly/campaigns_resource.rb', line 41 def sending? status == "sending" end |
#sent? ⇒ Boolean
45 46 47 |
# File 'lib/sendly/campaigns_resource.rb', line 45 def sent? status == "sent" end |
#to_h ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sendly/campaigns_resource.rb', line 53 def to_h { id: id, name: name, text: text, template_id: template_id, contact_list_ids: contact_list_ids, status: status, recipient_count: recipient_count, sent_count: sent_count, delivered_count: delivered_count, failed_count: failed_count, estimated_credits: estimated_credits, credits_used: credits_used, scheduled_at: scheduled_at&.iso8601, timezone: timezone, started_at: started_at&.iso8601, completed_at: completed_at&.iso8601, created_at: created_at&.iso8601, updated_at: updated_at&.iso8601 }.compact end |