Class: DskRb::Client
- Inherits:
-
Object
- Object
- DskRb::Client
- Defined in:
- lib/dsk_rb/client.rb
Constant Summary collapse
- BASE_URLS =
{ uat: 'https://uat.dskbank.bg' }.freeze
Instance Method Summary collapse
- #get_order_status(order_id) ⇒ Object
-
#initialize(username:, password:, environment:) ⇒ Client
constructor
A new instance of Client.
- #payment_registration(params) ⇒ Object
- #refund_payment(params) ⇒ Object
Constructor Details
#initialize(username:, password:, environment:) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 |
# File 'lib/dsk_rb/client.rb', line 7 def initialize(username:, password:, environment:) @username = username @password = password @environment = environment.to_sym validate_environment @base_url = BASE_URLS[@environment] end |
Instance Method Details
#get_order_status(order_id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dsk_rb/client.rb', line 28 def get_order_status(order_id) params = { orderId: order_id } response = connection.post('/payment/rest/getOrderStatus.do') do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = URI.encode_www_form(default_params.merge(params)) end JSON.parse(response.body) end |
#payment_registration(params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dsk_rb/client.rb', line 17 def payment_registration(params) camelized_params = params.transform_keys { |key| key.to_s.camelize(:lower) } response = connection.post('/payment/rest/register.do') do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = URI.encode_www_form(default_params.merge(camelized_params)) end JSON.parse(response.body) end |
#refund_payment(params) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dsk_rb/client.rb', line 39 def refund_payment(params) camelized_params = params.transform_keys { |key| key.to_s.camelize(:lower) } response = connection.post('/payment/rest/refund.do') do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = URI.encode_www_form(default_params.merge(camelized_params)) end JSON.parse(response.body) end |