Class: WalletPay::Client

Inherits:
Object
  • Object
show all
Extended by:
HTTP
Defined in:
lib/wallet_pay/client.rb

Constant Summary

Constants included from HTTP

HTTP::SUCCESS_STATUSES

Instance Method Summary collapse

Methods included from HTTP

get, json_post

Constructor Details

#initialize(token: nil, url: nil, request_timeout: nil, extra_headers: nil, api_version: nil) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/wallet_pay/client.rb', line 7

def initialize(token: nil, url: nil, request_timeout: nil, extra_headers: nil, api_version: nil)
  WalletPay.configuration.token = token if token
  WalletPay.configuration.url = url if url
  WalletPay.configuration.api_version = api_version if api_version
  WalletPay.configuration.request_timeout = request_timeout if request_timeout
  WalletPay.configuration.extra_headers = extra_headers if extra_headers
end

Instance Method Details

#create_order(amount:, description:, user_id:, external_id:, **params) ⇒ Object



31
32
33
34
# File 'lib/wallet_pay/client.rb', line 31

def create_order(amount:, description:, user_id:, external_id:, **params)
  WalletPay::Client.json_post(path: "/order",
                              parameters: order_params(amount, description, user_id, external_id, params))
end

#order_preview(order_id:) ⇒ Object



21
22
23
# File 'lib/wallet_pay/client.rb', line 21

def order_preview(order_id:)
  WalletPay::Client.get(path: "/order/preview?id=#{order_id}")
end

#orders_amountObject



26
27
28
# File 'lib/wallet_pay/client.rb', line 26

def orders_amount
  WalletPay::Client.get(path: "/reconciliation/order-amount")
end

#orders_list(limit: 100, offset: 0) ⇒ Object



16
17
18
# File 'lib/wallet_pay/client.rb', line 16

def orders_list(limit: 100, offset: 0)
  WalletPay::Client.get(path: "/reconciliation/order-list?offset=#{offset}&count=#{limit}")
end