Class: SmartyStreets::USAutocomplete::Lookup

Inherits:
JSONAble
  • Object
show all
Defined in:
lib/smartystreets_ruby_sdk/us_autocomplete/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.

See “www.smarty.com/docs/apis/us-autocomplete-v2/reference#http-request-input-fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from JSONAble

#from_json!, #to_json

Constructor Details

#initialize(search = nil, max_results = nil, city_filter = nil, state_filter = nil, zip_filter = nil, exclude_states = nil, prefer_cities = nil, prefer_states = nil, prefer_zips = nil, prefer_ratio = nil, prefer_geolocation = nil, selected = nil, exclude = nil, source = nil, custom_param_hash = nil) ⇒ Lookup

Returns a new instance of Lookup.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 15

def initialize(search=nil, max_results=nil, city_filter=nil, state_filter=nil, zip_filter=nil,
               exclude_states=nil, prefer_cities=nil, prefer_states=nil, prefer_zips=nil, prefer_ratio=nil,
               prefer_geolocation=nil, selected=nil, exclude=nil, source=nil, custom_param_hash=nil)
  @result = []
  @search = search
  @max_results = max_results
  @city_filter = city_filter ? city_filter : []
  @state_filter = state_filter ? state_filter : []
  @zip_filter = zip_filter ? zip_filter : []
  @exclude_states = exclude_states ? exclude_states : []
  @prefer_cities = prefer_cities ? prefer_cities : []
  @prefer_states = prefer_states ? prefer_states : []
  @prefer_zip_codes = prefer_zips ? prefer_zips : []
  @prefer_ratio = prefer_ratio
  @prefer_geolocation = prefer_geolocation
  @selected = selected
  @exclude = exclude ? exclude : []
  @source = source
  @custom_param_hash = {}
end

Instance Attribute Details

#city_filterObject

Returns the value of attribute city_filter.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def city_filter
  @city_filter
end

#custom_param_hashObject

Returns the value of attribute custom_param_hash.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def custom_param_hash
  @custom_param_hash
end

#excludeObject

Returns the value of attribute exclude.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def exclude
  @exclude
end

#exclude_statesObject

Returns the value of attribute exclude_states.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def exclude_states
  @exclude_states
end

#max_resultsObject

Returns the value of attribute max_results.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def max_results
  @max_results
end

#prefer_citiesObject

Returns the value of attribute prefer_cities.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def prefer_cities
  @prefer_cities
end

#prefer_geolocationObject

Returns the value of attribute prefer_geolocation.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def prefer_geolocation
  @prefer_geolocation
end

#prefer_ratioObject

Returns the value of attribute prefer_ratio.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def prefer_ratio
  @prefer_ratio
end

#prefer_statesObject

Returns the value of attribute prefer_states.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def prefer_states
  @prefer_states
end

#prefer_zip_codesObject

Returns the value of attribute prefer_zip_codes.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def prefer_zip_codes
  @prefer_zip_codes
end

#resultObject

Returns the value of attribute result.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def result
  @result
end

#searchObject

Returns the value of attribute search.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def search
  @search
end

#selectedObject

Returns the value of attribute selected.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def selected
  @selected
end

#sourceObject

Returns the value of attribute source.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def source
  @source
end

#state_filterObject

Returns the value of attribute state_filter.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def state_filter
  @state_filter
end

#zip_filterObject

Returns the value of attribute zip_filter.



11
12
13
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 11

def zip_filter
  @zip_filter
end

Instance Method Details

#add_city_filter(city) ⇒ Object



40
41
42
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 40

def add_city_filter(city)
  @city_filter.push(city)
end

#add_custom_parameter(parameter, value) ⇒ Object



36
37
38
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 36

def add_custom_parameter(parameter, value)
  @custom_param_hash[parameter] = value
end

#add_exclude(exclude_type) ⇒ Object



68
69
70
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 68

def add_exclude(exclude_type)
  @exclude.push(exclude_type)
end

#add_preferred_city(city) ⇒ Object



56
57
58
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 56

def add_preferred_city(city)
  @prefer_cities.push(city)
end

#add_preferred_state(state) ⇒ Object



60
61
62
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 60

def add_preferred_state(state)
  @prefer_states.push(state)
end

#add_preferred_zip(zip) ⇒ Object



64
65
66
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 64

def add_preferred_zip(zip)
  @prefer_zip_codes.push(zip)
end

#add_state_exclusion(state) ⇒ Object



52
53
54
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 52

def add_state_exclusion(state)
  @exclude_states.push(state)
end

#add_state_filter(state) ⇒ Object



44
45
46
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 44

def add_state_filter(state)
  @state_filter.push(state)
end

#add_zip_filter(zip) ⇒ Object



48
49
50
# File 'lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb', line 48

def add_zip_filter(zip)
  @zip_filter.push(zip)
end