module Adyen::REST
The Adyen::REST
module allows you to interact with Adyen's REST
API
.
The primary method here is {Adyen::REST.session}, which will yield a {Adyen::REST::Client} which you can use to send API
requests.
If you need more than one client instance, for instance because you have multiple acounts set up with different permissions, you can instantiate clients yourself using {Adyen::REST::Client.new}
@example Using the singleton Client
instance
Adyen::REST.session do |client| client.http.read_timeout = 5 response = client.api_request(...) # ... end
@example Using a your own Client
instance
Adyen::REST::Client.new('test', 'username', 'password').session do |client| client.http.read_timeout = 5 response = client.api_request(...) # ... end
@see Adyen::REST.session
Use Adyen::REST.session
to run code against the API
. @see Adyen::REST::Client
Adyen::REST::Client
implements the actual API
calls.
Public Class Methods
Provides a singelton REST
API
client this is configured using the values in Adyen.configuration
.
@param options [Hash] (see Adyen::REST::Client#initialize) @return [Adyen::REST::Client] A configured client instance @see .session @see Adyen::REST::Client.new
To instantiate Clients yourself, in case you need more than one.
# File lib/adyen/rest.rb 44 def self.client 45 Adyen::REST::Client.new( 46 Adyen.configuration.environment, 47 Adyen.configuration.api_username, 48 Adyen.configuration.api_password, 49 Adyen.configuration.merchant_specific_endpoint 50 ) 51 end
Exectutes a session against the Adyen
REST
API
.
It will use a standard client from {Adyen::REST.client}, or it uses a provided client. The client will be yielded to the block, and will be closed after the block is finisged
@param client [Adyen::REST::Client] A custom API
client if a default one won't do. @yield The provided block will be called in which you can interact with the API
using
the provided client. The client will be closed after the block returns.
@yieldparam client [Adyen::REST::Client] The REST
client to use for the session. @return [void] @see Adyen::REST::Client#session
# File lib/adyen/rest.rb 64 def self.session(client = self.client, &block) 65 client.session(&block) 66 end