Class: MailerLite::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/mailerlite/connection.rb

Overview

A class responsible for connecting to MailerLite API and making requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Connection



18
19
20
# File 'lib/mailerlite/connection.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



16
17
18
# File 'lib/mailerlite/connection.rb', line 16

def client
  @client
end

Instance Method Details

#delete(path, options = { return_body: true }) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/mailerlite/connection.rb', line 34

def delete(path, options = { return_body: true })
  return_body = options.delete(:return_body)
  response = request(:delete, path, options)
  return response.body || {} if return_body

  response
end

#get(path, options = {}) ⇒ Object



22
23
24
# File 'lib/mailerlite/connection.rb', line 22

def get(path, options = {})
  request(:get, path, options).body
end

#post(path, options = {}) ⇒ Object



30
31
32
# File 'lib/mailerlite/connection.rb', line 30

def post(path, options = {})
  request(:post, path, {}, options).body
end

#put(path, options = {}) ⇒ Object



26
27
28
# File 'lib/mailerlite/connection.rb', line 26

def put(path, options = {})
  request(:put, path, {}, options).body
end