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,262 @@
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 'date'
14
+ require 'time'
15
+
16
+ module SnapBusinessSDK
17
+ class ValidatedFieldsValidatedFields
18
+ attr_accessor :pixel_id
19
+
20
+ attr_accessor :snap_app_id
21
+
22
+ attr_accessor :currency
23
+
24
+ attr_accessor :price
25
+
26
+ attr_accessor :event_conversion_type
27
+
28
+ attr_accessor :event_type
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'pixel_id' => :'pixel_id',
34
+ :'snap_app_id' => :'snap_app_id',
35
+ :'currency' => :'currency',
36
+ :'price' => :'price',
37
+ :'event_conversion_type' => :'event_conversion_type',
38
+ :'event_type' => :'event_type'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'pixel_id' => :'String',
51
+ :'snap_app_id' => :'String',
52
+ :'currency' => :'String',
53
+ :'price' => :'String',
54
+ :'event_conversion_type' => :'String',
55
+ :'event_type' => :'String'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ ])
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapBusinessSDK::ValidatedFieldsValidatedFields` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapBusinessSDK::ValidatedFieldsValidatedFields`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'pixel_id')
81
+ self.pixel_id = attributes[:'pixel_id']
82
+ end
83
+
84
+ if attributes.key?(:'snap_app_id')
85
+ self.snap_app_id = attributes[:'snap_app_id']
86
+ end
87
+
88
+ if attributes.key?(:'currency')
89
+ self.currency = attributes[:'currency']
90
+ end
91
+
92
+ if attributes.key?(:'price')
93
+ self.price = attributes[:'price']
94
+ end
95
+
96
+ if attributes.key?(:'event_conversion_type')
97
+ self.event_conversion_type = attributes[:'event_conversion_type']
98
+ end
99
+
100
+ if attributes.key?(:'event_type')
101
+ self.event_type = attributes[:'event_type']
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ invalid_properties = Array.new
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ true
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ pixel_id == o.pixel_id &&
124
+ snap_app_id == o.snap_app_id &&
125
+ currency == o.currency &&
126
+ price == o.price &&
127
+ event_conversion_type == o.event_conversion_type &&
128
+ event_type == o.event_type
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [pixel_id, snap_app_id, currency, price, event_conversion_type, event_type].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ new.build_from_hash(attributes)
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def build_from_hash(attributes)
154
+ return nil unless attributes.is_a?(Hash)
155
+ attributes = attributes.transform_keys(&:to_sym)
156
+ self.class.openapi_types.each_pair do |key, type|
157
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
158
+ self.send("#{key}=", nil)
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
163
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
164
+ end
165
+ elsif !attributes[self.class.attribute_map[key]].nil?
166
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
+ end
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :Time
180
+ Time.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :Boolean
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ # models (e.g. Pet) or oneOf
211
+ klass = SnapBusinessSDK.const_get(type)
212
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
213
+ end
214
+ end
215
+
216
+ # Returns the string representation of the object
217
+ # @return [String] String presentation of the object
218
+ def to_s
219
+ to_hash.to_s
220
+ end
221
+
222
+ # to_body is an alias to to_hash (backward compatibility)
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_body
225
+ to_hash
226
+ end
227
+
228
+ # Returns the object in the form of hash
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_hash
231
+ hash = {}
232
+ self.class.attribute_map.each_pair do |attr, param|
233
+ value = self.send(attr)
234
+ if value.nil?
235
+ is_nullable = self.class.openapi_nullable.include?(attr)
236
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
237
+ end
238
+
239
+ hash[param] = _to_hash(value)
240
+ end
241
+ hash
242
+ end
243
+
244
+ # Outputs non-array value in the form of hash
245
+ # For object, use to_hash. Otherwise, just return the value
246
+ # @param [Object] value Any valid value
247
+ # @return [Hash] Returns the value in the form of hash
248
+ def _to_hash(value)
249
+ if value.is_a?(Array)
250
+ value.compact.map { |v| _to_hash(v) }
251
+ elsif value.is_a?(Hash)
252
+ {}.tap do |hash|
253
+ value.each { |k, v| hash[k] = _to_hash(v) }
254
+ end
255
+ elsif value.respond_to? :to_hash
256
+ value.to_hash
257
+ else
258
+ value
259
+ end
260
+ end
261
+ end
262
+ end
@@ -0,0 +1,61 @@
1
+ require 'digest'
2
+ require 'soundex'
3
+
4
+ module SnapBusinessSDK
5
+ class CapiHash
6
+ class << self
7
+ PHONE_NUM_PATTERN = /^((\+|00)(\d+)[\-\s])?0?(.+)/
8
+ PHONE_NUM_REPLACE_PATTERN = /[^\d.]/
9
+
10
+ def norm_and_hash_str(str)
11
+ if blank? str
12
+ nil
13
+ else
14
+ Digest::SHA256.hexdigest str.strip.downcase
15
+ end
16
+ end
17
+
18
+ def norm_and_soundex_str(str)
19
+ if blank? str
20
+ nil
21
+ else
22
+ Soundex.new(str.strip.downcase).soundex.upcase
23
+ end
24
+ end
25
+
26
+ def norm_and_hash_phone_num(phone_num)
27
+ normalized_phone_num = normalize_phone_num phone_num
28
+ if normalized_phone_num.nil?
29
+ nil
30
+ else
31
+ Digest::SHA256.hexdigest normalized_phone_num
32
+ end
33
+ end
34
+
35
+ def normalize_phone_num(phone_num)
36
+ if blank? phone_num
37
+ return nil
38
+ end
39
+
40
+ phone_num.match(PHONE_NUM_PATTERN) do |m|
41
+ country_code = (m[3] || "").gsub PHONE_NUM_REPLACE_PATTERN, ""
42
+ num = (m[4] || "").gsub PHONE_NUM_REPLACE_PATTERN, ""
43
+
44
+ if blank? country_code
45
+ country_code = "1"
46
+ end
47
+
48
+ if blank? num
49
+ nil
50
+ else
51
+ country_code + num
52
+ end
53
+ end
54
+ end
55
+
56
+ def blank?(str)
57
+ str.respond_to?(:empty?) ? str.empty? : str.nil?
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,16 @@
1
+ module SnapBusinessSDK
2
+ module Constants
3
+ API_VERSION = 'v2'
4
+ PROD_DOMAIN = 'tr.snapchat.com'
5
+ STAGING_DOMAIN = 'tr-shadow.snapchat.com'
6
+ USER_AGENT = 'BusinessSDK/' + VERSION.to_s + '/Ruby'
7
+ USER_AGENT_WITH_PAD = USER_AGENT + ' (LaunchPAD)'
8
+ INTEGRATION_SDK = 'business-sdk'
9
+ TEST_MODE_HEADER = 'X-CAPI-Test-Mode'
10
+ CAPI_PATH_HEADER = 'X-CAPI-Path'
11
+ METRICS_HEADER = 'X-CAPI-BusinessSDK'
12
+ METRICS_HEADER_VALUE = 'Ruby/' + VERSION.to_s
13
+ CAPI_PATH = '/' + API_VERSION + '/conversion'
14
+ CAPI_PATH_TEST = CAPI_PATH + '/validate'
15
+ end
16
+ end
@@ -0,0 +1,15 @@
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
+ module SnapBusinessSDK
14
+ VERSION = '1.0.1'
15
+ end
@@ -0,0 +1,52 @@
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
+ # Common files
14
+ require 'snap_business/api_client'
15
+ require 'snap_business/api_error'
16
+ require 'snap_business/version'
17
+ require 'snap_business/configuration'
18
+
19
+ # Models
20
+ require 'snap_business/models/capi_event'
21
+ require 'snap_business/models/response'
22
+ require 'snap_business/models/response_error_records'
23
+ require 'snap_business/models/response_logs'
24
+ require 'snap_business/models/response_logs_log'
25
+ require 'snap_business/models/response_stats'
26
+ require 'snap_business/models/response_stats_data'
27
+ require 'snap_business/models/response_stats_test'
28
+ require 'snap_business/models/test_response'
29
+ require 'snap_business/models/validated_fields'
30
+ require 'snap_business/models/validated_fields_items'
31
+
32
+ # APIs
33
+ require 'snap_business/api/default_api'
34
+ require 'snap_business/api/conversion_api'
35
+
36
+ module SnapBusinessSDK
37
+ class << self
38
+ # Customize default settings for the SDK using block.
39
+ # SnapBusinessSDK.configure do |config|
40
+ # config.username = "xxx"
41
+ # config.password = "xxx"
42
+ # end
43
+ # If no block given, return the default Configuration object.
44
+ def configure
45
+ if block_given?
46
+ yield(Configuration.default)
47
+ else
48
+ Configuration.default
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,203 @@
1
+ require_relative '../../lib/snap_business/api/conversion_api'
2
+ require_relative '../../lib/snap_business/util/constants'
3
+
4
+ describe 'conversion_api' do
5
+ describe 'initialize' do
6
+ it 'initializes with all optional fields provided' do
7
+ is_debugging = false
8
+ launchpad_url = 'some.domain.com'
9
+ logger = Logger.new(STDOUT)
10
+ capi = SnapBusinessSDK::ConversionApi.new 'token',
11
+ launchpad_url: launchpad_url,
12
+ logger: logger,
13
+ is_debugging: is_debugging
14
+
15
+ expect(capi.use_launchpad).to be true
16
+ expect(capi.config.host).to eq launchpad_url
17
+ expect(capi.client.default_headers['User-Agent']).to eq SnapBusinessSDK::Constants::USER_AGENT_WITH_PAD
18
+ expect(capi.logger).to eq logger
19
+ expect(capi.is_debugging).to eq is_debugging
20
+ end
21
+ end
22
+
23
+ describe 'launchpad_url' do
24
+ it 'sets the provided launchpad url' do
25
+ launchpad_url = 'some.domain.com'
26
+ capi = SnapBusinessSDK::ConversionApi.new 'token', launchpad_url: launchpad_url
27
+
28
+ expect(capi.use_launchpad).to be true
29
+ expect(capi.config.host).to eq launchpad_url
30
+ expect(capi.client.default_headers['User-Agent']).to eq SnapBusinessSDK::Constants::USER_AGENT_WITH_PAD
31
+ end
32
+
33
+ it 'uses the default endpoint when not set' do
34
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
35
+
36
+ expect(capi.use_launchpad).to be false
37
+ expect(capi.config.host).to eq SnapBusinessSDK::Constants::PROD_DOMAIN
38
+ expect(capi.client.default_headers['User-Agent']).to eq SnapBusinessSDK::Constants::USER_AGENT
39
+ end
40
+ end
41
+
42
+ describe 'is_debugging' do
43
+ it 'sets debugging to false by default' do
44
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
45
+
46
+ expect(capi.is_debugging).to be false
47
+ end
48
+
49
+ it 'sets debugging to true' do
50
+ debugging = true
51
+ capi = SnapBusinessSDK::ConversionApi.new 'token', is_debugging: debugging
52
+
53
+ expect(capi.is_debugging).to be true
54
+ end
55
+ end
56
+
57
+ describe 'send_events' do
58
+ it 'sends events asynchronously' do
59
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
60
+ capi_event = SnapBusinessSDK::CapiEvent.new(
61
+ pixel_id: 'pixel-id',
62
+ event_conversion_type: 'WEB',
63
+ event_type: 'PURCHASE',
64
+ timestamp: 1656022510346,
65
+ )
66
+ capi_event.email = 'usr1@gmail.com'
67
+ capi_event.ip_address = '202.117.0.20'
68
+ capi_event.phone_number = '123-456-7890'
69
+ capi_events = [capi_event]
70
+
71
+ header = {}
72
+ request = { body: capi_events, header_params: header }
73
+ response = SnapBusinessSDK::Response.new status: '200'
74
+ expect(capi.default_api).to receive(:send_data).with(request).and_return(response)
75
+
76
+ promise = capi.send_events capi_events
77
+ promise.execute.wait
78
+ expect(promise.value).to eq response
79
+ end
80
+ end
81
+
82
+ describe 'send_events_sync' do
83
+ it 'sends events synchronously' do
84
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
85
+ capi_event = SnapBusinessSDK::CapiEvent.new(
86
+ pixel_id: 'pixel-id',
87
+ event_conversion_type: 'WEB',
88
+ event_type: 'PURCHASE',
89
+ timestamp: 1656022510346,
90
+ )
91
+ capi_event.email = 'usr1@gmail.com'
92
+ capi_event.ip_address = '202.117.0.20'
93
+ capi_event.phone_number = '123-456-7890'
94
+ capi_events = [capi_event]
95
+
96
+ header = {}
97
+ request = { body: capi_events, header_params: header }
98
+ response = SnapBusinessSDK::Response.new status: '200'
99
+ expect(capi.default_api).to receive(:send_data).with(request).and_return(response)
100
+
101
+ actual_response = capi.send_events_sync capi_events
102
+ expect(actual_response).to eq response
103
+ end
104
+
105
+ it 'sends events synchronously to launchpad' do
106
+ launchpad_url = 'some.domain.com'
107
+ capi = SnapBusinessSDK::ConversionApi.new 'token', launchpad_url: launchpad_url
108
+ capi_event = SnapBusinessSDK::CapiEvent.new(
109
+ pixel_id: 'pixel-id',
110
+ event_conversion_type: 'WEB',
111
+ event_type: 'PURCHASE',
112
+ timestamp: 1656022510346,
113
+ )
114
+ capi_event.email = 'usr1@gmail.com'
115
+ capi_event.ip_address = '202.117.0.20'
116
+ capi_event.phone_number = '123-456-7890'
117
+ capi_events = [capi_event]
118
+
119
+ header = { SnapBusinessSDK::Constants::CAPI_PATH_HEADER => SnapBusinessSDK::Constants::CAPI_PATH }
120
+ request = { body: capi_events, header_params: header }
121
+ response = SnapBusinessSDK::Response.new status: '200'
122
+ expect(capi.default_api).to receive(:send_data).with(request).and_return(response)
123
+
124
+ actual_response = capi.send_events_sync capi_events
125
+ expect(actual_response).to eq response
126
+ end
127
+ end
128
+
129
+ describe 'send_test_events' do
130
+ it 'sends test events synchronously' do
131
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
132
+ capi_event = SnapBusinessSDK::CapiEvent.new(
133
+ pixel_id: 'pixel-id',
134
+ event_conversion_type: 'WEB',
135
+ event_type: 'PURCHASE',
136
+ timestamp: 1656022510346,
137
+ )
138
+ capi_event.email = 'usr1@gmail.com'
139
+ capi_event.ip_address = '202.117.0.20'
140
+ capi_event.phone_number = '123-456-7890'
141
+ capi_events = [capi_event]
142
+
143
+ header = {}
144
+ request = { body: capi_events, header_params: header }
145
+ response = SnapBusinessSDK::TestResponse.new status: '200'
146
+ expect(capi.default_api).to receive(:send_test_data).with(request).and_return(response)
147
+
148
+ actual_response = capi.send_test_events capi_events
149
+ expect(actual_response).to eq response
150
+ end
151
+
152
+ it 'sends test events synchronously to launchpad' do
153
+ launchpad_url = 'some.domain.com'
154
+ capi = SnapBusinessSDK::ConversionApi.new 'token', launchpad_url: launchpad_url
155
+ capi_event = SnapBusinessSDK::CapiEvent.new(
156
+ pixel_id: 'pixel-id',
157
+ event_conversion_type: 'WEB',
158
+ event_type: 'PURCHASE',
159
+ timestamp: 1656022510346,
160
+ )
161
+ capi_event.email = 'usr1@gmail.com'
162
+ capi_event.ip_address = '202.117.0.20'
163
+ capi_event.phone_number = '123-456-7890'
164
+ capi_events = [capi_event]
165
+
166
+ header = { SnapBusinessSDK::Constants::CAPI_PATH_HEADER => SnapBusinessSDK::Constants::CAPI_PATH_TEST }
167
+ request = { body: capi_events, header_params: header }
168
+ response = SnapBusinessSDK::TestResponse.new status: '200'
169
+ expect(capi.default_api).to receive(:send_test_data).with(request).and_return(response)
170
+
171
+ actual_response = capi.send_test_events capi_events
172
+ expect(actual_response).to eq response
173
+ end
174
+ end
175
+
176
+ describe 'get_test_event_logs' do
177
+ it 'gets test event logs' do
178
+ asset_id = 'test-asset-id'
179
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
180
+ header = {}
181
+ request = { header_params: header }
182
+ response = SnapBusinessSDK::ResponseLogs.new status: '200'
183
+ expect(capi.default_api).to receive(:conversion_validate_logs).with(asset_id, request).and_return(response)
184
+
185
+ actual_response = capi.get_test_event_logs asset_id
186
+ expect(actual_response).to eq response
187
+ end
188
+ end
189
+
190
+ describe 'get_test_event_stats' do
191
+ it 'gets test event stats' do
192
+ asset_id = 'test-asset-id'
193
+ capi = SnapBusinessSDK::ConversionApi.new 'token'
194
+ header = {}
195
+ request = { header_params: header }
196
+ response = SnapBusinessSDK::ResponseStats.new status: '200'
197
+ expect(capi.default_api).to receive(:conversion_validate_stats).with(asset_id, request).and_return(response)
198
+
199
+ actual_response = capi.get_test_event_stats asset_id
200
+ expect(actual_response).to eq response
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,45 @@
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
+ require 'json'
15
+
16
+ # Unit tests for SnapBusinessSDK::DefaultApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'DefaultApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = SnapBusinessSDK::DefaultApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of DefaultApi' do
30
+ it 'should create an instance of DefaultApi' do
31
+ expect(@api_instance).to be_instance_of(SnapBusinessSDK::DefaultApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for send_data
36
+ # @param [Hash] opts the optional parameters
37
+ # @option opts [Array<CapiEvent>] :body Snap Conversions API
38
+ # @return [Response]
39
+ describe 'send_data test' do
40
+ it 'should work' do
41
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
42
+ end
43
+ end
44
+
45
+ end