Class: CapsuleCRM::Connection

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

Class Method Summary collapse

Class Method Details

.delete(path) ⇒ Object



30
31
32
33
34
# File 'lib/capsule_crm/connection.rb', line 30

def self.delete(path)
  faraday.delete(path) do |request|
    request.headers.update default_request_headers
  end.success?
end

.get(path, params = {}) ⇒ Object

Public: Send a GET request to CapsuleCRM API

path - The String path where the request should go params - The Hash of URL parameters

Returns a Hash from the JSON response



10
11
12
13
14
15
# File 'lib/capsule_crm/connection.rb', line 10

def self.get(path, params = {})
  response = faraday.get(path, params) do |req|
    req.headers.update default_request_headers
  end
  JSON.parse response.body
end

.post(path, params = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/capsule_crm/connection.rb', line 17

def self.post(path, params = {})
  response = faraday.post(path, params.to_json) do |request|
    request.headers.update default_request_headers
  end
  process_post_response(response)
end

.put(path, params) ⇒ Object



24
25
26
27
28
# File 'lib/capsule_crm/connection.rb', line 24

def self.put(path, params)
  faraday.put(path, params) do |request|
    request.headers.update default_request_headers
  end.success?
end