Class: ActiveCampaign::Client
- Inherits:
-
Object
- Object
- ActiveCampaign::Client
- Includes:
- API, TransformHash
- Defined in:
- lib/active_campaign/client.rb
Overview
Provides http request functionality
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#connection ⇒ Object
rubocop:disable Metrics/AbcSize.
- #delete(*args) ⇒ Object
- #get(*args) ⇒ Object
-
#initialize(conf = {}) ⇒ Client
constructor
A new instance of Client.
- #post(*args) ⇒ Object
- #put(*args) ⇒ Object
-
#transform_key(key, *new_case) ⇒ Symbol
included
from TransformHash
Transform the provided keys case and lastly symbolize it.
-
#transform_keys(hash, *new_case) ⇒ Hash
included
from TransformHash
Transforms case of all hash keys.
-
#transform_value(value, *new_case) ⇒ Object
included
from TransformHash
Transform all values.
Constructor Details
#initialize(conf = {}) ⇒ Client
Returns a new instance of Client.
22 23 24 |
# File 'lib/active_campaign/client.rb', line 22 def initialize(conf = {}) @config = conf end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/active_campaign/client.rb', line 20 def config @config end |
Instance Method Details
#connection ⇒ Object
rubocop:disable Metrics/AbcSize
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_campaign/client.rb', line 26 def connection # rubocop:disable Metrics/AbcSize @connection ||= ::Faraday.new(url: config[:api_url]) do |faraday| ActiveCampaign::Faraday::Middleware.add_request_middleware(faraday, config) ActiveCampaign::Faraday::Middleware.add_response_middleware(faraday, config[:response_middleware]) faraday.adapter config[:adapter] if ( = faraday.) .timeout = config[:api_timeout] .open_timeout = .timeout end faraday end end |
#delete(*args) ⇒ Object
54 55 56 57 58 |
# File 'lib/active_campaign/client.rb', line 54 def delete(*args) safe_http_call do connection.delete(*args) end end |
#get(*args) ⇒ Object
60 61 62 63 64 |
# File 'lib/active_campaign/client.rb', line 60 def get(*args) safe_http_call do connection.get(*args) end end |
#post(*args) ⇒ Object
42 43 44 45 46 |
# File 'lib/active_campaign/client.rb', line 42 def post(*args) safe_http_call do connection.post(*args) end end |
#put(*args) ⇒ Object
48 49 50 51 52 |
# File 'lib/active_campaign/client.rb', line 48 def put(*args) safe_http_call do connection.put(*args) end end |
#transform_key(key, *new_case) ⇒ Symbol Originally defined in module TransformHash
Transform the provided keys case and lastly symbolize it
#transform_keys(hash, *new_case) ⇒ Hash Originally defined in module TransformHash
Note:
this is used to always output a hash response
Transforms case of all hash keys
#transform_value(value, *new_case) ⇒ Object Originally defined in module TransformHash
Note:
used for nested values like hashes and arrays
Transform all values