Class: Courrier::Email::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/courrier/email/providers/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, options: {}, provider_options: {}, context_options: {}, custom_headers: {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
# File 'lib/courrier/email/providers/base.rb', line 9

def initialize(api_key: nil, options: {}, provider_options: {}, context_options: {}, custom_headers: {})
  @api_key = api_key
  @options = options
  @provider_options = provider_options
  @context_options = context_options
  @custom_headers = custom_headers
end

Instance Method Details

#bodyObject



27
# File 'lib/courrier/email/providers/base.rb', line 27

def body = raise Courrier::NotImplementedError, "Provider class must implement `body`"

#deliverObject



17
18
19
20
21
22
23
24
25
# File 'lib/courrier/email/providers/base.rb', line 17

def deliver
  Request.new(
    endpoint_url: endpoint_url,
    body: body,
    provider: provider,
    headers: headers,
    content_type: content_type
  ).post
end