Class: SmartyStreets::InternationalStreet::Lookup
- Inherits:
-
Object
- Object
- SmartyStreets::InternationalStreet::Lookup
- Defined in:
- lib/smartystreets_ruby_sdk/international_street/lookup.rb
Overview
In addition to holding all of the input data for this lookup, this class also will contain the result of the lookup after it comes back from the API.
Note: Lookups must have certain required fields set with non-blank values. These can be found at the URL below.
See “smartystreets.com/docs/cloud/international-street-api#http-input-fields”
- @geocode
-
Disabled by default. Set to true to enable.
- @language
-
When not set, the output language will match the language of the input values.
When set to language_mode.NATIVE, the results will always be in the language of the output country.
When set to language_mode.LATIN, the results will always be provided using a Latin character set.
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#address3 ⇒ Object
Returns the value of attribute address3.
-
#address4 ⇒ Object
Returns the value of attribute address4.
-
#administrative_area ⇒ Object
Returns the value of attribute administrative_area.
-
#country ⇒ Object
Returns the value of attribute country.
-
#custom_param_hash ⇒ Object
Returns the value of attribute custom_param_hash.
-
#features ⇒ Object
Returns the value of attribute features.
-
#freeform ⇒ Object
Returns the value of attribute freeform.
-
#geocode ⇒ Object
Returns the value of attribute geocode.
-
#input_id ⇒ Object
Returns the value of attribute input_id.
-
#inputId ⇒ Object
Returns the value of attribute inputId.
-
#language ⇒ Object
Returns the value of attribute language.
-
#locality ⇒ Object
Returns the value of attribute locality.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #add_custom_parameter(parameter, value) ⇒ Object
- #ensure_enough_info ⇒ Object
- #field_is_missing(field) ⇒ Object
- #field_is_set(field) ⇒ Object
- #has_freeform ⇒ Object
- #has_postal_code ⇒ Object
-
#initialize(freeform = nil, country = nil) ⇒ Lookup
constructor
A new instance of Lookup.
- #missing_address1 ⇒ Object
- #missing_country ⇒ Object
- #missing_locality_or_administrative_area ⇒ Object
Constructor Details
#initialize(freeform = nil, country = nil) ⇒ Lookup
Returns a new instance of Lookup.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 21 def initialize(freeform=nil, country=nil) @result = [] @input_id = nil @country = country @geocode = nil @language = nil @freeform = freeform @address1 = nil @address2 = nil @address3 = nil @address4 = nil @organization = nil @locality = nil @administrative_area = nil @postal_code = nil @features = nil @custom_param_hash = {} end |
Instance Attribute Details
#address1 ⇒ Object
Returns the value of attribute address1.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def address2 @address2 end |
#address3 ⇒ Object
Returns the value of attribute address3.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def address3 @address3 end |
#address4 ⇒ Object
Returns the value of attribute address4.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def address4 @address4 end |
#administrative_area ⇒ Object
Returns the value of attribute administrative_area.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def administrative_area @administrative_area end |
#country ⇒ Object
Returns the value of attribute country.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def country @country end |
#custom_param_hash ⇒ Object
Returns the value of attribute custom_param_hash.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def custom_param_hash @custom_param_hash end |
#features ⇒ Object
Returns the value of attribute features.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def features @features end |
#freeform ⇒ Object
Returns the value of attribute freeform.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def freeform @freeform end |
#geocode ⇒ Object
Returns the value of attribute geocode.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def geocode @geocode end |
#input_id ⇒ Object
Returns the value of attribute input_id.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def input_id @input_id end |
#inputId ⇒ Object
Returns the value of attribute inputId.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def inputId @inputId end |
#language ⇒ Object
Returns the value of attribute language.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def language @language end |
#locality ⇒ Object
Returns the value of attribute locality.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def locality @locality end |
#organization ⇒ Object
Returns the value of attribute organization.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def organization @organization end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def postal_code @postal_code end |
#result ⇒ Object
Returns the value of attribute result.
17 18 19 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 17 def result @result end |
Instance Method Details
#add_custom_parameter(parameter, value) ⇒ Object
41 42 43 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 41 def add_custom_parameter(parameter, value) @custom_param_hash[parameter] = value end |
#ensure_enough_info ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 73 def ensure_enough_info raise UnprocessableEntityError, 'Country field is required.' if missing_country return true if has_freeform raise UnprocessableEntityError, 'Either freeform or address1 is required.' if missing_address1 return true if has_postal_code if missing_locality_or_administrative_area raise UnprocessableEntityError, 'Insufficient information:'\ 'One or more required fields were not set on the lookup.' end end |
#field_is_missing(field) ⇒ Object
65 66 67 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 65 def field_is_missing(field) field.nil? or field.empty? end |
#field_is_set(field) ⇒ Object
69 70 71 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 69 def field_is_set(field) not field_is_missing(field) end |
#has_freeform ⇒ Object
49 50 51 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 49 def has_freeform field_is_set(@freeform) end |
#has_postal_code ⇒ Object
57 58 59 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 57 def has_postal_code field_is_set(@postal_code) end |
#missing_address1 ⇒ Object
53 54 55 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 53 def missing_address1 field_is_missing(@address1) end |
#missing_country ⇒ Object
45 46 47 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 45 def missing_country field_is_missing(@country) end |
#missing_locality_or_administrative_area ⇒ Object
61 62 63 |
# File 'lib/smartystreets_ruby_sdk/international_street/lookup.rb', line 61 def missing_locality_or_administrative_area field_is_missing(@locality) or field_is_missing(@administrative_area) end |