Class: ZaiPayment::Client
- Inherits:
-
Object
- Object
- ZaiPayment::Client
- Defined in:
- lib/zai_payment/client.rb
Overview
Base API client that handles HTTP requests to Zai API
Instance Attribute Summary collapse
-
#base_endpoint ⇒ Object
readonly
Returns the value of attribute base_endpoint.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#token_provider ⇒ Object
readonly
Returns the value of attribute token_provider.
Instance Method Summary collapse
-
#delete(path) ⇒ Response
Perform a DELETE request.
-
#get(path, params: {}) ⇒ Response
Perform a GET request.
-
#initialize(config: nil, token_provider: nil, base_endpoint: nil) ⇒ Client
constructor
A new instance of Client.
-
#patch(path, body: {}) ⇒ Response
Perform a PATCH request.
-
#post(path, body: {}) ⇒ Response
Perform a POST request.
Constructor Details
#initialize(config: nil, token_provider: nil, base_endpoint: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/zai_payment/client.rb', line 10 def initialize(config: nil, token_provider: nil, base_endpoint: nil) @config = config || ZaiPayment.config @token_provider = token_provider || ZaiPayment.auth @base_endpoint = base_endpoint end |
Instance Attribute Details
#base_endpoint ⇒ Object (readonly)
Returns the value of attribute base_endpoint.
8 9 10 |
# File 'lib/zai_payment/client.rb', line 8 def base_endpoint @base_endpoint end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/zai_payment/client.rb', line 8 def config @config end |
#token_provider ⇒ Object (readonly)
Returns the value of attribute token_provider.
8 9 10 |
# File 'lib/zai_payment/client.rb', line 8 def token_provider @token_provider end |
Instance Method Details
#delete(path) ⇒ Response
Perform a DELETE request
47 48 49 |
# File 'lib/zai_payment/client.rb', line 47 def delete(path) request(:delete, path) end |
#get(path, params: {}) ⇒ Response
Perform a GET request
21 22 23 |
# File 'lib/zai_payment/client.rb', line 21 def get(path, params: {}) request(:get, path, params: params) end |
#patch(path, body: {}) ⇒ Response
Perform a PATCH request
39 40 41 |
# File 'lib/zai_payment/client.rb', line 39 def patch(path, body: {}) request(:patch, path, body: body) end |
#post(path, body: {}) ⇒ Response
Perform a POST request
30 31 32 |
# File 'lib/zai_payment/client.rb', line 30 def post(path, body: {}) request(:post, path, body: body) end |