Class: Sendly::Draft
- Inherits:
-
Object
- Object
- Sendly::Draft
- Defined in:
- lib/sendly/types.rb
Overview
Drafts
Constant Summary collapse
- STATUSES =
%w[pending approved rejected sent failed].freeze
Instance Attribute Summary collapse
-
#conversation_id ⇒ Object
readonly
Returns the value of attribute conversation_id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#created_by ⇒ Object
readonly
Returns the value of attribute created_by.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#media_urls ⇒ Object
readonly
Returns the value of attribute media_urls.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#rejection_reason ⇒ Object
readonly
Returns the value of attribute rejection_reason.
-
#reviewed_at ⇒ Object
readonly
Returns the value of attribute reviewed_at.
-
#reviewed_by ⇒ Object
readonly
Returns the value of attribute reviewed_by.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #approved? ⇒ Boolean
-
#initialize(data) ⇒ Draft
constructor
A new instance of Draft.
- #pending? ⇒ Boolean
- #rejected? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ Draft
Returns a new instance of Draft.
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
# File 'lib/sendly/types.rb', line 642 def initialize(data) @id = data["id"] @conversation_id = data["conversationId"] || data["conversation_id"] @text = data["text"] @media_urls = data["mediaUrls"] || data["media_urls"] || [] @metadata = data["metadata"] || {} @status = data["status"] @source = data["source"] @created_by = data["createdBy"] || data["created_by"] @reviewed_by = data["reviewedBy"] || data["reviewed_by"] @reviewed_at = parse_time(data["reviewedAt"] || data["reviewed_at"]) @rejection_reason = data["rejectionReason"] || data["rejection_reason"] @message_id = data["messageId"] || data["message_id"] @created_at = parse_time(data["createdAt"] || data["created_at"]) @updated_at = parse_time(data["updatedAt"] || data["updated_at"]) end |
Instance Attribute Details
#conversation_id ⇒ Object (readonly)
Returns the value of attribute conversation_id.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def conversation_id @conversation_id end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def created_at @created_at end |
#created_by ⇒ Object (readonly)
Returns the value of attribute created_by.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def created_by @created_by end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def id @id end |
#media_urls ⇒ Object (readonly)
Returns the value of attribute media_urls.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def media_urls @media_urls end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def @message_id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def @metadata end |
#rejection_reason ⇒ Object (readonly)
Returns the value of attribute rejection_reason.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def rejection_reason @rejection_reason end |
#reviewed_at ⇒ Object (readonly)
Returns the value of attribute reviewed_at.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def reviewed_at @reviewed_at end |
#reviewed_by ⇒ Object (readonly)
Returns the value of attribute reviewed_by.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def reviewed_by @reviewed_by end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def source @source end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def status @status end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def text @text end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
636 637 638 |
# File 'lib/sendly/types.rb', line 636 def updated_at @updated_at end |
Instance Method Details
#approved? ⇒ Boolean
663 664 665 |
# File 'lib/sendly/types.rb', line 663 def approved? status == "approved" end |
#pending? ⇒ Boolean
659 660 661 |
# File 'lib/sendly/types.rb', line 659 def pending? status == "pending" end |
#rejected? ⇒ Boolean
667 668 669 |
# File 'lib/sendly/types.rb', line 667 def rejected? status == "rejected" end |
#to_h ⇒ Object
671 672 673 674 675 676 677 678 679 680 |
# File 'lib/sendly/types.rb', line 671 def to_h { id: id, conversation_id: conversation_id, text: text, media_urls: media_urls, metadata: , status: status, source: source, created_by: created_by, reviewed_by: reviewed_by, reviewed_at: reviewed_at&.iso8601, rejection_reason: rejection_reason, message_id: , created_at: created_at&.iso8601, updated_at: updated_at&.iso8601 }.compact end |