-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.rb
38 lines (30 loc) · 1.02 KB
/
example.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'engaging_networks_rest'
require 'faraday/detailed_logger'
require 'byebug'
def instrument_connection_with_extended_logging(client)
default_options = {
headers: {
'Accept' => 'application/json;q=0.1',
'Accept-Charset' => 'utf-8'
}
}
faraday_builder = lambda do |faraday|
faraday.request :json
faraday.response :json, content_type: /\bjson$/
faraday.use Faraday::Response::Logger if ENV['DEBUG']
faraday.use EngagingNetworksRest::Response::RaiseError
faraday.response :detailed_logger
faraday.adapter Faraday.default_adapter
end
instrumented_connection = Faraday.new(
default_options.merge(url: "https://#{EngagingNetworksRest::Client::ENS_DOMAIN}"),
&faraday_builder
)
client.instance_variable_set(:@connection, instrumented_connection)
end
client = EngagingNetworksRest.new(api_key: ENV['EN_API_KEY'])
instrument_connection_with_extended_logging(client)
byebug
puts 'Bye!'