Class: DashamailTransactional::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/dashamail/http.rb

Constant Summary collapse

VERBS =
{
  get: Net::HTTP::Get,
  post: Net::HTTP::Post
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HTTP

Returns a new instance of HTTP.



14
15
16
17
18
19
20
# File 'lib/dashamail/http.rb', line 14

def initialize(options = {})
  @config = DashaMail.config
  @credentials = {
    end_point: @config.end_point,
    api_key: @config.api_key
  }.merge!(options)
end

Instance Method Details

#base_headers(options = {}) ⇒ Object



22
23
24
25
26
27
# File 'lib/dashamail/http.rb', line 22

def base_headers(options = {})
  @headers = {
    'User-Agent' => "DashaMail(Ruby)/#{DashaMail::VERSION}",
    'Content-Type' => 'application/json'
  }.merge!(options)
end

#reset_headersObject



29
30
31
# File 'lib/dashamail/http.rb', line 29

def reset_headers
  @headers = base_headers
end