Class: Mailkube::Email

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

Overview

The result of a successful send.

A scheduled send (one carrying scheduled_at) is acknowledged with 202 and a richer body; status, scheduled_at and batch_id are populated only then, and #scheduled? is the discriminator. An immediate send leaves all three nil.

This is the worked example of the contract's widen, never union rule: one call can return two shapes, and adding optional fields plus a predicate keeps every existing caller valid, where returning one of two classes would not.

Timestamps stay the verbatim ISO-8601 strings the server sent. The SDK does not validate or reinterpret server data; call Time.iso8601 yourself if you want an object. Transport metadata (response headers, the request id) belongs on the exception, not here.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, message_id: nil, idempotent_replayed: false, status: nil, scheduled_at: nil, batch_id: nil) ⇒ Email

Returns a new instance of Email.

Parameters:

  • id (String)

    the accepted message's UUID.

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

    the RFC Message-ID, when the deployment returns one.

  • idempotent_replayed (Boolean) (defaults to: false)

    true when this replays an earlier identical request.

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

    the scheduled email's status, on a scheduled ack only.

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

    when the send is due, on a scheduled ack only.

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

    the batch label the send was grouped under.



46
47
48
49
# File 'lib/mailkube/types.rb', line 46

def initialize(id:, message_id: nil, idempotent_replayed: false, status: nil, scheduled_at: nil,
               batch_id: nil)
  super
end

Instance Attribute Details

#batch_idString? (readonly)

Returns the value of attribute batch_id.

Returns:

  • (String, nil)


38
39
40
# File 'sig/mailkube/types.rbs', line 38

def batch_id
  @batch_id
end

#idString (readonly)

Returns the value of attribute id.

Returns:

  • (String)


33
34
35
# File 'sig/mailkube/types.rbs', line 33

def id
  @id
end

#idempotent_replayedBoolean (readonly)

Returns the value of attribute idempotent_replayed.

Returns:

  • (Boolean)


35
36
37
# File 'sig/mailkube/types.rbs', line 35

def idempotent_replayed
  @idempotent_replayed
end

#message_idString? (readonly)

Returns the value of attribute message_id.

Returns:

  • (String, nil)


34
35
36
# File 'sig/mailkube/types.rbs', line 34

def message_id
  @message_id
end

#scheduled_atString? (readonly)

Returns the value of attribute scheduled_at.

Returns:

  • (String, nil)


37
38
39
# File 'sig/mailkube/types.rbs', line 37

def scheduled_at
  @scheduled_at
end

#statusString? (readonly)

Returns the value of attribute status.

Returns:

  • (String, nil)


36
37
38
# File 'sig/mailkube/types.rbs', line 36

def status
  @status
end

Instance Method Details

#scheduled?Boolean

Returns true when the send was accepted for later delivery rather than sent now.

Returns:

  • (Boolean)

    true when the send was accepted for later delivery rather than sent now.



52
# File 'lib/mailkube/types.rb', line 52

def scheduled? = !scheduled_at.nil?