Class: LoopsRails::Client

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

Constant Summary collapse

BASE_URL =
'https://app.loops.so/api/v1/'

Instance Method Summary collapse

Constructor Details

#initialize(api_key = LoopsRails.configuration.api_key) ⇒ Client

Returns a new instance of Client.



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

def initialize(api_key = LoopsRails.configuration.api_key)
  @api_key = api_key
  @conn = Faraday.new(url: BASE_URL) do |faraday|
    faraday.request :url_encoded
    faraday.adapter Faraday.default_adapter
    faraday.headers['Authorization'] = "Bearer #{@api_key}"
    faraday.headers['Content-Type'] = 'application/json'
  end
end

Instance Method Details

#api_keyObject



15
16
17
# File 'lib/loops_rails/client.rb', line 15

def api_key
  @api_key_endpoint ||= ApiKey.new(@conn)
end

#contactsObject



19
20
21
# File 'lib/loops_rails/client.rb', line 19

def contacts
  @contacts ||= Contacts.new(@conn)
end

#custom_fieldsObject



23
24
25
# File 'lib/loops_rails/client.rb', line 23

def custom_fields
  @custom_fields ||= CustomFields.new(@conn)
end

#eventsObject



31
32
33
# File 'lib/loops_rails/client.rb', line 31

def events
  @events ||= Events.new(@conn)
end

#listsObject



27
28
29
# File 'lib/loops_rails/client.rb', line 27

def lists
  @lists ||= Lists.new(@conn)
end

#transactional_emailsObject



35
36
37
# File 'lib/loops_rails/client.rb', line 35

def transactional_emails
  @transactional_emails ||= TransactionalEmails.new(@conn)
end