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) - integer - Payment ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
Instance Method Summary collapse
-
#amount ⇒ Object
float - Line item amount.
-
#balance ⇒ Object
float - 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 - Associated invoice line items.
-
#method ⇒ Object
string - Line item payment method.
-
#payment_line_items ⇒ Object
array - 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.
-
#updated_at ⇒ Object
date-time - Line item updated at.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Payment
Returns a new instance of Payment.
7 8 9 10 |
# File 'lib/files.com/models/payment.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/payment.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/payment.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
95 96 97 |
# File 'lib/files.com/models/payment.rb', line 95 def self.all(params = {}, = {}) list(params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Payment ID.
101 102 103 104 105 106 107 108 109 |
# File 'lib/files.com/models/payment.rb', line 101 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/payments/#{params[:id]}", :get, params, ) AccountLineItem.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
111 112 113 |
# File 'lib/files.com/models/payment.rb', line 111 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
86 87 88 89 90 91 92 93 |
# File 'lib/files.com/models/payment.rb', line 86 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) response, = Api.send_request("/payments", :get, params, ) response.data.map { |object| AccountLineItem.new(object, ) } end |
Instance Method Details
#amount ⇒ Object
float - Line item amount
18 19 20 |
# File 'lib/files.com/models/payment.rb', line 18 def amount @attributes[:amount] end |
#balance ⇒ Object
float - Line item balance
23 24 25 |
# File 'lib/files.com/models/payment.rb', line 23 def balance @attributes[:balance] end |
#created_at ⇒ Object
date-time - Line item created at
28 29 30 |
# File 'lib/files.com/models/payment.rb', line 28 def created_at @attributes[:created_at] end |
#currency ⇒ Object
string - Line item currency
33 34 35 |
# File 'lib/files.com/models/payment.rb', line 33 def currency @attributes[:currency] end |
#download_uri ⇒ Object
string - Line item download uri
38 39 40 |
# File 'lib/files.com/models/payment.rb', line 38 def download_uri @attributes[:download_uri] end |
#id ⇒ Object
int64 - Line item Id
13 14 15 |
# File 'lib/files.com/models/payment.rb', line 13 def id @attributes[:id] end |
#invoice_line_items ⇒ Object
array - Associated invoice line items
43 44 45 |
# File 'lib/files.com/models/payment.rb', line 43 def invoice_line_items @attributes[:invoice_line_items] end |
#method ⇒ Object
string - Line item payment method
48 49 50 |
# File 'lib/files.com/models/payment.rb', line 48 def method @attributes[:method] end |
#payment_line_items ⇒ Object
array - Associated payment line items
53 54 55 |
# File 'lib/files.com/models/payment.rb', line 53 def payment_line_items @attributes[:payment_line_items] end |
#payment_reversed_at ⇒ Object
date-time - Date/time payment was reversed if applicable
58 59 60 |
# File 'lib/files.com/models/payment.rb', line 58 def payment_reversed_at @attributes[:payment_reversed_at] end |
#payment_type ⇒ Object
string - Type of payment if applicable
63 64 65 |
# File 'lib/files.com/models/payment.rb', line 63 def payment_type @attributes[:payment_type] end |
#site_name ⇒ Object
string - Site name this line item is for
68 69 70 |
# File 'lib/files.com/models/payment.rb', line 68 def site_name @attributes[:site_name] end |
#type ⇒ Object
string - Type of line item, either payment or invoice
73 74 75 |
# File 'lib/files.com/models/payment.rb', line 73 def type @attributes[:type] end |
#updated_at ⇒ Object
date-time - Line item updated at
78 79 80 |
# File 'lib/files.com/models/payment.rb', line 78 def updated_at @attributes[:updated_at] end |