Class: Pin::Transfer
Overview
This class models Pin’s Transfers API
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.all(page = nil, pagination = false) ⇒ Object
Returns a paginated list of all transfers.
-
.create(options) ⇒ Object
Creates a new transfer and returns its details.
-
.find(token) ⇒ Object
Returns the details of a transfer.
-
.line_items(token, page = nil, pagination = false) ⇒ Object
Returns the line items associated with transfer.
-
.search(page = nil, pagination = false, **options) ⇒ Object
Find a transfer(s) for your account given a search term or set of terms args: options (Hash) returns: a collection of transfer objects.
Methods inherited from Base
#base_uri, build_collection_response, build_response, #initialize, make_request
Constructor Details
This class inherits a constructor from Pin::Base
Class Method Details
.all(page = nil, pagination = false) ⇒ Object
Returns a paginated list of all transfers. page: page (Fixnum), pagination (Boolean)
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
21 22 23 |
# File 'lib/pin_up/transfer.rb', line 21 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, {url: "transfers?page=#{page}" } ), pagination) end |
.create(options) ⇒ Object
Creates a new transfer and returns its details. pinpayments.com/docs/api/transfers#post-transfers args: options (Hash)
9 10 11 |
# File 'lib/pin_up/transfer.rb', line 9 def self.create() build_response(make_request(:post, { url: 'transfers', options: })) end |
.find(token) ⇒ Object
Returns the details of a transfer. args: token (String) returns: a transfer pinpayments.com/docs/api/transfers#get-transfer
30 31 32 |
# File 'lib/pin_up/transfer.rb', line 30 def self.find(token) build_response(make_request(:get, {url: "transfers/#{token}" } )) end |
.line_items(token, page = nil, pagination = false) ⇒ Object
Returns the line items associated with transfer. args: token (String), page (Fixnum), pagination (Boolean)
57 58 59 |
# File 'lib/pin_up/transfer.rb', line 57 def self.line_items(token, page = nil, pagination = false) build_collection_response(make_request(:get, {url: "transfers/#{token}/line_items?page=#{page}" } ), pagination) end |
.search(page = nil, pagination = false, **options) ⇒ Object
Find a transfer(s) for your account given a search term or set of terms args: options (Hash) returns: a collection of transfer objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
42 43 44 45 46 47 48 49 50 |
# File 'lib/pin_up/transfer.rb', line 42 def self.search(page = nil, pagination = false, **) term = '' .merge! page: page if page .each do |key, option| term += "#{key.to_s}=#{CGI.escape(option.to_s)}&" end build_collection_response(make_request(:get, {url: "transfers/search?#{term}" } ), pagination) end |