Class: YNAB::SaveSubTransaction
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- YNAB::SaveSubTransaction
- Defined in:
- lib/ynab/models/save_sub_transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
The subtransaction amount in milliunits format.
-
#category_id ⇒ Object
The category for the subtransaction.
-
#memo ⇒ Object
Returns the value of attribute memo.
-
#payee_id ⇒ Object
The payee for the subtransaction.
-
#payee_name ⇒ Object
The payee name.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ SaveSubTransaction
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ SaveSubTransaction
Initializes the object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 68 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveSubTransaction` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveSubTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'amount') self.amount = attributes[:'amount'] end if attributes.key?(:'payee_id') self.payee_id = attributes[:'payee_id'] end if attributes.key?(:'payee_name') self.payee_name = attributes[:'payee_name'] end if attributes.key?(:'category_id') self.category_id = attributes[:'category_id'] end if attributes.key?(:'memo') self.memo = attributes[:'memo'] end end |
Instance Attribute Details
#amount ⇒ Object
The subtransaction amount in milliunits format.
16 17 18 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 16 def amount @amount end |
#category_id ⇒ Object
The category for the subtransaction. Credit Card Payment categories are not permitted and will be ignored if supplied.
25 26 27 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 25 def category_id @category_id end |
#memo ⇒ Object
Returns the value of attribute memo.
27 28 29 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 27 def memo @memo end |
#payee_id ⇒ Object
The payee for the subtransaction.
19 20 21 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 19 def payee_id @payee_id end |
#payee_name ⇒ Object
The payee name. If a payee_name value is provided and payee_id has a null value, the payee_name value will be used to resolve the payee by either (1) a matching payee rename rule (only if import_id is also specified on parent transaction) or (2) a payee with the same name or (3) creation of a new payee.
22 23 24 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 22 def payee_name @payee_name end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
41 42 43 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 41 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
30 31 32 33 34 35 36 37 38 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 30 def self.attribute_map { :'amount' => :'amount', :'payee_id' => :'payee_id', :'payee_name' => :'payee_name', :'category_id' => :'category_id', :'memo' => :'memo' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 157 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
57 58 59 60 61 62 63 64 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 57 def self.openapi_nullable Set.new([ :'payee_id', :'payee_name', :'category_id', :'memo' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
46 47 48 49 50 51 52 53 54 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 46 def self.openapi_types { :'amount' => :'Integer', :'payee_id' => :'String', :'payee_name' => :'String', :'category_id' => :'String', :'memo' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
132 133 134 135 136 137 138 139 140 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 132 def ==(o) return true if self.equal?(o) self.class == o.class && amount == o.amount && payee_id == o.payee_id && payee_name == o.payee_name && category_id == o.category_id && memo == o.memo end |
#eql?(o) ⇒ Boolean
144 145 146 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 144 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
150 151 152 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 150 def hash [amount, payee_id, payee_name, category_id, memo].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
104 105 106 107 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 104 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 179 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
111 112 113 114 115 116 |
# File 'lib/ynab/models/save_sub_transaction.rb', line 111 def valid? return false if @amount.nil? return false if !@payee_name.nil? && @payee_name.to_s.length > 200 return false if !@memo.nil? && @memo.to_s.length > 500 true end |