snap_business 1.0.1

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 (31) hide show
  1. checksums.yaml +7 -0
  2. data/lib/snap_business/api/conversion_api.rb +244 -0
  3. data/lib/snap_business/api/default_api.rb +266 -0
  4. data/lib/snap_business/api_client.rb +428 -0
  5. data/lib/snap_business/api_error.rb +57 -0
  6. data/lib/snap_business/configuration.rb +318 -0
  7. data/lib/snap_business/models/capi_event.rb +590 -0
  8. data/lib/snap_business/models/capi_event_ext.rb +58 -0
  9. data/lib/snap_business/models/response.rb +237 -0
  10. data/lib/snap_business/models/response_error_records.rb +228 -0
  11. data/lib/snap_business/models/response_logs.rb +237 -0
  12. data/lib/snap_business/models/response_logs_log.rb +284 -0
  13. data/lib/snap_business/models/response_stats.rb +235 -0
  14. data/lib/snap_business/models/response_stats_data.rb +226 -0
  15. data/lib/snap_business/models/response_stats_test.rb +226 -0
  16. data/lib/snap_business/models/test_response.rb +259 -0
  17. data/lib/snap_business/models/validated_fields.rb +226 -0
  18. data/lib/snap_business/models/validated_fields_items.rb +262 -0
  19. data/lib/snap_business/models/validated_fields_validated_fields.rb +262 -0
  20. data/lib/snap_business/util/capi_hash.rb +61 -0
  21. data/lib/snap_business/util/constants.rb +16 -0
  22. data/lib/snap_business/version.rb +15 -0
  23. data/lib/snap_business.rb +52 -0
  24. data/spec/api/conversion_api_spec.rb +203 -0
  25. data/spec/api/default_api_spec.rb +45 -0
  26. data/spec/api_client_spec.rb +188 -0
  27. data/spec/configuration_spec.rb +42 -0
  28. data/spec/models/capi_event_spec.rb +127 -0
  29. data/spec/spec_helper.rb +111 -0
  30. data/spec/util/capi_hash_spec.rb +62 -0
  31. metadata +178 -0
