Class: Codat::Client
- Inherits:
-
Object
- Object
- Codat::Client
- Defined in:
- lib/codat/client.rb
Constant Summary collapse
- BASE_URLS =
{ production: 'https://api.codat.io/', uat: 'https://api-uat.codat.io/' }.freeze
Instance Method Summary collapse
- #connection ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/codat/client.rb', line 14 def initialize Faraday::Request.register_middleware codat_auth: -> { Codat::FaradayCodatAuth } end |
Instance Method Details
#connection ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/codat/client.rb', line 26 def connection @connection ||= Faraday.new(url: api_url) do |conn| conn.request :codat_auth, Codat.configuration.api_key conn.response :json, parser_options: { symbolize_names: true } # conn.response :logger # if Codat.configuration.debug? conn.adapter Faraday.default_adapter end end |
#get(path, params = {}) ⇒ Object
18 19 20 |
# File 'lib/codat/client.rb', line 18 def get(path, params = {}) connection.get(path, params) end |
#post(path, params = {}) ⇒ Object
22 23 24 |
# File 'lib/codat/client.rb', line 22 def post(path, params = {}) connection.post(path, MultiJson.dump(params)) end |