Module: EmailFuse::Emails
- Included in:
- Client
- Defined in:
- lib/email_fuse/emails.rb,
lib/email_fuse/emails/receiving.rb,
lib/email_fuse/emails/attachments.rb,
lib/email_fuse/emails/receiving/attachments.rb
Overview
Module responsible for wrapping email sending API
Defined Under Namespace
Modules: Attachments, Receiving
Class Method Summary collapse
-
.cancel(email_id) ⇒ EmailFuse::Response
Cancel a scheduled email.
-
.get(email_id) ⇒ EmailFuse::Response
Retrieve a single email.
-
.list(options = {}) ⇒ EmailFuse::Response
List emails with optional pagination.
-
.send(params, options: {}) ⇒ EmailFuse::Response
Sends or schedules an email.
-
.update(params) ⇒ EmailFuse::Response
Update a scheduled email.
Class Method Details
.cancel(email_id) ⇒ EmailFuse::Response
Cancel a scheduled email.
56 57 58 59 60 61 |
# File 'lib/email_fuse/emails.rb', line 56 def cancel(email_id) raise ArgumentError, "email_id is required" if email_id.nil? || email_id.to_s.empty? path = "emails/#{email_id}/cancel" EmailFuse::Request.new(path, {}, "post").perform end |
.get(email_id) ⇒ EmailFuse::Response
Retrieve a single email.
30 31 32 33 34 35 |
# File 'lib/email_fuse/emails.rb', line 30 def get(email_id) raise ArgumentError, "email_id is required" if email_id.nil? || email_id.to_s.empty? path = "emails/#{email_id}" EmailFuse::Request.new(path, {}, "get").perform end |
.list(options = {}) ⇒ EmailFuse::Response
List emails with optional pagination.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/email_fuse/emails.rb', line 71 def list( = {}) path = "emails" # Build query parameters, filtering out nil values query_params = {} query_params[:limit] = [:limit] if [:limit] query_params[:after] = [:after] if [:after] query_params[:before] = [:before] if [:before] EmailFuse::Request.new(path, query_params, "get").perform end |
.send(params, options: {}) ⇒ EmailFuse::Response
Sends or schedules an email.
17 18 19 20 21 22 23 |
# File 'lib/email_fuse/emails.rb', line 17 def send(params, options: {}) raise ArgumentError, ":from is required" unless params[:from] || params["from"] raise ArgumentError, ":to is required" unless params[:to] || params["to"] path = "emails" EmailFuse::Request.new(path, params, "post", options: ).perform end |
.update(params) ⇒ EmailFuse::Response
Update a scheduled email.
43 44 45 46 47 48 49 |
# File 'lib/email_fuse/emails.rb', line 43 def update(params) email_id = params[:email_id] || params["email_id"] raise ArgumentError, ":email_id is required" if email_id.nil? || email_id.to_s.empty? path = "emails/#{email_id}" EmailFuse::Request.new(path, params, "patch").perform end |