@@ -0,0 +1,188 @@
1
+ =begin
2
+ #Snap Conversions API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe SnapBusinessSDK::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ SnapBusinessSDK.configure { |c| c.host = 'http://example.com' }
21
+ expect(SnapBusinessSDK::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ SnapBusinessSDK.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(SnapBusinessSDK::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ SnapBusinessSDK.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(SnapBusinessSDK::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ SnapBusinessSDK.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(SnapBusinessSDK::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ SnapBusinessSDK.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(SnapBusinessSDK::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ SnapBusinessSDK.configure { |c| c.base_path = nil }
48
+ expect(SnapBusinessSDK::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#deserialize' do
55
+ it "handles Array<Integer>" do
56
+ api_client = SnapBusinessSDK::ApiClient.new
57
+ headers = { 'Content-Type' => 'application/json' }
58
+ response = double('response', headers: headers, body: '[12, 34]')
59
+ data = api_client.deserialize(response, 'Array<Integer>')
60
+ expect(data).to be_instance_of(Array)
61
+ expect(data).to eq([12, 34])
62
+ end
63
+
64
+ it 'handles Array<Array<Integer>>' do
65
+ api_client = SnapBusinessSDK::ApiClient.new
66
+ headers = { 'Content-Type' => 'application/json' }
67
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
68
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
69
+ expect(data).to be_instance_of(Array)
70
+ expect(data).to eq([[12, 34], [56]])
71
+ end
72
+
73
+ it 'handles Hash<String, String>' do
74
+ api_client = SnapBusinessSDK::ApiClient.new
75
+ headers = { 'Content-Type' => 'application/json' }
76
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
77
+ data = api_client.deserialize(response, 'Hash<String, String>')
78
+ expect(data).to be_instance_of(Hash)
79
+ expect(data).to eq(:message => 'Hello')
80
+ end
81
+ end
82
+
83
+ describe "#object_to_hash" do
84
+ it 'ignores nils and includes empty arrays' do
85
+ # uncomment below to test object_to_hash for model
86
+ # api_client = SnapBusinessSDK::ApiClient.new
87
+ # _model = SnapBusinessSDK::ModelName.new
88
+ # update the model attribute below
89
+ # _model.id = 1
90
+ # update the expected value (hash) below
91
+ # expected = {id: 1, name: '', tags: []}
92
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
93
+ end
94
+ end
95
+
96
+ describe '#build_collection_param' do
97
+ let(:param) { ['aa', 'bb', 'cc'] }
98
+ let(:api_client) { SnapBusinessSDK::ApiClient.new }
99
+
100
+ it 'works for csv' do
101
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
102
+ end
103
+
104
+ it 'works for ssv' do
105
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
106
+ end
107
+
108
+ it 'works for tsv' do
109
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
110
+ end
111
+
112
+ it 'works for pipes' do
113
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
114
+ end
115
+
116
+ it 'works for multi' do
117
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
118
+ end
119
+
120
+ it 'fails for invalid collection format' do
121
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
122
+ end
123
+ end
124
+
125
+ describe '#json_mime?' do
126
+ let(:api_client) { SnapBusinessSDK::ApiClient.new }
127
+
128
+ it 'works' do
129
+ expect(api_client.json_mime?(nil)).to eq false
130
+ expect(api_client.json_mime?('')).to eq false
131
+
132
+ expect(api_client.json_mime?('application/json')).to eq true
133
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
134
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
135
+
136
+ expect(api_client.json_mime?('application/xml')).to eq false
137
+ expect(api_client.json_mime?('text/plain')).to eq false
138
+ expect(api_client.json_mime?('application/jsonp')).to eq false
139
+ end
140
+ end
141
+
142
+ describe '#select_header_accept' do
143
+ let(:api_client) { SnapBusinessSDK::ApiClient.new }
144
+
145
+ it 'works' do
146
+ expect(api_client.select_header_accept(nil)).to be_nil
147
+ expect(api_client.select_header_accept([])).to be_nil
148
+
149
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
150
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
151
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
152
+
153
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
154
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
155
+ end
156
+ end
157
+
158
+ describe '#select_header_content_type' do
159
+ let(:api_client) { SnapBusinessSDK::ApiClient.new }
160
+
161
+ it 'works' do
162
+ expect(api_client.select_header_content_type(nil)).to be_nil
163
+ expect(api_client.select_header_content_type([])).to be_nil
164
+
165
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
166
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
167
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
168
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
169
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
170
+ end
171
+ end
172
+
173
+ describe '#sanitize_filename' do
174
+ let(:api_client) { SnapBusinessSDK::ApiClient.new }
175
+
176
+ it 'works' do
177
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
178
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
179
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
180
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
181
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
182
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
183
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
184
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
185
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+ #Snap Conversions API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe SnapBusinessSDK::Configuration do
16
+ let(:config) { SnapBusinessSDK::Configuration.default }
17
+
18
+ before(:each) do
19
+ # uncomment below to setup host and base_path
20
+ # require 'URI'
21
+ # uri = URI.parse("https://tr.snapchat.com")
22
+ # SnapBusinessSDK.configure do |c|
23
+ # c.host = uri.host
24
+ # c.base_path = uri.path
25
+ # end
26
+ end
27
+
28
+ describe '#base_url' do
29
+ it 'should have the default value' do
30
+ # uncomment below to test default value of the base path
31
+ # expect(config.base_url).to eq("https://tr.snapchat.com")
32
+ end
33
+
34
+ it 'should remove trailing slashes' do
35
+ [nil, '', '/', '//'].each do |base_path|
36
+ config.base_path = base_path
37
+ # uncomment below to test trailing slashes
38
+ # expect(config.base_url).to eq("https://tr.snapchat.com")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,127 @@
1
+ require 'digest'
2
+
3
+ describe 'capi_event' do
4
+ describe 'email' do
5
+ it 'hashes plaintext arguments' do
6
+ val = 'test@test.com'
7
+ capi_event = SnapBusinessSDK::CapiEvent.new
8
+ capi_event.email = val
9
+ expect(capi_event.hashed_email).not_to be_empty
10
+ expect(capi_event.hashed_email).not_to eq val
11
+ end
12
+ end
13
+
14
+ describe 'mobile_ad_id' do
15
+ it 'hashes plaintext arguments' do
16
+ val = 'test-ad-id'
17
+ capi_event = SnapBusinessSDK::CapiEvent.new
18
+ capi_event.mobile_ad_id = val
19
+ expect(capi_event.hashed_mobile_ad_id).not_to be_empty
20
+ expect(capi_event.hashed_mobile_ad_id).not_to eq val
21
+ end
22
+ end
23
+
24
+ describe 'idfv' do
25
+ it 'hashes plaintext arguments' do
26
+ val = 'test-idfv'
27
+ capi_event = SnapBusinessSDK::CapiEvent.new
28
+ capi_event.idfv = val
29
+ expect(capi_event.hashed_idfv).not_to be_empty
30
+ expect(capi_event.hashed_idfv).not_to eq val
31
+ end
32
+ end
33
+
34
+ describe 'phone_number' do
35
+ it 'hashes plaintext arguments' do
36
+ val = '0044-447-234-2344'
37
+ capi_event = SnapBusinessSDK::CapiEvent.new
38
+ capi_event.phone_number = val
39
+ expect(capi_event.hashed_phone_number).not_to be_empty
40
+ expect(capi_event.hashed_phone_number).not_to eq val
41
+ end
42
+ end
43
+
44
+ describe 'ip_address' do
45
+ it 'hashes plaintext arguments' do
46
+ val = 'test-ip_address'
47
+ capi_event = SnapBusinessSDK::CapiEvent.new
48
+ capi_event.ip_address = val
49
+ expect(capi_event.hashed_ip_address).not_to be_empty
50
+ expect(capi_event.hashed_ip_address).not_to eq val
51
+ end
52
+ end
53
+
54
+ describe 'first_name' do
55
+ it 'hashes plaintext arguments' do
56
+ val = 'test-first_name'
57
+ capi_event = SnapBusinessSDK::CapiEvent.new
58
+ capi_event.first_name = val
59
+ expect(capi_event.hashed_first_name_sha).not_to be_empty
60
+ expect(capi_event.hashed_first_name_sha).not_to eq val
61
+ expect(capi_event.hashed_first_name_sdx).not_to be_empty
62
+ expect(capi_event.hashed_first_name_sdx).not_to eq val
63
+ end
64
+ end
65
+
66
+ describe 'middle_name' do
67
+ it 'hashes plaintext arguments' do
68
+ val = 'test-middle_name'
69
+ capi_event = SnapBusinessSDK::CapiEvent.new
70
+ capi_event.middle_name = val
71
+ expect(capi_event.hashed_middle_name_sha).not_to be_empty
72
+ expect(capi_event.hashed_middle_name_sha).not_to eq val
73
+ expect(capi_event.hashed_middle_name_sdx).not_to be_empty
74
+ expect(capi_event.hashed_middle_name_sdx).not_to eq val
75
+ end
76
+ end
77
+
78
+ describe 'last_name' do
79
+ it 'hashes plaintext arguments' do
80
+ val = 'test-last_name'
81
+ capi_event = SnapBusinessSDK::CapiEvent.new
82
+ capi_event.last_name = val
83
+ expect(capi_event.hashed_last_name_sha).not_to be_empty
84
+ expect(capi_event.hashed_last_name_sha).not_to eq val
85
+ expect(capi_event.hashed_last_name_sdx).not_to be_empty
86
+ expect(capi_event.hashed_last_name_sdx).not_to eq val
87
+ end
88
+ end
89
+
90
+ describe 'city' do
91
+ it 'hashes plaintext arguments' do
92
+ val = 'test-city'
93
+ capi_event = SnapBusinessSDK::CapiEvent.new
94
+ capi_event.city = val
95
+ expect(capi_event.hashed_city_sha).not_to be_empty
96
+ expect(capi_event.hashed_city_sha).not_to eq val
97
+ expect(capi_event.hashed_city_sdx).not_to be_empty
98
+ expect(capi_event.hashed_city_sdx).not_to eq val
99
+ end
100
+ end
101
+
102
+ describe 'state' do
103
+ it 'hashes plaintext arguments' do
104
+ val = 'test-state'
105
+ capi_event = SnapBusinessSDK::CapiEvent.new
106
+ capi_event.state = val
107
+ expect(capi_event.hashed_state_sha).not_to be_empty
108
+ expect(capi_event.hashed_state_sha).not_to eq val
109
+ expect(capi_event.hashed_state_sdx).not_to be_empty
110
+ expect(capi_event.hashed_state_sdx).not_to eq val
111
+ end
112
+ end
113
+
114
+ describe 'zip' do
115
+ it 'hashes plaintext arguments' do
116
+ val = 'test-zip'
117
+ capi_event = SnapBusinessSDK::CapiEvent.new
118
+ capi_event.zip = val
119
+ expect(capi_event.hashed_zip).not_to be_empty
120
+ expect(capi_event.hashed_zip).not_to eq val
121
+ end
122
+ end
123
+
124
+ def hash(str)
125
+ Digest::SHA256.hexdigest str.downcase
126
+ end
127
+ end
@@ -0,0 +1,111 @@
1
+ =begin
2
+ #Snap Conversions API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1
10
+
11
+ =end
12
+
13
+ # load the gem
14
+ require 'snap_business'
15
+
16
+ # The following was generated by the `rspec --init` command. Conventionally, all
17
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
18
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
19
+ # this file to always be loaded, without a need to explicitly require it in any
20
+ # files.
21
+ #
22
+ # Given that it is always loaded, you are encouraged to keep this file as
23
+ # light-weight as possible. Requiring heavyweight dependencies from this file
24
+ # will add to the boot time of your test suite on EVERY test run, even for an
25
+ # individual file that may not need all of that loaded. Instead, consider making
26
+ # a separate helper file that requires the additional dependencies and performs
27
+ # the additional setup, and require it from the spec files that actually need
28
+ # it.
29
+ #
30
+ # The `.rspec` file also contains a few flags that are not defaults but that
31
+ # users commonly want.
32
+ #
33
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
34
+ RSpec.configure do |config|
35
+ # rspec-expectations config goes here. You can use an alternate
36
+ # assertion/expectation library such as wrong or the stdlib/minitest
37
+ # assertions if you prefer.
38
+ config.expect_with :rspec do |expectations|
39
+ # This option will default to `true` in RSpec 4. It makes the `description`
40
+ # and `failure_message` of custom matchers include text for helper methods
41
+ # defined using `chain`, e.g.:
42
+ # be_bigger_than(2).and_smaller_than(4).description
43
+ # # => "be bigger than 2 and smaller than 4"
44
+ # ...rather than:
45
+ # # => "be bigger than 2"
46
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
47
+ end
48
+
49
+ # rspec-mocks config goes here. You can use an alternate test double
50
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
51
+ config.mock_with :rspec do |mocks|
52
+ # Prevents you from mocking or stubbing a method that does not exist on
53
+ # a real object. This is generally recommended, and will default to
54
+ # `true` in RSpec 4.
55
+ mocks.verify_partial_doubles = true
56
+ end
57
+
58
+ # The settings below are suggested to provide a good initial experience
59
+ # with RSpec, but feel free to customize to your heart's content.
60
+ =begin
61
+ # These two settings work together to allow you to limit a spec run
62
+ # to individual examples or groups you care about by tagging them with
63
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
64
+ # get run.
65
+ config.filter_run :focus
66
+ config.run_all_when_everything_filtered = true
67
+
68
+ # Allows RSpec to persist some state between runs in order to support
69
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
70
+ # you configure your source control system to ignore this file.
71
+ config.example_status_persistence_file_path = "spec/examples.txt"
72
+
73
+ # Limits the available syntax to the non-monkey patched syntax that is
74
+ # recommended. For more details, see:
75
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
76
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
77
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
78
+ config.disable_monkey_patching!
79
+
80
+ # This setting enables warnings. It's recommended, but in some cases may
81
+ # be too noisy due to issues in dependencies.
82
+ config.warnings = true
83
+
84
+ # Many RSpec users commonly either run the entire suite or an individual
85
+ # file, and it's useful to allow more verbose output when running an
86
+ # individual spec file.
87
+ if config.files_to_run.one?
88
+ # Use the documentation formatter for detailed output,
89
+ # unless a formatter has already been configured
90
+ # (e.g. via a command-line flag).
91
+ config.default_formatter = 'doc'
92
+ end
93
+
94
+ # Print the 10 slowest examples and example groups at the
95
+ # end of the spec run, to help surface which specs are running
96
+ # particularly slow.
97
+ config.profile_examples = 10
98
+
99
+ # Run specs in random order to surface order dependencies. If you find an
100
+ # order dependency and want to debug it, you can fix the order by providing
101
+ # the seed, which is printed after each run.
102
+ # --seed 1234
103
+ config.order = :random
104
+
105
+ # Seed global randomization in this process using the `--seed` CLI option.
106
+ # Setting this allows you to use `--seed` to deterministically reproduce
107
+ # test failures related to randomization by passing the same `--seed` value
108
+ # as the one that triggered the failure.
109
+ Kernel.srand config.seed
110
+ =end
111
+ end
@@ -0,0 +1,62 @@
1
+ require 'digest'
2
+ require_relative '../../lib/snap_business/util/capi_hash'
3
+
4
+ describe 'capi_hash' do
5
+ describe 'norm_and_hash_str' do
6
+ [
7
+ "abc123",
8
+ "ABC123",
9
+ "aBc123",
10
+ ].each do |str|
11
+ it "hashes the non-empty string #{str}" do
12
+ expect(SnapBusinessSDK::CapiHash.norm_and_hash_str str).to eq(Digest::SHA256.hexdigest str.downcase)
13
+ end
14
+ end
15
+ end
16
+
17
+ describe 'norm_and_soundex_str' do
18
+ {
19
+ 'Robert' => 'R163',
20
+ 'Rupert' => 'R163',
21
+ 'Rubin' => 'R150',
22
+ 'Ashcraft' => 'A261',
23
+ 'Ashcroft' => 'A261',
24
+ 'Tymczak' => 'T522',
25
+ 'Pfister' => 'P236',
26
+ 'Bob' => 'B100'
27
+ }.each do |str, expected|
28
+ it "it soundex hashes #{str} to #{expected}" do
29
+ expect(SnapBusinessSDK::CapiHash.norm_and_soundex_str str).to eq expected
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'normalize_phone_num' do
35
+ {
36
+ "+44-447-234-2344" => "444472342344",
37
+ "0044-447-234-2344" => "444472342344",
38
+ "+44-0447-234-2344" => "444472342344",
39
+ "+44 0447 234 2344" => "444472342344",
40
+ "447-234-2344" => "14472342344",
41
+ "4472342344" => "14472342344",
42
+ "+1-447-234-2344" => "14472342344",
43
+ "(447)-234-2344" => "14472342344",
44
+ "447 234-2344" => "14472342344",
45
+ "+1-(447) 234 2344" => "14472342344",
46
+ }.each do |phone_num, expected|
47
+ it "validates and removes extra characters for #{phone_num}" do
48
+ expect(SnapBusinessSDK::CapiHash.normalize_phone_num phone_num).to eq expected
49
+ end
50
+ end
51
+
52
+ {
53
+ "" => nil,
54
+ nil => nil,
55
+ " " => nil,
56
+ }.each do |phone_num, expected|
57
+ it "rejects invalid phone number #{phone_num}" do
58
+ expect(SnapBusinessSDK::CapiHash.normalize_phone_num phone_num).to eq expected
59
+ end
60
+ end
61
+ end
62
+ end