Class: Tikkie::Api::V1::Requests::PaymentRequests
- Inherits:
-
Object
- Object
- Tikkie::Api::V1::Requests::PaymentRequests
- Defined in:
- lib/tikkie/api/v1/requests/payment_requests.rb
Overview
Payment requests operations at Tikkie.
Instance Method Summary collapse
- #create(platform_token, user_token, bank_account_token, options = {}) ⇒ Object
- #get(platform_token, user_token, payment_request_token) ⇒ Object
-
#initialize(request) ⇒ PaymentRequests
constructor
A new instance of PaymentRequests.
- #list(platform_token, user_token, options = {}) ⇒ Object
Constructor Details
#initialize(request) ⇒ PaymentRequests
Returns a new instance of PaymentRequests.
11 12 13 |
# File 'lib/tikkie/api/v1/requests/payment_requests.rb', line 11 def initialize(request) @request = request end |
Instance Method Details
#create(platform_token, user_token, bank_account_token, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tikkie/api/v1/requests/payment_requests.rb', line 35 def create(platform_token, user_token, bank_account_token, = {}) params = { currency: .fetch(:currency), description: .fetch(:description) } params[:amountInCents] = to_cents([:amount]) if .key?(:amount) params[:externalId] = [:external_id] if .key?(:external_id) response = @request.post("/tikkie/platforms/#{platform_token}/users/#{user_token}/bankaccounts/#{bank_account_token}/paymentrequests", params) Tikkie::Api::V1::Responses::PaymentRequestCreated.new(response) end |
#get(platform_token, user_token, payment_request_token) ⇒ Object
29 30 31 32 33 |
# File 'lib/tikkie/api/v1/requests/payment_requests.rb', line 29 def get(platform_token, user_token, payment_request_token) response = @request.get("/tikkie/platforms/#{platform_token}/users/#{user_token}/paymentrequests/#{payment_request_token}") Tikkie::Api::V1::Responses::PaymentRequest.new(response) end |
#list(platform_token, user_token, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tikkie/api/v1/requests/payment_requests.rb', line 15 def list(platform_token, user_token, = {}) offset = [:offset] || 0 limit = [:limit] || 20 from_date = [:from_date] to_date = [:to_date] params = { offset: offset, limit: limit } params[:fromDate] = from_date.respond_to?(:utc) ? from_date.utc.iso8601 : from_date if from_date params[:toDate] = to_date.respond_to?(:utc) ? to_date.utc.iso8601 : to_date if to_date response = @request.get("/tikkie/platforms/#{platform_token}/users/#{user_token}/paymentrequests", params) Tikkie::Api::V1::Responses::PaymentRequests.new(response, offset: offset, limit: limit) end |