Class: ThePlaidApi::TransactionLocation
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ThePlaidApi::TransactionLocation
- Defined in:
- lib/the_plaid_api/models/transaction_location.rb
Overview
A representation of where a transaction took place. Location data is provided only for transactions at physical locations, not for online transactions. Location data availability depends primarily on the merchant and is most likely to be populated for transactions at large retail chains; small, local businesses are less likely to have location data available.
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.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 83 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.
18 19 20 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 18 def address @address end |
#city ⇒ String
The city where the transaction occurred.
22 23 24 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 22 def city @city end |
#country ⇒ String
The ISO 3166-1 alpha-2 country code where the transaction occurred.
36 37 38 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 36 def country @country end |
#lat ⇒ Float
The latitude where the transaction occurred.
40 41 42 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 40 def lat @lat end |
#lon ⇒ Float
The longitude where the transaction occurred.
44 45 46 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 44 def lon @lon end |
#postal_code ⇒ String
The postal code where the transaction occurred. In API versions 2018-05-22 and earlier, this field is called ‘zip`.
32 33 34 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 32 def postal_code @postal_code end |
#region ⇒ String
The region or state where the transaction occurred. In API versions 2018-05-22 and earlier, this field is called ‘state`.
27 28 29 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 27 def region @region end |
#store_number ⇒ String
The merchant defined store number where the transaction occurred.
48 49 50 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 48 def store_number @store_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 125 126 127 128 129 130 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 100 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.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 51 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
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 70 def self.nullables %w[ address city region postal_code country lat lon store_number ] end |
.optionals ⇒ Object
An array for optional fields
65 66 67 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 65 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
141 142 143 144 145 146 147 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 141 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.
133 134 135 136 137 138 |
# File 'lib/the_plaid_api/models/transaction_location.rb', line 133 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 |