Class: BitPesa::Client
- Inherits:
-
Object
- Object
- BitPesa::Client
- Defined in:
- lib/bitpesa/client.rb
Class Attribute Summary collapse
-
.base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
.debug ⇒ Object
Returns the value of attribute debug.
-
.host ⇒ Object
Returns the value of attribute host.
-
.key ⇒ Object
Returns the value of attribute key.
-
.secret ⇒ Object
Returns the value of attribute secret.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
- .delete(endpoint) ⇒ Object
- .get(endpoint, payload = nil) ⇒ Object
- .patch(endpoint, payload = {}) ⇒ Object
- .post(endpoint, payload = {}) ⇒ Object
- .put(endpoint, payload = {}) ⇒ Object
Class Attribute Details
.base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
20 21 22 |
# File 'lib/bitpesa/client.rb', line 20 def base_url @base_url end |
.debug ⇒ Object
Returns the value of attribute debug.
19 20 21 |
# File 'lib/bitpesa/client.rb', line 19 def debug @debug end |
.host ⇒ Object
Returns the value of attribute host.
19 20 21 |
# File 'lib/bitpesa/client.rb', line 19 def host @host end |
.key ⇒ Object
Returns the value of attribute key.
19 20 21 |
# File 'lib/bitpesa/client.rb', line 19 def key @key end |
.secret ⇒ Object
Returns the value of attribute secret.
19 20 21 |
# File 'lib/bitpesa/client.rb', line 19 def secret @secret end |
.timeout ⇒ Object
Returns the value of attribute timeout.
19 20 21 |
# File 'lib/bitpesa/client.rb', line 19 def timeout @timeout end |
Class Method Details
.delete(endpoint) ⇒ Object
43 44 45 |
# File 'lib/bitpesa/client.rb', line 43 def delete(endpoint) request "DELETE", request_url(endpoint) end |
.get(endpoint, payload = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/bitpesa/client.rb', line 22 def get(endpoint, payload=nil) url = request_url(endpoint) url += "?" + URI.encode_www_form(payload) if payload request "GET", url end |
.patch(endpoint, payload = {}) ⇒ Object
38 39 40 41 |
# File 'lib/bitpesa/client.rb', line 38 def patch(endpoint, payload={}) body = JSON.generate(payload) request "PATCH", request_url(endpoint), body end |
.post(endpoint, payload = {}) ⇒ Object
28 29 30 31 |
# File 'lib/bitpesa/client.rb', line 28 def post(endpoint, payload={}) body = JSON.generate(payload) request "POST", request_url(endpoint), body end |
.put(endpoint, payload = {}) ⇒ Object
33 34 35 36 |
# File 'lib/bitpesa/client.rb', line 33 def put(endpoint, payload={}) body = JSON.generate(payload) request "PUT", request_url(endpoint), body end |