Class: MailUp::Console::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/mailup/console/email.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Email

Returns a new instance of Email.



6
7
8
# File 'lib/mailup/console/email.rb', line 6

def initialize(api)
  @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



4
5
6
# File 'lib/mailup/console/email.rb', line 4

def api
  @api
end

Instance Method Details

#get_deferred_confirmation_date(sending_id) ⇒ Object

Retrieves the earliest date to schedule the given sending task.

Parameters:

  • Id (Integer)

    Sending.



45
46
47
# File 'lib/mailup/console/email.rb', line 45

def get_deferred_confirmation_date(sending_id)
  @api.get("#{@api.path}/Email/Sendings/#{sending_id}/Deferred")
end

#get_deferred_confirmation_quequeObject

Retrieves the list of email messages that are currently queued up for “deferred sending”.



68
69
70
# File 'lib/mailup/console/email.rb', line 68

def get_deferred_confirmation_queque
  @api.get("#{@api.path}/Email/Sendings/Deferred")
end

#get_immediate_confirmation_quequeObject

Retrieves the list of email messages that are currently queued up for “immediate sending”.



61
62
63
# File 'lib/mailup/console/email.rb', line 61

def get_immediate_confirmation_queque
  @api.get("#{@api.path}/Email/Sendings/Immediate")
end

#get_undefined_confirmation_quequeObject

Retrieves the list of email messages that are neither “scheduled” nor queued up for “immediate sending”.



75
76
77
# File 'lib/mailup/console/email.rb', line 75

def get_undefined_confirmation_queque
  @api.get("#{@api.path}/Email/Sendings/Undefined")
end

#send(message_id, email) ⇒ JSON

Send single email message to specified recipient.

Examples:


send = mailup.console.email.send(5, '[email protected]')
send['Sent']
=> 1

Parameters:

  • message_id (Integer)

    The ID of the message to send.

  • email (String)

    The email address of the recipient.

Returns:

  • (JSON)

    A Send object with the following attributes:

    • idMessage [Integer]

    • Sent [Integer]

    • UnprocessedRecipients [Array]

    • InvalidRecipients [Array]

See Also:



29
30
31
# File 'lib/mailup/console/email.rb', line 29

def send(message_id, email)
  @api.post("#{@api.path}/Email/Send", body: {:idMessage => message_id, :Email => email})
end

#send_deferred_confirmation(sending_id, date = nil) ⇒ Object

Sets up a mailing for scheduled delivery

Parameters:

  • Id (Integer)

    Sending.

  • :Date (String)

    date/time for a deferred sending(should be UTC).



54
55
56
# File 'lib/mailup/console/email.rb', line 54

def send_deferred_confirmation(sending_id, date = nil)
  @api.post("#{@api.path}/Email/Sendings/#{sending_id}/Deferred", body: {'Date' => date})
end

#send_immediate_confirmation(sending_id) ⇒ Object

Schedules a mailing for immediate sending

Parameters:

  • Id (Integer)

    Sending.



37
38
39
# File 'lib/mailup/console/email.rb', line 37

def send_immediate_confirmation(sending_id)
  @api.post("#{@api.path}/Email/Sendings/#{sending_id}/Immediate")
end