smartystreets_ruby_sdk 0.0.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/{LICENSE.md → LICENSE.txt} +1 -1
  4. data/Makefile +17 -31
  5. data/README.md +6 -9
  6. data/Rakefile +2 -5
  7. data/examples/us_street_multiple_address_example.rb +15 -40
  8. data/examples/us_street_single_address_example.rb +8 -32
  9. data/examples/us_zipcode_multiple_lookup_example.rb +9 -21
  10. data/examples/us_zipcode_single_lookup_example.rb +6 -18
  11. data/lib/smartystreets_ruby_sdk/batch.rb +38 -45
  12. data/lib/smartystreets_ruby_sdk/core_client_builder.rb +56 -0
  13. data/lib/smartystreets_ruby_sdk/custom_header_sender.rb +8 -10
  14. data/lib/smartystreets_ruby_sdk/errors.rb +11 -21
  15. data/lib/smartystreets_ruby_sdk/exceptions.rb +16 -27
  16. data/lib/smartystreets_ruby_sdk/json_able.rb +11 -13
  17. data/lib/smartystreets_ruby_sdk/match_type.rb +5 -0
  18. data/lib/smartystreets_ruby_sdk/native_sender.rb +43 -65
  19. data/lib/smartystreets_ruby_sdk/native_serializer.rb +7 -9
  20. data/lib/smartystreets_ruby_sdk/request.rb +8 -11
  21. data/lib/smartystreets_ruby_sdk/response.rb +7 -9
  22. data/lib/smartystreets_ruby_sdk/retry_sender.rb +26 -32
  23. data/lib/smartystreets_ruby_sdk/shared_credentials.rb +9 -11
  24. data/lib/smartystreets_ruby_sdk/signing_sender.rb +9 -11
  25. data/lib/smartystreets_ruby_sdk/sleeper.rb +3 -5
  26. data/lib/smartystreets_ruby_sdk/static_credentials.rb +9 -11
  27. data/lib/smartystreets_ruby_sdk/status_code_sender.rb +29 -33
  28. data/lib/smartystreets_ruby_sdk/url_prefix_sender.rb +9 -11
  29. data/lib/smartystreets_ruby_sdk/us_street/analysis.rb +16 -21
  30. data/lib/smartystreets_ruby_sdk/us_street/candidate.rb +19 -23
  31. data/lib/smartystreets_ruby_sdk/us_street/client.rb +47 -60
  32. data/lib/smartystreets_ruby_sdk/us_street/client_builder.rb +15 -0
  33. data/lib/smartystreets_ruby_sdk/us_street/components.rb +27 -32
  34. data/lib/smartystreets_ruby_sdk/us_street/lookup.rb +20 -27
  35. data/lib/smartystreets_ruby_sdk/us_street/metadata.rb +23 -27
  36. data/lib/smartystreets_ruby_sdk/us_street.rb +3 -5
  37. data/lib/smartystreets_ruby_sdk/us_zipcode/city.rb +8 -14
  38. data/lib/smartystreets_ruby_sdk/us_zipcode/client.rb +36 -51
  39. data/lib/smartystreets_ruby_sdk/us_zipcode/client_builder.rb +15 -0
  40. data/lib/smartystreets_ruby_sdk/us_zipcode/lookup.rb +9 -16
  41. data/lib/smartystreets_ruby_sdk/us_zipcode/result.rb +30 -34
  42. data/lib/smartystreets_ruby_sdk/us_zipcode/zip_code.rb +14 -32
  43. data/lib/smartystreets_ruby_sdk/us_zipcode.rb +3 -5
  44. data/lib/smartystreets_ruby_sdk/version.rb +2 -2
  45. data/lib/smartystreets_ruby_sdk.rb +1 -30
  46. data/smartystreets_ruby_sdk.gemspec +12 -3
  47. metadata +15 -61
  48. data/.github/workflows/gem-publish.yml +0 -58
  49. data/CHANGELOG.md +0 -5
  50. data/Dockerfile +0 -10
  51. data/docker-compose.yml +0 -12
  52. data/examples/international_autocomplete_example.rb +0 -47
  53. data/examples/international_example.rb +0 -53
  54. data/examples/us_autocomplete_pro_example.rb +0 -56
  55. data/examples/us_extract_example.rb +0 -63
  56. data/examples/us_reverse_geo_example.rb +0 -47
  57. data/lib/smartystreets_ruby_sdk/client_builder.rb +0 -188
  58. data/lib/smartystreets_ruby_sdk/international_autocomplete/client.rb +0 -61
  59. data/lib/smartystreets_ruby_sdk/international_autocomplete/lookup.rb +0 -21
  60. data/lib/smartystreets_ruby_sdk/international_autocomplete/suggestion.rb +0 -16
  61. data/lib/smartystreets_ruby_sdk/international_street/analysis.rb +0 -17
  62. data/lib/smartystreets_ruby_sdk/international_street/candidate.rb +0 -23
  63. data/lib/smartystreets_ruby_sdk/international_street/changes.rb +0 -15
  64. data/lib/smartystreets_ruby_sdk/international_street/client.rb +0 -63
  65. data/lib/smartystreets_ruby_sdk/international_street/components.rb +0 -58
  66. data/lib/smartystreets_ruby_sdk/international_street/language_mode.rb +0 -9
  67. data/lib/smartystreets_ruby_sdk/international_street/lookup.rb +0 -82
  68. data/lib/smartystreets_ruby_sdk/international_street/metadata.rb +0 -17
  69. data/lib/smartystreets_ruby_sdk/international_street/rootlevel.rb +0 -25
  70. data/lib/smartystreets_ruby_sdk/international_street.rb +0 -12
  71. data/lib/smartystreets_ruby_sdk/license_sender.rb +0 -15
  72. data/lib/smartystreets_ruby_sdk/logger.rb +0 -7
  73. data/lib/smartystreets_ruby_sdk/proxy.rb +0 -16
  74. data/lib/smartystreets_ruby_sdk/us_autocomplete/client.rb +0 -72
  75. data/lib/smartystreets_ruby_sdk/us_autocomplete/geolocation_type.rb +0 -9
  76. data/lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb +0 -38
  77. data/lib/smartystreets_ruby_sdk/us_autocomplete/suggestion.rb +0 -16
  78. data/lib/smartystreets_ruby_sdk/us_autocomplete.rb +0 -9
  79. data/lib/smartystreets_ruby_sdk/us_autocomplete_pro/client.rb +0 -78
  80. data/lib/smartystreets_ruby_sdk/us_autocomplete_pro/geolocation_type.rb +0 -8
  81. data/lib/smartystreets_ruby_sdk/us_autocomplete_pro/lookup.rb +0 -63
  82. data/lib/smartystreets_ruby_sdk/us_autocomplete_pro/suggestion.rb +0 -18
  83. data/lib/smartystreets_ruby_sdk/us_autocomplete_pro.rb +0 -10
  84. data/lib/smartystreets_ruby_sdk/us_extract/address.rb +0 -24
  85. data/lib/smartystreets_ruby_sdk/us_extract/client.rb +0 -49
  86. data/lib/smartystreets_ruby_sdk/us_extract/lookup.rb +0 -22
  87. data/lib/smartystreets_ruby_sdk/us_extract/metadata.rb +0 -17
  88. data/lib/smartystreets_ruby_sdk/us_extract/result.rb +0 -21
  89. data/lib/smartystreets_ruby_sdk/us_extract.rb +0 -10
  90. data/lib/smartystreets_ruby_sdk/us_reverse_geo/address.rb +0 -16
  91. data/lib/smartystreets_ruby_sdk/us_reverse_geo/client.rb +0 -38
  92. data/lib/smartystreets_ruby_sdk/us_reverse_geo/coordinate.rb +0 -25
  93. data/lib/smartystreets_ruby_sdk/us_reverse_geo/lookup.rb +0 -21
  94. data/lib/smartystreets_ruby_sdk/us_reverse_geo/result.rb +0 -20
  95. data/lib/smartystreets_ruby_sdk/us_reverse_geo/us_reverse_geo_response.rb +0 -17
  96. data/lib/smartystreets_ruby_sdk/us_reverse_geo.rb +0 -12
  97. data/lib/smartystreets_ruby_sdk/us_street/match_type.rb +0 -10
  98. data/lib/smartystreets_ruby_sdk/us_zipcode/alternate_county.rb +0 -15
  99. data/ruby-sdk-demo.json +0 -354
