Class: Contactually::API
- Inherits:
-
Object
- Object
- Contactually::API
- Defined in:
- lib/contactually/api.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #call(url, method, params = {}) ⇒ Object
- #connection ⇒ Object
- #contact_groupings ⇒ Object
- #contacts ⇒ Object
- #groupings ⇒ Object
-
#initialize ⇒ API
constructor
A new instance of API.
- #notes ⇒ Object
Constructor Details
#initialize ⇒ API
Returns a new instance of API.
3 4 5 6 7 |
# File 'lib/contactually/api.rb', line 3 def initialize raise ConfigMissingApiKeyError, 'You must provide a Contactually API key' unless Contactually.config.api_key @api_key = Contactually.config.api_key @base_url = Contactually.config.contactually_url end |
Instance Method Details
#accounts ⇒ Object
26 27 28 |
# File 'lib/contactually/api.rb', line 26 def accounts Contactually::Accounts.new self end |
#call(url, method, params = {}) ⇒ Object
9 10 11 12 |
# File 'lib/contactually/api.rb', line 9 def call(url, method, params={}) response = send(method, url, params) JSON.load(response.body) end |
#connection ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/contactually/api.rb', line 34 def connection @connection ||= Faraday.new do |faraday| faraday.adapter Faraday.default_adapter faraday.headers['Content-Type'] = 'application/json' faraday.use Contactually::Middleware::ErrorDetector end end |
#contact_groupings ⇒ Object
30 31 32 |
# File 'lib/contactually/api.rb', line 30 def contact_groupings Contactually::ContactGroupings.new self end |
#contacts ⇒ Object
14 15 16 |
# File 'lib/contactually/api.rb', line 14 def contacts Contactually::Contacts.new self end |
#groupings ⇒ Object
22 23 24 |
# File 'lib/contactually/api.rb', line 22 def groupings Contactually::Groupings.new self end |
#notes ⇒ Object
18 19 20 |
# File 'lib/contactually/api.rb', line 18 def notes Contactually::Notes.new self end |