Class: FlatApi::CreditTransaction
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- FlatApi::CreditTransaction
- Defined in:
- lib/flat_api/models/credit_transaction.rb
Overview
A single credit ledger entry
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#amount ⇒ Object
How many credits this entry moved, signed: positive for top-ups (
+30from a credit pack), negative for deductions (-2for a two-page import). -
#creation_date ⇒ Object
When the transaction was created.
-
#feature ⇒ Object
Which product the credits relate to.
-
#id ⇒ Object
Unique identifier of the credit transaction.
-
#job ⇒ Object
Identifier of the import this entry belongs to, when it relates to one.
-
#modification_date ⇒ Object
When the transaction was last modified.
-
#source ⇒ Object
Which pool the credits came from: *
subscription: the plan's periodic allowance *purchase: credits bought as a pack, which do not expire with the billing period *free_tier: promotional grants *support: a manual adjustment made by Flat's support team A single import can produce two entries when it spans two pools: the plan allowance is drawn down first, and the remainder comes frompurchase. -
#state ⇒ Object
Whether the entry still counts: *
active: in effect *canceled: reversed, and no longer affecting the balance. -
#type ⇒ Object
Credit category.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.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 = {}) ⇒ CreditTransaction
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 = {}) ⇒ CreditTransaction
Initializes the object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/flat_api/models/credit_transaction.rb', line 116 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `FlatApi::CreditTransaction` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `FlatApi::CreditTransaction`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'type') self.type = attributes[:'type'] else self.type = nil end if attributes.key?(:'feature') self.feature = attributes[:'feature'] end if attributes.key?(:'amount') self.amount = attributes[:'amount'] else self.amount = nil end if attributes.key?(:'source') self.source = attributes[:'source'] else self.source = nil end if attributes.key?(:'state') self.state = attributes[:'state'] else self.state = nil end if attributes.key?(:'job') self.job = attributes[:'job'] end if attributes.key?(:'creation_date') self.creation_date = attributes[:'creation_date'] else self.creation_date = nil end if attributes.key?(:'modification_date') self.modification_date = attributes[:'modification_date'] else self.modification_date = nil end end |
Instance Attribute Details
#amount ⇒ Object
How many credits this entry moved, signed: positive for top-ups (+30 from a credit pack), negative for deductions (-2 for a two-page import). Sum only entries whose state is active.
29 30 31 |
# File 'lib/flat_api/models/credit_transaction.rb', line 29 def amount @amount end |
#creation_date ⇒ Object
When the transaction was created
41 42 43 |
# File 'lib/flat_api/models/credit_transaction.rb', line 41 def creation_date @creation_date end |
#feature ⇒ Object
Which product the credits relate to. Set on deductions and on the credits a refund returns, absent on credit-pack top-ups, which are not tied to a single feature.
26 27 28 |
# File 'lib/flat_api/models/credit_transaction.rb', line 26 def feature @feature end |
#id ⇒ Object
Unique identifier of the credit transaction
20 21 22 |
# File 'lib/flat_api/models/credit_transaction.rb', line 20 def id @id end |
#job ⇒ Object
Identifier of the import this entry belongs to, when it relates to one. Present on an import's deduction, on its reversal, and on credits returned when an import is refunded. Absent on credit-pack top-ups and manual adjustments.
38 39 40 |
# File 'lib/flat_api/models/credit_transaction.rb', line 38 def job @job end |
#modification_date ⇒ Object
When the transaction was last modified
44 45 46 |
# File 'lib/flat_api/models/credit_transaction.rb', line 44 def modification_date @modification_date end |
#source ⇒ Object
Which pool the credits came from: * subscription: the plan's periodic allowance * purchase: credits bought as a pack, which do not expire with the billing period * free_tier: promotional grants * support: a manual adjustment made by Flat's support team A single import can produce two entries when it spans two pools: the plan allowance is drawn down first, and the remainder comes from purchase.
32 33 34 |
# File 'lib/flat_api/models/credit_transaction.rb', line 32 def source @source end |
#state ⇒ Object
Whether the entry still counts: * active: in effect * canceled: reversed, and no longer affecting the balance. Deductions are canceled when the import they paid for fails or is refunded.
35 36 37 |
# File 'lib/flat_api/models/credit_transaction.rb', line 35 def state @state end |
#type ⇒ Object
Credit category. ai covers every AI-powered feature.
23 24 25 |
# File 'lib/flat_api/models/credit_transaction.rb', line 23 def type @type end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
84 85 86 |
# File 'lib/flat_api/models/credit_transaction.rb', line 84 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
89 90 91 |
# File 'lib/flat_api/models/credit_transaction.rb', line 89 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/flat_api/models/credit_transaction.rb', line 69 def self.attribute_map { :'id' => :'id', :'type' => :'type', :'feature' => :'feature', :'amount' => :'amount', :'source' => :'source', :'state' => :'state', :'job' => :'job', :'creation_date' => :'creationDate', :'modification_date' => :'modificationDate' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/flat_api/models/credit_transaction.rb', line 350 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
109 110 111 112 |
# File 'lib/flat_api/models/credit_transaction.rb', line 109 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/flat_api/models/credit_transaction.rb', line 94 def self.openapi_types { :'id' => :'String', :'type' => :'String', :'feature' => :'String', :'amount' => :'Integer', :'source' => :'String', :'state' => :'String', :'job' => :'String', :'creation_date' => :'Time', :'modification_date' => :'Time' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/flat_api/models/credit_transaction.rb', line 321 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && type == o.type && feature == o.feature && amount == o.amount && source == o.source && state == o.state && job == o.job && creation_date == o.creation_date && modification_date == o.modification_date end |
#eql?(o) ⇒ Boolean
337 338 339 |
# File 'lib/flat_api/models/credit_transaction.rb', line 337 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
343 344 345 |
# File 'lib/flat_api/models/credit_transaction.rb', line 343 def hash [id, type, feature, amount, source, state, job, creation_date, modification_date].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/flat_api/models/credit_transaction.rb', line 183 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end if @amount.nil? invalid_properties.push('invalid value for "amount", amount cannot be nil.') end if @source.nil? invalid_properties.push('invalid value for "source", source cannot be nil.') end if @state.nil? invalid_properties.push('invalid value for "state", state cannot be nil.') end if @creation_date.nil? invalid_properties.push('invalid value for "creation_date", creation_date cannot be nil.') end if @modification_date.nil? invalid_properties.push('invalid value for "modification_date", modification_date cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/flat_api/models/credit_transaction.rb', line 372 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
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/flat_api/models/credit_transaction.rb', line 219 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @id.nil? return false if @type.nil? type_validator = EnumAttributeValidator.new('String', ["ai"]) return false unless type_validator.valid?(@type) feature_validator = EnumAttributeValidator.new('String', ["omr"]) return false unless feature_validator.valid?(@feature) return false if @amount.nil? return false if @source.nil? source_validator = EnumAttributeValidator.new('String', ["subscription", "purchase", "free_tier", "support"]) return false unless source_validator.valid?(@source) return false if @state.nil? state_validator = EnumAttributeValidator.new('String', ["active", "canceled"]) return false unless state_validator.valid?(@state) return false if @creation_date.nil? return false if @modification_date.nil? true end |