@@ -1,188 +0,0 @@
1
- require_relative 'native_serializer'
2
- require_relative 'native_sender'
3
- require_relative 'status_code_sender'
4
- require_relative 'signing_sender'
5
- require_relative 'retry_sender'
6
- require_relative 'url_prefix_sender'
7
- require_relative 'license_sender'
8
- require_relative 'sleeper'
9
- require_relative 'logger'
10
- require_relative 'proxy'
11
- require_relative 'custom_header_sender'
12
- require_relative 'us_street/client'
13
- require_relative 'us_zipcode/client'
14
- require_relative 'us_extract/client'
15
- require_relative 'us_autocomplete/client'
16
- require_relative 'international_street/client'
17
- require_relative 'us_reverse_geo/client'
18
- require_relative 'us_autocomplete_pro/client'
19
-
20
- module SmartyStreets
21
- # The ClientBuilder class helps you build a client object for one of the supported SmartyStreets APIs.
22
- # You can use ClientBuilder's methods to customize settings like maximum retries or timeout duration.
23
- # These methods are chainable, so you can usually get set up with one line of code.
24
- class ClientBuilder
25
- INTERNATIONAL_STREET_API_URL = 'https://international-street.api.smartystreets.com/verify'.freeze
26
- INTERNATIONAL_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smartystreets.com/lookup".freeze
27
- US_AUTOCOMPLETE_API_URL = 'https://us-autocomplete.api.smartystreets.com/suggest'.freeze
28
- US_AUTOCOMPLETE_PRO_API_URL = 'https://us-autocomplete-pro.api.smartystreets.com/lookup'.freeze
29
- US_EXTRACT_API_URL = 'https://us-extract.api.smartystreets.com/'.freeze
30
- US_STREET_API_URL = 'https://us-street.api.smartystreets.com/street-address'.freeze
31
- US_ZIP_CODE_API_URL = 'https://us-zipcode.api.smartystreets.com/lookup'.freeze
32
- US_REVERSE_GEO_API_URL = 'https://us-reverse-geo.api.smartystreets.com/lookup'.freeze
33
-
34
- def initialize(signer)
35
- @signer = signer
36
- @serializer = NativeSerializer.new
37
- @http_sender = nil
38
- @max_retries = 5
39
- @max_timeout = 10
40
- @url_prefix = nil
41
- @proxy = nil
42
- @headers = nil
43
- @licenses = %w()
44
- @debug = nil
45
- end
46
-
47
- # Sets the maximum number of times to retry sending the request to the API. (Default is 5)
48
- #
49
- # Returns self to accommodate method chaining.
50
- def retry_at_most(max_retries)
51
- @max_retries = max_retries
52
- self
53
- end
54
-
55
- # The maximum time (in seconds) to wait for the response to be read. (Default is 10)
56
- #
57
- # Returns self to accommodate method chaining.
58
- def with_max_timeout(max_timeout)
59
- @max_timeout = max_timeout
60
- self
61
- end
62
-
63
- # Default is a series of nested senders. (See build_sender()
64
- #
65
- # Returns self to accommodate method chaining.
66
- def with_sender(sender)
67
- @http_sender = sender
68
- self
69
- end
70
-
71
- # Changes the Serializer from the default.
72
- #
73
- # Returns self to accommodate method chaining.
74
- def with_serializer(serializer)
75
- @serializer = serializer
76
- self
77
- end
78
-
79
- # This may be useful when using a local installation of the SmartyStreets APIs.
80
- # base_url is a string that defaults to the URL for the API corresponding to the Client object being built.
81
- #
82
- # Returns self to accommodate method chaining.
83
- def with_base_url(base_url)
84
- @url_prefix = base_url
85
- self
86
- end
87
-
88
- # Assigns a proxy through which all requests will be sent.
89
- # proxy is a Proxy object from this module.
90
- #
91
- # Returns self to accommodate method chaining.
92
- def with_proxy(host, port, username, password)
93
- @proxy = SmartyStreets::Proxy.new(host, port, username, password)
94
- self
95
- end
96
-
97
- # Allows you to submit custom headers using a Hash.
98
- # headers is a Hash object.
99
- #
100
- # Returns self to accommodate method chaining.
101
- def with_custom_headers(headers)
102
- @headers = headers
103
- self
104
- end
105
-
106
- # Allows the caller to specify the subscription license (aka "track") they wish to use.
107
- #
108
- # Returns self to accommodate method chaining.
109
- def with_licenses(licenses)
110
- @licenses.concat licenses
111
- self
112
- end
113
-
114
- # Enables debug mode, which will print information about the HTTP request and response to $stdout.
115
- #
116
- # Returns self to accommodate method chaining.
117
- def with_debug
118
- @debug = true
119
- self
120
- end
121
-
122
- # <editor-fold desc="Build methods">
123
-
124
- def build_international_street_api_client
125
- ensure_url_prefix_not_null(INTERNATIONAL_STREET_API_URL)
126
- InternationalStreet::Client.new(build_sender, @serializer)
127
- end
128
-
129
- def build_international_autocomplete_api_client
130
- ensure_url_prefix_not_null(INTERNATIONAL_AUTOCOMPLETE_API_URL)
131
- InternationalAutocomplete::Client.new(build_sender, @serializer)
132
- end
133
-
134
- def build_us_autocomplete_api_client # Deprecated
135
- ensure_url_prefix_not_null(US_AUTOCOMPLETE_API_URL)
136
- USAutocomplete::Client.new(build_sender, @serializer)
137
- end
138
-
139
- def build_us_autocomplete_pro_api_client
140
- ensure_url_prefix_not_null(US_AUTOCOMPLETE_PRO_API_URL)
141
- USAutocompletePro::Client.new(build_sender, @serializer)
142
- end
143
-
144
- def build_us_extract_api_client
145
- ensure_url_prefix_not_null(US_EXTRACT_API_URL)
146
- USExtract::Client.new(build_sender, @serializer)
147
- end
148
-
149
- def build_us_street_api_client
150
- ensure_url_prefix_not_null(US_STREET_API_URL)
151
- USStreet::Client.new(build_sender, @serializer)
152
- end
153
-
154
- def build_us_zipcode_api_client
155
- ensure_url_prefix_not_null(US_ZIP_CODE_API_URL)
156
- USZipcode::Client.new(build_sender, @serializer)
157
- end
158
-
159
- def build_us_reverse_geo_api_client
160
- ensure_url_prefix_not_null(US_REVERSE_GEO_API_URL)
161
- USReverseGeo::Client.new(build_sender, @serializer)
162
- end
163
-
164
- # </editor-fold>
165
-
166
- def build_sender
167
- return @http_sender unless @http_sender.nil?
168
-
169
- sender = NativeSender.new(@max_timeout, @proxy, @debug)
170
-
171
- sender = StatusCodeSender.new(sender)
172
-
173
- sender = CustomHeaderSender.new(sender, @headers) unless @headers.nil?
174
-
175
- sender = SigningSender.new(@signer, sender) unless @signer.nil?
176
-
177
- sender = RetrySender.new(@max_retries, sender, SmartyStreets::Sleeper.new,SmartyStreets::Logger.new) if @max_retries > 0
178
-
179
- sender = LicenseSender.new(sender, @licenses)
180
-
181
- URLPrefixSender.new(@url_prefix, sender)
182
- end
183
-
184
- def ensure_url_prefix_not_null(url)
185
- @url_prefix = url if @url_prefix.nil?
186
- end
187
- end
188
- end
@@ -1,61 +0,0 @@
1
- require_relative '../request'
2
- require_relative '../exceptions'
3
- require_relative 'suggestion'
4
-
5
- module SmartyStreets
6
- module InternationalAutocomplete
7
- # It is recommended to instantiate this class using ClientBuilder.build_international_autocomplete_api_client
8
- class Client
9
- def initialize(sender, serializer)
10
- @sender = sender
11
- @serializer = serializer
12
- end
13
-
14
- # Sends a Lookup object to the International Autocomplete API and stores the result in the Lookup's result field.
15
- def send(lookup)
16
- if not lookup or not lookup.search
17
- raise SmartyStreets::SmartyError, 'Send() must be passed a Lookup with the prefix field set.'
18
- end
19
-
20
- request = build_request(lookup)
21
-
22
- response = @sender.send(request)
23
-
24
- raise response.error if response.error
25
-
26
- result = @serializer.deserialize(response.payload)
27
- suggestions = convert_suggestions(result.fetch('candidates', []))
28
- lookup.result = suggestions
29
- end
30
-
31
-
32
- def build_request(lookup)
33
- request = Request.new
34
-
35
- add_parameter(request, 'search', lookup.search)
36
- add_parameter(request, 'country', lookup.country)
37
- add_parameter(request, 'include_only_administrative_area', lookup.administrative_area)
38
- add_parameter(request, 'include_only_locality', lookup.locality)
39
- add_parameter(request, 'include_only_postal_code', lookup.postal_code)
40
-
41
- request
42
- end
43
-
44
- def convert_suggestions(suggestion_hashes)
45
- converted_suggestions = []
46
- return converted_suggestions if suggestion_hashes.nil?
47
-
48
- suggestion_hashes.each do |suggestion|
49
- converted_suggestions.push(InternationalAutocomplete::Suggestion.new(suggestion))
50
- end
51
-
52
- converted_suggestions
53
- end
54
-
55
- def add_parameter(request, key, value)
56
- request.parameters[key] = value unless value.nil? or value.empty?
57
- end
58
- end
59
- end
60
- end
61
-
@@ -1,21 +0,0 @@
1
- require_relative '../json_able'
2
-
3
- module SmartyStreets
4
- module InternationalAutocomplete
5
- # In addition to holding all of the input data for this lookup, this class also will contain the result
6
- # of the lookup after it comes back from the API.
7
- class Lookup < JSONAble
8
-
9
- attr_accessor :result, :search, :country, :administrative_area, :locality, :postal_code
10
-
11
- def initialize(search=nil, country=nil, administrative_area=nil, locality=nil, postal_code=nil)
12
- @result = []
13
- @search = search
14
- @country = country
15
- @administrative_area = administrative_area
16
- @locality = locality
17
- @postal_code = postal_code
18
- end
19
- end
20
- end
21
- end
@@ -1,16 +0,0 @@
1
- module SmartyStreets
2
- module InternationalAutocomplete
3
- class Suggestion
4
-
5
- attr_reader :street, :locality, :administrative_area, :postal_code, :country_iso3
6
-
7
- def initialize(obj)
8
- @street = obj.fetch('street', nil)
9
- @locality = obj.fetch('locality', nil)
10
- @administrative_area = obj.fetch('administrative_area', nil)
11
- @postal_code = obj.fetch('postal_code', nil)
12
- @country_iso3 = obj.fetch('country_iso3', nil)
13
- end
14
- end
15
- end
16
- end
@@ -1,17 +0,0 @@
1
- require_relative 'changes'
2
- module SmartyStreets
3
- module InternationalStreet
4
- # See "https://smartystreets.com/docs/cloud/international-street-api#analysis"
5
- class Analysis
6
-
7
- attr_reader :max_address_precision, :verification_status, :address_precision, :changes
8
-
9
- def initialize(obj)
10
- @verification_status = obj.fetch('verification_status', nil)
11
- @address_precision = obj.fetch('address_precision', nil)
12
- @max_address_precision = obj.fetch('max_address_precision', nil)
13
- @changes = Changes.new(obj.fetch('changes', {}))
14
- end
15
- end
16
- end
17
- end
@@ -1,23 +0,0 @@
1
- require_relative 'components'
2
- require_relative 'metadata'
3
- require_relative 'analysis'
4
- require_relative 'rootlevel'
5
-
6
- module SmartyStreets
7
- module InternationalStreet
8
- # A candidate is a possible match for an address that was submitted. A lookup can have multiple
9
- # candidates if the address was ambiguous.
10
- #
11
- # See "https://smartystreets.com/docs/cloud/international-street-api#root"
12
- class Candidate < RootLevel
13
- attr_reader :metadata, :components, :analysis
14
-
15
- def initialize(obj)
16
- @components = Components.new(obj.fetch('components', {}))
17
- @metadata = Metadata.new(obj.fetch('metadata', {}))
18
- @analysis = Analysis.new(obj.fetch('analysis', {}))
19
- super(obj)
20
- end
21
- end
22
- end
23
- end
@@ -1,15 +0,0 @@
1
- require_relative 'rootlevel'
2
- require_relative 'components'
3
-
4
- module SmartyStreets
5
- module InternationalStreet
6
- class Changes < RootLevel
7
- attr_reader :components
8
-
9
- def initialize(obj)
10
- @components = Components.new(obj.fetch('components', {}))
11
- super(obj)
12
- end
13
- end
14
- end
15
- end
@@ -1,63 +0,0 @@
1
- require_relative '../request'
2
- require_relative 'candidate'
3
-
4
- module SmartyStreets
5
- module InternationalStreet
6
- # It is recommended to instantiate this class using ClientBuilder.build_international_street_api_client()
7
- class Client
8
- def initialize(sender, serializer)
9
- @sender = sender
10
- @serializer = serializer
11
- end
12
-
13
- # Sends a Lookup object to the International Street API and stores the result in the Lookup's result field.
14
- def send(lookup)
15
- lookup.ensure_enough_info
16
- request = build_request(lookup)
17
-
18
- response = @sender.send(request)
19
-
20
- raise response.error if response.error
21
-
22
- candidates = convert_candidates(@serializer.deserialize(response.payload))
23
- lookup.result = candidates
24
- end
25
-
26
- def build_request(lookup)
27
- request = SmartyStreets::Request.new
28
-
29
- add_parameter(request, 'input_id', lookup.input_id)
30
- add_parameter(request, 'country', lookup.country)
31
- add_parameter(request, 'geocode', lookup.geocode.to_s)
32
- add_parameter(request, 'language', lookup.language)
33
- add_parameter(request, 'freeform', lookup.freeform)
34
- add_parameter(request, 'address1', lookup.address1)
35
- add_parameter(request, 'address2', lookup.address2)
36
- add_parameter(request, 'address3', lookup.address3)
37
- add_parameter(request, 'address4', lookup.address4)
38
- add_parameter(request, 'organization', lookup.organization)
39
- add_parameter(request, 'locality', lookup.locality)
40
- add_parameter(request, 'administrative_area', lookup.administrative_area)
41
- add_parameter(request, 'postal_code', lookup.postal_code)
42
-
43
- request
44
- end
45
-
46
- def add_parameter(request, key, value)
47
- request.parameters[key] = value unless value.nil? or value.empty?
48
- end
49
-
50
- def convert_candidates(raw_candidates)
51
- candidates = []
52
-
53
- unless raw_candidates.nil?
54
- raw_candidates.each do |candidate|
55
- candidates.push(Candidate.new(candidate))
56
- end
57
- end
58
-
59
- candidates
60
- end
61
- end
62
- end
63
- end
@@ -1,58 +0,0 @@
1
- module SmartyStreets
2
- module InternationalStreet
3
- # See "https://smartystreets.com/docs/cloud/international-street-api#components"
4
- class Components
5
- attr_reader :premise, :thoroughfare_trailing_type, :sub_building, :locality, :post_box_number,
6
- :thoroughfare_name, :thoroughfare_postdirection, :dependent_thoroughfare, :premise_prefix_number,
7
- :thoroughfare, :dependent_thoroughfare_name, :postal_code_short, :dependent_thoroughfare_trailing_type,
8
- :administrative_area, :post_box, :building_leading_type, :dependent_locality_name, :thoroughfare_type,
9
- :dependent_thoroughfare_postdirection, :double_dependent_locality, :premise_number,
10
- :dependent_thoroughfare_type, :post_box_type, :building, :sub_administrative_area, :postal_code_extra,
11
- :sub_building_name, :postal_code, :dependent_locality, :premise_type, :sub_building_number,
12
- :super_administrative_area, :premise_extra, :dependent_thoroughfare_predirection,
13
- :building_trailing_type, :thoroughfare_predirection, :building_name, :country_iso_3, :sub_building_type
14
-
15
- def initialize(obj)
16
- @country_iso_3 = obj.fetch('country_iso_3', nil)
17
- @super_administrative_area = obj.fetch('super_administrative_area', nil)
18
- @administrative_area = obj.fetch('administrative_area', nil)
19
- @sub_administrative_area = obj.fetch('sub_administrative_area', nil)
20
- @dependent_locality= obj.fetch('dependent_locality', nil)
21
- @dependent_locality_name = obj.fetch('dependent_locality_name', nil)
22
- @double_dependent_locality = obj.fetch('double_dependent_locality', nil)
23
- @locality = obj.fetch('locality', nil)
24
- @postal_code = obj.fetch('postal_code', nil)
25
- @postal_code_short = obj.fetch('postal_code_short', nil)
26
- @postal_code_extra = obj.fetch('postal_code_extra', nil)
27
- @premise = obj.fetch('premise', nil)
28
- @premise_extra = obj.fetch('premise_extra', nil)
29
- @premise_number = obj.fetch('premise_number', nil)
30
- @premise_prefix_number = obj.fetch('premise_prefix_number', nil)
31
- @premise_type = obj.fetch('premise_type', nil)
32
- @thoroughfare = obj.fetch('thoroughfare', nil)
33
- @thoroughfare_predirection = obj.fetch('thoroughfare_predirection', nil)
34
- @thoroughfare_postdirection = obj.fetch('thoroughfare_postdirection', nil)
35
- @thoroughfare_name = obj.fetch('thoroughfare_name', nil)
36
- @thoroughfare_trailing_type = obj.fetch('thoroughfare_trailing_type', nil)
37
- @thoroughfare_type = obj.fetch('thoroughfare_type', nil)
38
- @dependent_thoroughfare = obj.fetch('dependent_thoroughfare', nil)
39
- @dependent_thoroughfare_predirection = obj.fetch('dependent_thoroughfare_predirection', nil)
40
- @dependent_thoroughfare_postdirection = obj.fetch('dependent_thoroughfare_postdirection', nil)
41
- @dependent_thoroughfare_name = obj.fetch('dependent_thoroughfare_name', nil)
42
- @dependent_thoroughfare_trailing_type = obj.fetch('dependent_thoroughfare_trailing_type', nil)
43
- @dependent_thoroughfare_type = obj.fetch('dependent_thoroughfare_type', nil)
44
- @building = obj.fetch('building', nil)
45
- @building_leading_type = obj.fetch('building_leading_type', nil)
46
- @building_name = obj.fetch('building_name', nil)
47
- @building_trailing_type = obj.fetch('building_trailing_type', nil)
48
- @sub_building_type = obj.fetch('sub_building_type', nil)
49
- @sub_building_number = obj.fetch('sub_building_number', nil)
50
- @sub_building_name = obj.fetch('sub_building_name', nil)
51
- @sub_building = obj.fetch('sub_building', nil)
52
- @post_box = obj.fetch('post_box', nil)
53
- @post_box_type = obj.fetch('post_box_type', nil)
54
- @post_box_number = obj.fetch('post_box_number', nil)
55
- end
56
- end
57
- end
58
- end
@@ -1,9 +0,0 @@
1
- module SmartyStreets
2
- module InternationalStreet
3
- module LanguageMode
4
- NATIVE = 'native'.freeze
5
-
6
- LATIN = 'latin'.freeze
7
- end
8
- end
9
- end
@@ -1,82 +0,0 @@
1
- module SmartyStreets
2
- module InternationalStreet
3
- # In addition to holding all of the input data for this lookup, this class also will contain the
4
- # result of the lookup after it comes back from the API.
5
- #
6
- # Note: Lookups must have certain required fields set with non-blank values.
7
- # These can be found at the URL below.
8
- #
9
- # See "https://smartystreets.com/docs/cloud/international-street-api#http-input-fields"
10
- #
11
- # @geocode:: Disabled by default. Set to true to enable.
12
- # @language:: When not set, the output language will match the language of the input values.
13
- # When set to language_mode.NATIVE, the results will always be in the language of the output country.
14
- # When set to language_mode.LATIN, the results will always be provided using a Latin character set.
15
- class Lookup
16
-
17
- attr_accessor :input_id, :freeform, :locality, :postal_code, :address3, :address2, :inputId, :address1,
18
- :geocode, :administrative_area, :country, :organization, :language, :address4, :result
19
-
20
- def initialize(freeform=nil, country=nil)
21
- @result = []
22
-
23
- @input_id = nil
24
- @country = country
25
- @geocode = nil
26
- @language = nil
27
- @freeform = freeform
28
- @address1 = nil
29
- @address2 = nil
30
- @address3 = nil
31
- @address4 = nil
32
- @organization = nil
33
- @locality = nil
34
- @administrative_area = nil
35
- @postal_code = nil
36
- end
37
-
38
- def missing_country
39
- field_is_missing(@country)
40
- end
41
-
42
- def has_freeform
43
- field_is_set(@freeform)
44
- end
45
-
46
- def missing_address1
47
- field_is_missing(@address1)
48
- end
49
-
50
- def has_postal_code
51
- field_is_set(@postal_code)
52
- end
53
-
54
- def missing_locality_or_administrative_area
55
- field_is_missing(@locality) or field_is_missing(@administrative_area)
56
- end
57
-
58
- def field_is_missing(field)
59
- field.nil? or field.empty?
60
- end
61
-
62
- def field_is_set(field)
63
- not field_is_missing(field)
64
- end
65
-
66
- def ensure_enough_info
67
- raise UnprocessableEntityError, 'Country field is required.' if missing_country
68
-
69
- return true if has_freeform
70
-
71
- raise UnprocessableEntityError, 'Either freeform or address1 is required.' if missing_address1
72
-
73
- return true if has_postal_code
74
-
75
- if missing_locality_or_administrative_area
76
- raise UnprocessableEntityError, 'Insufficient information:'\
77
- 'One or more required fields were not set on the lookup.'
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,17 +0,0 @@
1
- module SmartyStreets
2
- module InternationalStreet
3
- # See "https://smartystreets.com/docs/cloud/international-street-api#metadata"
4
- class Metadata
5
-
6
- attr_reader :longitude, :geocode_precision, :max_geocode_precision, :latitude, :address_format
7
-
8
- def initialize(obj)
9
- @latitude = obj.fetch('latitude', nil)
10
- @longitude = obj.fetch('longitude', nil)
11
- @geocode_precision = obj.fetch('geocode_precision', nil)
12
- @max_geocode_precision = obj.fetch('max_geocode_precision', nil)
13
- @address_format = obj.fetch('address_format', nil)
14
- end
15
- end
16
- end
17
- end
@@ -1,25 +0,0 @@
1
- module SmartyStreets
2
- module InternationalStreet
3
- class RootLevel
4
- attr_reader :input_id, :organization, :address1, :address2, :address3, :address4, :address5, :address6, :address7,
5
- :address8, :address9, :address10, :address11, :address12
6
-
7
- def initialize(obj)
8
- @input_id = obj.fetch('input_id', nil)
9
- @organization = obj.fetch('organization', nil)
10
- @address1 = obj.fetch('address1', nil)
11
- @address2 = obj.fetch('address2', nil)
12
- @address3 = obj.fetch('address3', nil)
13
- @address4 = obj.fetch('address4', nil)
14
- @address5 = obj.fetch('address5', nil)
15
- @address6 = obj.fetch('address6', nil)
16
- @address7 = obj.fetch('address7', nil)
17
- @address8 = obj.fetch('address8', nil)
18
- @address9 = obj.fetch('address9', nil)
19
- @address10 = obj.fetch('address10', nil)
20
- @address11 = obj.fetch('address11', nil)
21
- @address12 = obj.fetch('address12', nil)
22
- end
23
- end
24
- end
25
- end
@@ -1,12 +0,0 @@
1
- require_relative './international_street/lookup'
2
- require_relative './international_street/metadata'
3
- require_relative './international_street/analysis'
4
- require_relative './international_street/components'
5
- require_relative './international_street/candidate'
6
- require_relative './international_street/client'
7
- require_relative './international_street/language_mode'
8
-
9
- module SmartyStreets
10
- module InternationalStreet
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- module SmartyStreets
2
- class LicenseSender
3
- def initialize(inner, licenses)
4
- @inner = inner
5
- @licenses = licenses
6
- end
7
-
8
- def send(request)
9
- if @licenses.length > 0
10
- request.parameters['license'] = @licenses.join(',')
11
- end
12
- @inner.send(request)
13
- end
14
- end
15
- end
@@ -1,7 +0,0 @@
1
- module SmartyStreets
2
- class Logger
3
- def log(message)
4
- puts message
5
- end
6
- end
7
- end
@@ -1,16 +0,0 @@
1
- module SmartyStreets
2
- # Contains information about the proxy through which all requests will be sent.
3
- #
4
- # host should not include a scheme
5
- class Proxy
6
-
7
- attr_accessor :port, :host, :username, :password
8
-
9
- def initialize(host, port, username = nil, password = nil)
10
- @host = host
11
- @port = port
12
- @username = username
13
- @password = password
14
- end
15
- end
16
- end