Class: BitPesa::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bitpesa/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.base_urlObject (readonly)

Returns the value of attribute base_url.



20
21
22
# File 'lib/bitpesa/client.rb', line 20

def base_url
  @base_url
end

.debugObject

Returns the value of attribute debug.



19
20
21
# File 'lib/bitpesa/client.rb', line 19

def debug
  @debug
end

.hostObject

Returns the value of attribute host.



19
20
21
# File 'lib/bitpesa/client.rb', line 19

def host
  @host
end

.keyObject

Returns the value of attribute key.



19
20
21
# File 'lib/bitpesa/client.rb', line 19

def key
  @key
end

.secretObject

Returns the value of attribute secret.



19
20
21
# File 'lib/bitpesa/client.rb', line 19

def secret
  @secret
end

.timeoutObject

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