Class: Wizypay::ApiClient
- Inherits:
-
Object
- Object
- Wizypay::ApiClient
- Defined in:
- lib/wizypay/api_client.rb
Class Attribute Summary collapse
-
.api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.api_secret ⇒ Object
Returns the value of attribute api_secret.
Class Method Summary collapse
- .delete(path) ⇒ Object
- .execute(path, req_params) ⇒ Object
- .get(path, params = {}) ⇒ Object
- .post(path, payload = {}) ⇒ Object
- .put(path, payload = {}) ⇒ Object
Class Attribute Details
.api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
6 7 8 |
# File 'lib/wizypay/api_client.rb', line 6 def api_endpoint @api_endpoint end |
.api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/wizypay/api_client.rb', line 6 def api_key @api_key end |
.api_secret ⇒ Object
Returns the value of attribute api_secret.
6 7 8 |
# File 'lib/wizypay/api_client.rb', line 6 def api_secret @api_secret end |
Class Method Details
.delete(path) ⇒ Object
20 21 22 |
# File 'lib/wizypay/api_client.rb', line 20 def delete(path) execute(path, { method: :delete }) end |
.execute(path, req_params) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/wizypay/api_client.rb', line 24 def execute(path, req_params) req_params.deep_merge!( url: "#{api_endpoint}#{path}", headers: { accept: :json } ) req = RestClient::Request.new(req_params) req.sign!(api_key, api_secret) parse_response req.execute end |
.get(path, params = {}) ⇒ Object
16 17 18 |
# File 'lib/wizypay/api_client.rb', line 16 def get(path, params = {}) execute(path, { method: :get, headers: { params: params } }) end |
.post(path, payload = {}) ⇒ Object
8 9 10 |
# File 'lib/wizypay/api_client.rb', line 8 def post(path, payload = {}) execute(path, { method: :post, payload: payload }) end |
.put(path, payload = {}) ⇒ Object
12 13 14 |
# File 'lib/wizypay/api_client.rb', line 12 def put(path, payload = {}) execute(path, { method: :put, payload: payload }) end |