Class: LoopsEmail::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/loops_email/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



3
# File 'lib/loops_email/client.rb', line 3

def initialize; end

Instance Method Details

#get(endpoint, other_headers: {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/loops_email/client.rb', line 17

def get(endpoint, other_headers: {})
  return if LoopsEmail.stub?

  response = Net::HTTP.get(
    endpoint_uri(endpoint),
    headers.merge(other_headers)
  )
  log_response(response)
  LoopsEmail::Result.new(response)
end

#post(endpoint, body: {}, other_headers: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/loops_email/client.rb', line 5

def post(endpoint, body: {}, other_headers: {})
  return if LoopsEmail.stub?

  response = Net::HTTP.post(
    endpoint_uri(endpoint),
    body.to_json,
    headers.merge(other_headers)
  )
  log_response(response)
  LoopsEmail::Result.new(response)
end