Class: MailerLite::Client
- Inherits:
-
Object
- Object
- MailerLite::Client
- Defined in:
- lib/mailerlite/client.rb
Overview
Inits the client.
Instance Method Summary collapse
- #headers ⇒ Object
- #http ⇒ Object
-
#initialize(api_token = ENV.fetch('MAILERLITE_API_TOKEN', nil)) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_token = ENV.fetch('MAILERLITE_API_TOKEN', nil)) ⇒ Client
Returns a new instance of Client.
16 17 18 |
# File 'lib/mailerlite/client.rb', line 16 def initialize(api_token = ENV.fetch('MAILERLITE_API_TOKEN', nil)) @api_token = api_token end |
Instance Method Details
#headers ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/mailerlite/client.rb', line 20 def headers { 'User-Agent' => "MailerLite-client-ruby/#{MailerLite::VERSION}", 'Accept' => 'application/json', 'Content-type' => 'application/json' } end |
#http ⇒ Object
28 29 30 31 32 33 |
# File 'lib/mailerlite/client.rb', line 28 def http HTTP .timeout(connect: 15, read: 30) .auth("Bearer #{@api_token}") .headers(headers) end |