Class: Plaid::TransactionLocation
- Defined in:
- lib/plaid/models/transaction_location.rb
Overview
A representation of where a transaction took place
Instance Attribute Summary collapse
-
#address ⇒ String
The street address where the transaction occurred.
-
#city ⇒ String
The city where the transaction occurred.
-
#country ⇒ String
The ISO 3166-1 alpha-2 country code where the transaction occurred.
-
#lat ⇒ Float
The latitude where the transaction occurred.
-
#lon ⇒ Float
The longitude where the transaction occurred.
-
#postal_code ⇒ String
The postal code where the transaction occurred.
-
#region ⇒ String
The region or state where the transaction occurred.
-
#store_number ⇒ String
The merchant defined store number where the transaction occurred.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(address:, city:, region:, postal_code:, country:, lat:, lon:, store_number:, additional_properties: nil) ⇒ TransactionLocation
constructor
A new instance of TransactionLocation.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(address:, city:, region:, postal_code:, country:, lat:, lon:, store_number:, additional_properties: nil) ⇒ TransactionLocation
Returns a new instance of TransactionLocation.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/plaid/models/transaction_location.rb', line 77 def initialize(address:, city:, region:, postal_code:, country:, lat:, lon:, store_number:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @address = address @city = city @region = region @postal_code = postal_code @country = country @lat = lat @lon = lon @store_number = store_number @additional_properties = additional_properties end |
Instance Attribute Details
#address ⇒ String
The street address where the transaction occurred.
14 15 16 |
# File 'lib/plaid/models/transaction_location.rb', line 14 def address @address end |
#city ⇒ String
The city where the transaction occurred.
18 19 20 |
# File 'lib/plaid/models/transaction_location.rb', line 18 def city @city end |
#country ⇒ String
The ISO 3166-1 alpha-2 country code where the transaction occurred.
30 31 32 |
# File 'lib/plaid/models/transaction_location.rb', line 30 def country @country end |
#lat ⇒ Float
The latitude where the transaction occurred.
34 35 36 |
# File 'lib/plaid/models/transaction_location.rb', line 34 def lat @lat end |
#lon ⇒ Float
The longitude where the transaction occurred.
38 39 40 |
# File 'lib/plaid/models/transaction_location.rb', line 38 def lon @lon end |
#postal_code ⇒ String
The postal code where the transaction occurred.
26 27 28 |
# File 'lib/plaid/models/transaction_location.rb', line 26 def postal_code @postal_code end |
#region ⇒ String
The region or state where the transaction occurred.
22 23 24 |
# File 'lib/plaid/models/transaction_location.rb', line 22 def region @region end |
#store_number ⇒ String
The merchant defined store number where the transaction occurred.
42 43 44 |
# File 'lib/plaid/models/transaction_location.rb', line 42 def store_number @store_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/plaid/models/transaction_location.rb', line 94 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. address = hash.key?('address') ? hash['address'] : nil city = hash.key?('city') ? hash['city'] : nil region = hash.key?('region') ? hash['region'] : nil postal_code = hash.key?('postal_code') ? hash['postal_code'] : nil country = hash.key?('country') ? hash['country'] : nil lat = hash.key?('lat') ? hash['lat'] : nil lon = hash.key?('lon') ? hash['lon'] : nil store_number = hash.key?('store_number') ? hash['store_number'] : nil # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. TransactionLocation.new(address: address, city: city, region: region, postal_code: postal_code, country: country, lat: lat, lon: lon, store_number: store_number, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/plaid/models/transaction_location.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['address'] = 'address' @_hash['city'] = 'city' @_hash['region'] = 'region' @_hash['postal_code'] = 'postal_code' @_hash['country'] = 'country' @_hash['lat'] = 'lat' @_hash['lon'] = 'lon' @_hash['store_number'] = 'store_number' @_hash end |
.nullables ⇒ Object
An array for nullable fields
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/plaid/models/transaction_location.rb', line 64 def self.nullables %w[ address city region postal_code country lat lon store_number ] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 |
# File 'lib/plaid/models/transaction_location.rb', line 59 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
135 136 137 138 139 140 141 |
# File 'lib/plaid/models/transaction_location.rb', line 135 def inspect class_name = self.class.name.split('::').last "<#{class_name} address: #{@address.inspect}, city: #{@city.inspect}, region:"\ " #{@region.inspect}, postal_code: #{@postal_code.inspect}, country: #{@country.inspect},"\ " lat: #{@lat.inspect}, lon: #{@lon.inspect}, store_number: #{@store_number.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
127 128 129 130 131 132 |
# File 'lib/plaid/models/transaction_location.rb', line 127 def to_s class_name = self.class.name.split('::').last "<#{class_name} address: #{@address}, city: #{@city}, region: #{@region}, postal_code:"\ " #{@postal_code}, country: #{@country}, lat: #{@lat}, lon: #{@lon}, store_number:"\ " #{@store_number}, additional_properties: #{@additional_properties}>" end |