Class: BeyondApi::Connection
- Inherits:
-
Object
- Object
- BeyondApi::Connection
- Defined in:
- lib/beyond_api/connection.rb
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.default ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/beyond_api/connection.rb', line 10 def self.default Faraday.new(ssl: { verify: true }) do |faraday| faraday.adapter(:net_http) faraday.[:open_timeout] = BeyondApi.configuration.open_timeout.to_i faraday.[:timeout] = BeyondApi.configuration.timeout.to_i faraday.headers["Accept"] = "application/json" faraday.headers["Content-Type"] = "application/json" faraday.request(:multipart) faraday.request(:url_encoded) faraday.request(:retry, BeyondApi.configuration.) faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers, bodies: BeyondApi.configuration.log_bodies } end end |
.multipart ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/beyond_api/connection.rb', line 40 def self.multipart Faraday.new(ssl: { verify: true }) do |faraday| faraday.[:open_timeout] = BeyondApi.configuration.open_timeout.to_i faraday.[:timeout] = BeyondApi.configuration.timeout.to_i faraday.request :multipart, { flat_encode: true } faraday.adapter Faraday.default_adapter end end |
.token ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/beyond_api/connection.rb', line 25 def self.token Faraday.new(ssl: { verify: true }) do |faraday| faraday.[:open_timeout] = BeyondApi.configuration.open_timeout.to_i faraday.[:timeout] = BeyondApi.configuration.timeout.to_i faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers, bodies: BeyondApi.configuration.log_bodies } do |logger| logger.filter(/(code=)([a-zA-Z0-9]+)/, '\1[FILTERED]') logger.filter(/(refresh_token=)([a-zA-Z0-9.\-\_]+)/, '\1[FILTERED]') end faraday.headers['Accept'] = 'application/json' faraday.adapter(:net_http) faraday.request :basic_auth, BeyondApi.configuration.client_id, BeyondApi.configuration.client_secret end end |