-
Notifications
You must be signed in to change notification settings - Fork 1
Client customizations
Ilya Krukowski edited this page Apr 10, 2022
·
1 revision
@client = RatingChgkV2.client params: {open_timeout: 100, timeout: 500}
We use Faraday to perform requests. The default adapter is built-in Net::HTTP
but you can customize it.
For example, to use Excon:
require 'excon' # somewhere in your code
Faraday.default_adapter = :excon
Please note that since the release of Faraday 2, most adapters have to be added manually.
By default we use a standard JSON library, but you can choose any other gem.
For example, to use Oj:
require 'oj'
module RatingChgkV2
module JsonHandler
# This method accepts a Ruby object and must return a JSON string
def custom_dump(obj)
Oj.dump obj
end
# This method accepts JSON and must return Ruby object
def custom_load(obj)
Oj.load obj
end
end
end
Basically, you have to redefine custom_dump
and custom_load
methods somewhere in your code.