Module: AgileCRMWrapper

Defined in:
lib/agilecrm-wrapper.rb,
lib/agilecrm-wrapper/note.rb,
lib/agilecrm-wrapper/error.rb,
lib/agilecrm-wrapper/contact.rb,
lib/agilecrm-wrapper/version.rb,
lib/agilecrm-wrapper/configuration.rb,
lib/agilecrm-wrapper/response/raise_error.rb

Defined Under Namespace

Modules: Response Classes: BadRequest, ClientError, Configuration, Contact, Error, InternalServerError, MediaTypeMismatch, MethodNotAllowed, NotFound, Note, ServerError, Unauthorized

Constant Summary collapse

VERSION =
'1.0.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



12
13
14
# File 'lib/agilecrm-wrapper.rb', line 12

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



22
23
24
# File 'lib/agilecrm-wrapper.rb', line 22

def configure
  yield(configuration)
end

.connectionObject



30
31
32
# File 'lib/agilecrm-wrapper.rb', line 30

def connection
  @connection ||= default_connection
end

.default_connectionObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/agilecrm-wrapper.rb', line 34

def default_connection
  options = {
    headers: { 'Accept' => 'application/json' }
  }
  Faraday.new(endpoint, options) do |conn|
    conn.request(:json)
    conn.request(:basic_auth, configuration.email, configuration.api_key)
    conn.response(:json, content_type: /\bjson$/)
    conn.response(:agilecrm_error)
    conn.adapter(Faraday.default_adapter)
  end
end

.endpointObject



26
27
28
# File 'lib/agilecrm-wrapper.rb', line 26

def endpoint
  "https://#{configuration.domain}.agilecrm.com/dev/api"
end

.resetObject



18
19
20
# File 'lib/agilecrm-wrapper.rb', line 18

def reset
  @configuration = Configuration.new
end