Class: Beze::Client
- Inherits:
-
Object
- Object
- Beze::Client
- Defined in:
- lib/beze/client.rb
Overview
Client that acts as a middleman to the API.
Defined Under Namespace
Classes: BezeErrorResult, BezeResult
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource, payload, options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(resource, payload, options) ⇒ Client
Returns a new instance of Client.
35 36 37 38 39 |
# File 'lib/beze/client.rb', line 35 def initialize(resource, payload, ) @resource = resource @payload = payload @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/beze/client.rb', line 29 def @options end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
29 30 31 |
# File 'lib/beze/client.rb', line 29 def payload @payload end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
29 30 31 |
# File 'lib/beze/client.rb', line 29 def resource @resource end |
Class Method Details
.call(resource:, payload:, options:) ⇒ Object
31 32 33 |
# File 'lib/beze/client.rb', line 31 def self.call(resource:, payload:, options:) new(resource, payload, ).call end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/beze/client.rb', line 41 def call body = payload headers = [:headers] params = [:params] uri = "#{Beze::BASE_URL}/#{Beze.configuration.api_version}/#{resource}/#{[:uri]}" http_call = Beze::HttpClient.call(body: body, headers: headers, method: method, params: params, uri: uri) if http_call.successful? BezesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.}") else BezeErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.}") end end |