Class: MailerLite::Connection
- Inherits:
-
Object
- Object
- MailerLite::Connection
- Defined in:
- lib/mailerlite/connection.rb
Overview
A class responsible for connecting to MailerLite API and making requests.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #delete(path, options = { return_body: true }) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(client) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Connection
18 19 20 |
# File 'lib/mailerlite/connection.rb', line 18 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (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, = { return_body: true }) return_body = .delete(:return_body) response = request(:delete, path, ) 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, = {}) request(:get, path, ).body end |
#post(path, options = {}) ⇒ Object
30 31 32 |
# File 'lib/mailerlite/connection.rb', line 30 def post(path, = {}) request(:post, path, {}, ).body end |
#put(path, options = {}) ⇒ Object
26 27 28 |
# File 'lib/mailerlite/connection.rb', line 26 def put(path, = {}) request(:put, path, {}, ).body end |