Class: Mailkube::ScheduledEmail

Inherits:
Object
  • Object
show all
Defined in:
lib/mailkube/types/scheduled_emails.rb,
sig/mailkube/types/scheduled_emails.rbs

Overview

Declared the same way as every other model — see sig/mailkube/types.rbs for why these are plain classes that do not name ::Data as a superclass.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, message_id: nil, object: "scheduled_email", status: "", scheduled_at: nil, created_at: nil, batch_id: nil, subject: nil, recipients: nil, topic: nil, tags: []) ⇒ ScheduledEmail

Returns a new instance of ScheduledEmail.

Parameters:

  • id (String)

    the scheduled email's UUID.

  • message_id (String, nil) (defaults to: nil)

    the RFC Message-ID.

  • object (String) (defaults to: "scheduled_email")

    the resource discriminator, always scheduled_email.

  • status (String) (defaults to: "")

    one of scheduled, canceled, sent, failed. A server-controlled string, deliberately not an enum: a value added later must not break a released client.

  • scheduled_at (String, nil) (defaults to: nil)

    when the send is due.

  • created_at (String, nil) (defaults to: nil)

    when the send was accepted.

  • batch_id (String, nil) (defaults to: nil)

    the batch label this send was grouped under.

  • subject (String, nil) (defaults to: nil)

    the subject line.

  • recipients (String, nil) (defaults to: nil)

    a recipient summary, not a list: "a@b.com +2" when there are more, the bare address when there is one, "" when there are none. The full list stays server-side.

  • topic (String, nil) (defaults to: nil)

    the mailing-list topic slug.

  • tags (Array<Hash{String => Object}>) (defaults to: [])

    the tags attached at send time, verbatim.



28
29
30
31
# File 'lib/mailkube/types/scheduled_emails.rb', line 28

def initialize(id:, message_id: nil, object: "scheduled_email", status: "", scheduled_at: nil,
               created_at: nil, batch_id: nil, subject: nil, recipients: nil, topic: nil, tags: [])
  super
end

Instance Attribute Details

#batch_idString? (readonly)

Returns the value of attribute batch_id.

Returns:

  • (String, nil)


11
12
13
# File 'sig/mailkube/types/scheduled_emails.rbs', line 11

def batch_id
  @batch_id
end

#created_atString? (readonly)

Returns the value of attribute created_at.

Returns:

  • (String, nil)


10
11
12
# File 'sig/mailkube/types/scheduled_emails.rbs', line 10

def created_at
  @created_at
end

#idString (readonly)

Returns the value of attribute id.

Returns:

  • (String)


5
6
7
# File 'sig/mailkube/types/scheduled_emails.rbs', line 5

def id
  @id
end

#message_idString? (readonly)

Returns the value of attribute message_id.

Returns:

  • (String, nil)


6
7
8
# File 'sig/mailkube/types/scheduled_emails.rbs', line 6

def message_id
  @message_id
end

#objectString (readonly)

Returns the value of attribute object.

Returns:

  • (String)


7
8
9
# File 'sig/mailkube/types/scheduled_emails.rbs', line 7

def object
  @object
end

#recipientsString? (readonly)

Returns the value of attribute recipients.

Returns:

  • (String, nil)


13
14
15
# File 'sig/mailkube/types/scheduled_emails.rbs', line 13

def recipients
  @recipients
end

#scheduled_atString? (readonly)

Returns the value of attribute scheduled_at.

Returns:

  • (String, nil)


9
10
11
# File 'sig/mailkube/types/scheduled_emails.rbs', line 9

def scheduled_at
  @scheduled_at
end

#statusString (readonly)

Returns the value of attribute status.

Returns:

  • (String)


8
9
10
# File 'sig/mailkube/types/scheduled_emails.rbs', line 8

def status
  @status
end

#subjectString? (readonly)

Returns the value of attribute subject.

Returns:

  • (String, nil)


12
13
14
# File 'sig/mailkube/types/scheduled_emails.rbs', line 12

def subject
  @subject
end

#tagsArray[Hash[String, untyped]] (readonly)

Returns the value of attribute tags.

Returns:

  • (Array[Hash[String, untyped]])


15
16
17
# File 'sig/mailkube/types/scheduled_emails.rbs', line 15

def tags
  @tags
end

#topicString? (readonly)

Returns the value of attribute topic.

Returns:

  • (String, nil)


14
15
16
# File 'sig/mailkube/types/scheduled_emails.rbs', line 14

def topic
  @topic
end

Class Method Details

.from(payload) ⇒ ScheduledEmail

Returns the model.

Parameters:

  • payload (Hash{String => Object})

    one decoded scheduled_email object.

  • (Hash[String, untyped])

Returns:



35
36
37
38
39
40
41
# File 'lib/mailkube/types/scheduled_emails.rb', line 35

def self.from(payload)
  new(id: payload["id"], message_id: payload["message_id"],
      object: payload["object"] || "scheduled_email", status: payload["status"] || "",
      scheduled_at: payload["scheduled_at"], created_at: payload["created_at"],
      batch_id: payload["batch_id"], subject: payload["subject"],
      recipients: payload["recipients"], topic: payload["topic"], tags: payload["tags"] || [])
end