Class: Files::Payment
- Inherits:
-
Object
- Object
- Files::Payment
- Defined in:
- lib/files.com/models/payment.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Payment ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
Instance Method Summary collapse
-
#amount ⇒ Object
decimal - Line item amount.
-
#balance ⇒ Object
decimal - Line item balance.
-
#created_at ⇒ Object
date-time - Line item created at.
-
#currency ⇒ Object
string - Line item currency.
-
#download_uri ⇒ Object
string - Line item download uri.
-
#id ⇒ Object
int64 - Line item Id.
-
#initialize(attributes = {}, options = {}) ⇒ Payment
constructor
A new instance of Payment.
-
#invoice_line_items ⇒ Object
array(object) - Associated invoice line items.
-
#method ⇒ Object
string - Line item payment method.
-
#payment_line_items ⇒ Object
array(object) - Associated payment line items.
-
#payment_reversed_at ⇒ Object
date-time - Date/time payment was reversed if applicable.
-
#payment_type ⇒ Object
string - Type of payment if applicable.
-
#site_name ⇒ Object
string - Site name this line item is for.
-
#type ⇒ Object
string - Type of line item, either payment or invoice.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Payment
Returns a new instance of Payment.
9 10 11 12 |
# File 'lib/files.com/models/payment.rb', line 9 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/files.com/models/payment.rb', line 7 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/files.com/models/payment.rb', line 7 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
97 98 99 |
# File 'lib/files.com/models/payment.rb', line 97 def self.all(params = {}, = {}) list(params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Payment ID.
103 104 105 106 107 108 109 110 111 |
# File 'lib/files.com/models/payment.rb', line 103 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/payments/#{params[:id]}", :get, params, ) AccountLineItem.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
113 114 115 |
# File 'lib/files.com/models/payment.rb', line 113 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
88 89 90 91 92 93 94 95 |
# File 'lib/files.com/models/payment.rb', line 88 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) List.new(AccountLineItem, params) do Api.send_request("/payments", :get, params, ) end end |
Instance Method Details
#amount ⇒ Object
decimal - Line item amount
20 21 22 23 24 25 |
# File 'lib/files.com/models/payment.rb', line 20 def amount value = @attributes[:amount] return value if value.nil? || value.is_a?(BigDecimal) BigDecimal(value.to_s) end |
#balance ⇒ Object
decimal - Line item balance
28 29 30 31 32 33 |
# File 'lib/files.com/models/payment.rb', line 28 def balance value = @attributes[:balance] return value if value.nil? || value.is_a?(BigDecimal) BigDecimal(value.to_s) end |
#created_at ⇒ Object
date-time - Line item created at
36 37 38 |
# File 'lib/files.com/models/payment.rb', line 36 def created_at @attributes[:created_at] end |
#currency ⇒ Object
string - Line item currency
41 42 43 |
# File 'lib/files.com/models/payment.rb', line 41 def currency @attributes[:currency] end |
#download_uri ⇒ Object
string - Line item download uri
46 47 48 |
# File 'lib/files.com/models/payment.rb', line 46 def download_uri @attributes[:download_uri] end |
#id ⇒ Object
int64 - Line item Id
15 16 17 |
# File 'lib/files.com/models/payment.rb', line 15 def id @attributes[:id] end |
#invoice_line_items ⇒ Object
array(object) - Associated invoice line items
51 52 53 |
# File 'lib/files.com/models/payment.rb', line 51 def invoice_line_items @attributes[:invoice_line_items] end |
#method ⇒ Object
string - Line item payment method
56 57 58 |
# File 'lib/files.com/models/payment.rb', line 56 def method @attributes[:method] end |
#payment_line_items ⇒ Object
array(object) - Associated payment line items
61 62 63 |
# File 'lib/files.com/models/payment.rb', line 61 def payment_line_items @attributes[:payment_line_items] end |
#payment_reversed_at ⇒ Object
date-time - Date/time payment was reversed if applicable
66 67 68 |
# File 'lib/files.com/models/payment.rb', line 66 def payment_reversed_at @attributes[:payment_reversed_at] end |
#payment_type ⇒ Object
string - Type of payment if applicable
71 72 73 |
# File 'lib/files.com/models/payment.rb', line 71 def payment_type @attributes[:payment_type] end |
#site_name ⇒ Object
string - Site name this line item is for
76 77 78 |
# File 'lib/files.com/models/payment.rb', line 76 def site_name @attributes[:site_name] end |
#type ⇒ Object
string - Type of line item, either payment or invoice
81 82 83 |
# File 'lib/files.com/models/payment.rb', line 81 def type @attributes[:type] end |