mints 0.0.21 → 0.0.22
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.
- checksums.yaml +4 -4
- data/lib/client.rb +394 -386
- metadata +19 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2092538b350860005ee4826457c90d29193a1e0433a66ec4a57e6871b89d2ec4
|
4
|
+
data.tar.gz: 1449b810544a74c41df442362c6f32ebb0f0093cdd347c0413a527bf11b29a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab861e9359093bda93256401ece08d7be1c34fe50d90dc83547c4703e931f842d6deb40d9035701a02e38ebac599e21dfc9e9d453db4f9920b0aadf0f0b747d
|
7
|
+
data.tar.gz: 1eccf6e965e9f5d2a48277efac3a05501ad399f387345eb0dbc58bb2678f4e126c91eca6413da61ca3fe2fad7b8be169ec34091cbccd8fbc4627cb9134493de9
|
data/lib/client.rb
CHANGED
@@ -1,386 +1,394 @@
|
|
1
|
-
require "httparty"
|
2
|
-
require "json"
|
3
|
-
require "addressable"
|
4
|
-
require "redis"
|
5
|
-
module Mints
|
6
|
-
class Client
|
7
|
-
attr_reader :host
|
8
|
-
attr_reader :api_key
|
9
|
-
attr_reader :scope
|
10
|
-
attr_reader :base_url
|
11
|
-
attr_accessor :session_token
|
12
|
-
attr_accessor :contact_token_id
|
13
|
-
|
14
|
-
def initialize(host, api_key, scope = nil, session_token = nil, contact_token_id = nil, visit_id = nil, debug = false)
|
15
|
-
@host = host
|
16
|
-
@api_key = api_key
|
17
|
-
@session_token = session_token
|
18
|
-
@contact_token_id = contact_token_id
|
19
|
-
@visit_id = visit_id
|
20
|
-
@debug = debug
|
21
|
-
self.set_scope(scope)
|
22
|
-
end
|
23
|
-
|
24
|
-
def raw(action, url, options = nil, data = nil, base_url = nil, compatibility_options = {}, only_tracking = false)
|
25
|
-
if compatibility_options === nil
|
26
|
-
compatibility_options = {}
|
27
|
-
end
|
28
|
-
base_url = @base_url if !base_url
|
29
|
-
uri = ""
|
30
|
-
if (options && options.class == Hash)
|
31
|
-
if (options[:jfilters] && options[:jfilters].class == Hash)
|
32
|
-
options[:jfilters] = Base64.encode64(JSON.generate(options[:jfilters]))
|
33
|
-
end
|
34
|
-
uri = Addressable::URI.new
|
35
|
-
uri.query_values = options
|
36
|
-
end
|
37
|
-
|
38
|
-
full_url = "#{@host}#{base_url}#{url}#{uri}"
|
39
|
-
response = nil
|
40
|
-
if action === 'get'
|
41
|
-
|
42
|
-
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
43
|
-
config = YAML.load template.result(binding)
|
44
|
-
url_need_cache = false
|
45
|
-
result_from_cache = false
|
46
|
-
time = 0
|
47
|
-
|
48
|
-
if config['redis_cache']['use_cache']
|
49
|
-
config['redis_cache']['groups'].each do |group|
|
50
|
-
group['urls'].each do |url|
|
51
|
-
if full_url.match url
|
52
|
-
time = group['time']
|
53
|
-
url_need_cache = true
|
54
|
-
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
response = self.send("#{@scope}_#{action}", url,
|
149
|
-
elsif action == "
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
def
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
def
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
puts "
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
puts "
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
puts "
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
"
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
h
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
h
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
1
|
+
require "httparty"
|
2
|
+
require "json"
|
3
|
+
require "addressable"
|
4
|
+
require "redis"
|
5
|
+
module Mints
|
6
|
+
class Client
|
7
|
+
attr_reader :host
|
8
|
+
attr_reader :api_key
|
9
|
+
attr_reader :scope
|
10
|
+
attr_reader :base_url
|
11
|
+
attr_accessor :session_token
|
12
|
+
attr_accessor :contact_token_id
|
13
|
+
|
14
|
+
def initialize(host, api_key, scope = nil, session_token = nil, contact_token_id = nil, visit_id = nil, debug = false)
|
15
|
+
@host = host
|
16
|
+
@api_key = api_key
|
17
|
+
@session_token = session_token
|
18
|
+
@contact_token_id = contact_token_id
|
19
|
+
@visit_id = visit_id
|
20
|
+
@debug = debug
|
21
|
+
self.set_scope(scope)
|
22
|
+
end
|
23
|
+
|
24
|
+
def raw(action, url, options = nil, data = nil, base_url = nil, compatibility_options = {}, only_tracking = false)
|
25
|
+
if compatibility_options === nil
|
26
|
+
compatibility_options = {}
|
27
|
+
end
|
28
|
+
base_url = @base_url if !base_url
|
29
|
+
uri = ""
|
30
|
+
if (options && options.class == Hash)
|
31
|
+
if (options[:jfilters] && options[:jfilters].class == Hash)
|
32
|
+
options[:jfilters] = Base64.encode64(JSON.generate(options[:jfilters]))
|
33
|
+
end
|
34
|
+
uri = Addressable::URI.new
|
35
|
+
uri.query_values = options
|
36
|
+
end
|
37
|
+
|
38
|
+
full_url = "#{@host}#{base_url}#{url}#{uri}"
|
39
|
+
response = nil
|
40
|
+
if action === 'get'
|
41
|
+
|
42
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
43
|
+
config = YAML.load template.result(binding)
|
44
|
+
url_need_cache = false
|
45
|
+
result_from_cache = false
|
46
|
+
time = 0
|
47
|
+
|
48
|
+
if config['redis_cache']['use_cache']
|
49
|
+
config['redis_cache']['groups'].each do |group|
|
50
|
+
group['urls'].each do |url|
|
51
|
+
if full_url.match url
|
52
|
+
time = group['time']
|
53
|
+
url_need_cache = true
|
54
|
+
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1)
|
55
|
+
redis_response = @redis_server.get(full_url)
|
56
|
+
if redis_response
|
57
|
+
response = redis_response
|
58
|
+
result_from_cache = true
|
59
|
+
|
60
|
+
headers = nil
|
61
|
+
if only_tracking
|
62
|
+
headers = {"Only-Tracking" => "true"}
|
63
|
+
#when is already in redis notify to California to register the object usage
|
64
|
+
cali_response = self.send("#{@scope}_#{action}", "#{full_url}", headers, compatibility_options)
|
65
|
+
if @debug
|
66
|
+
puts "CALI TRACKING RESPONSE: #{cali_response}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if @debug
|
71
|
+
puts "REDIS RESPONSE: #{redis_response}"
|
72
|
+
end
|
73
|
+
else
|
74
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}", nil, compatibility_options)
|
75
|
+
@redis_server.setex(full_url,time,response)
|
76
|
+
end
|
77
|
+
break
|
78
|
+
end
|
79
|
+
end
|
80
|
+
break if url_need_cache
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if !url_need_cache
|
85
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}", nil, compatibility_options)
|
86
|
+
end
|
87
|
+
|
88
|
+
elsif action === 'create' or action === 'post'
|
89
|
+
action = 'post'
|
90
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}", data, compatibility_options)
|
91
|
+
elsif action === 'put' or action === 'patch' or action ==='update'
|
92
|
+
action = 'put'
|
93
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}", data, compatibility_options)
|
94
|
+
elsif action === 'delete' or action === 'destroy'
|
95
|
+
action = 'delete'
|
96
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}", data, compatibility_options)
|
97
|
+
end
|
98
|
+
begin
|
99
|
+
if result_from_cache
|
100
|
+
return JSON.parse(response)
|
101
|
+
else
|
102
|
+
if (response.response.code == "404")
|
103
|
+
raise 'NotFoundError'
|
104
|
+
end
|
105
|
+
return JSON.parse(response.body)
|
106
|
+
end
|
107
|
+
rescue
|
108
|
+
return response
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def method_missing(name, *args, &block)
|
113
|
+
name.to_s.include?("__") ? separator = "__" : separator = "_"
|
114
|
+
# split the name to identify their elements
|
115
|
+
name_spplited = name.to_s.split(separator)
|
116
|
+
# count the elments
|
117
|
+
name_len = name_spplited.size
|
118
|
+
# the action always be the first element
|
119
|
+
action = name_spplited.first
|
120
|
+
raise 'NoActionError' unless ['get', 'create', 'post', 'update', 'put', 'delete', 'destroy'].include?(action)
|
121
|
+
# the object always be the last element
|
122
|
+
object = separator == "__" ? name_spplited.last.gsub("_","-") : name_spplited.last
|
123
|
+
# get intermediate url elements
|
124
|
+
route_array = []
|
125
|
+
(name_len-1).times do |n|
|
126
|
+
if n == 0 or n == name_len-1
|
127
|
+
next
|
128
|
+
end
|
129
|
+
n = name_spplited[n]
|
130
|
+
self.replacements().each do |object|
|
131
|
+
n = n.gsub(object[:old_value], object[:new_value])
|
132
|
+
end
|
133
|
+
route_array.push n
|
134
|
+
end
|
135
|
+
route = route_array.join("/")
|
136
|
+
|
137
|
+
|
138
|
+
slug = nil
|
139
|
+
uri = Addressable::URI.new
|
140
|
+
if action == "get"
|
141
|
+
if args.first.class == Hash
|
142
|
+
uri.query_values = args.first
|
143
|
+
elsif args.first.class == String or Integer
|
144
|
+
slug = args.first
|
145
|
+
uri.query_values = args[1]
|
146
|
+
end
|
147
|
+
url = self.get_url(route, object, uri, slug)
|
148
|
+
response = self.send("#{@scope}_#{action}", url, nil, compatibility_options)
|
149
|
+
elsif action == "post" or action == "create"
|
150
|
+
if args[1].class == Hash
|
151
|
+
uri.query_values = args[1]
|
152
|
+
end
|
153
|
+
url = self.get_url(route, object, uri, slug)
|
154
|
+
action = 'post'
|
155
|
+
data = args[0]
|
156
|
+
response = self.send("#{@scope}_#{action}", url, {data: data}, compatibility_options)
|
157
|
+
elsif action == "put" or action == "update"
|
158
|
+
if args.first.class == String or Integer
|
159
|
+
slug = args.first
|
160
|
+
uri.query_values = args[2]
|
161
|
+
end
|
162
|
+
url = self.get_url(route, object, uri, slug)
|
163
|
+
action = 'put'
|
164
|
+
id = args[0]
|
165
|
+
data = args[1]
|
166
|
+
response = self.send("#{@scope}_#{action}", "#{url}", {data: data}, compatibility_options)
|
167
|
+
end
|
168
|
+
|
169
|
+
if response.response.code == "404"
|
170
|
+
raise 'NotFoundError'
|
171
|
+
elsif response.response.code == "500"
|
172
|
+
raise 'InternalServerError'
|
173
|
+
end
|
174
|
+
return JSON.parse(response.body)
|
175
|
+
end
|
176
|
+
|
177
|
+
def get_url(route, object, uri, slug = nil)
|
178
|
+
if (slug)
|
179
|
+
return "#{@host}#{@base_url}/#{route}/#{object}/#{slug}#{uri}"
|
180
|
+
else
|
181
|
+
return "#{@host}#{@base_url}/#{route}/#{object}#{uri}"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def replacements
|
186
|
+
return [
|
187
|
+
{old_value: '_', new_value: '-'},
|
188
|
+
{old_value: 'people', new_value: 'crm'},
|
189
|
+
{old_value: 'store', new_value: 'ecommerce'}
|
190
|
+
]
|
191
|
+
end
|
192
|
+
|
193
|
+
def set_scope(scope)
|
194
|
+
@scope = scope
|
195
|
+
if scope == "public"
|
196
|
+
@base_url = "/api/v1"
|
197
|
+
elsif scope == "contact"
|
198
|
+
@base_url = "/api/v1"
|
199
|
+
elsif scope == "user"
|
200
|
+
@base_url = "/api/user/v1"
|
201
|
+
else
|
202
|
+
@scope = "public"
|
203
|
+
@base_url = "/api/v1"
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
##### HTTTP CLIENTS ######
|
208
|
+
# Simple HTTP GET
|
209
|
+
def http_get(url, headers = nil)
|
210
|
+
if @debug
|
211
|
+
puts "Url:"
|
212
|
+
puts url
|
213
|
+
puts "Headers:"
|
214
|
+
puts headers
|
215
|
+
puts "Method: get"
|
216
|
+
end
|
217
|
+
return headers ? HTTParty.get(url, :headers => headers) : HTTParty.get(url)
|
218
|
+
end
|
219
|
+
|
220
|
+
# Simple HTTP POST
|
221
|
+
def http_post(url, headers = nil, data = nil)
|
222
|
+
if @debug
|
223
|
+
puts "Url:"
|
224
|
+
puts url
|
225
|
+
puts "Headers:"
|
226
|
+
puts headers
|
227
|
+
puts "Data:"
|
228
|
+
puts data
|
229
|
+
puts "Method: post"
|
230
|
+
end
|
231
|
+
return headers ? HTTParty.post(url, :headers=> headers, :body => data) : HTTParty.post(url, :body => data)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Simple HTTP PUT
|
235
|
+
def http_put(url, headers = nil, data = nil)
|
236
|
+
if @debug
|
237
|
+
puts "Url:"
|
238
|
+
puts url
|
239
|
+
puts "Headers:"
|
240
|
+
puts headers
|
241
|
+
puts "Data:"
|
242
|
+
puts data
|
243
|
+
puts "Method: put"
|
244
|
+
end
|
245
|
+
return headers ? HTTParty.put(url, :headers=> headers, :body => data) : HTTParty.put(url, :body => data)
|
246
|
+
end
|
247
|
+
|
248
|
+
# Simple HTTP DELETE
|
249
|
+
def http_delete(url, headers = nil, data = nil)
|
250
|
+
if @debug
|
251
|
+
puts "Url:"
|
252
|
+
puts url
|
253
|
+
puts "Headers:"
|
254
|
+
puts headers
|
255
|
+
puts "Data:"
|
256
|
+
puts data
|
257
|
+
puts "Method: delete"
|
258
|
+
end
|
259
|
+
return headers ? HTTParty.delete(url, :headers=> headers, :body => data) : HTTParty.delete(url, :body => data)
|
260
|
+
end
|
261
|
+
|
262
|
+
# Start contact context
|
263
|
+
def contact_get(url, headers = nil, compatibility_options)
|
264
|
+
h = {
|
265
|
+
"ApiKey" => @api_key,
|
266
|
+
"Accept" => "application/json",
|
267
|
+
"ContactToken" => @contact_token_id
|
268
|
+
}
|
269
|
+
h["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
270
|
+
h["Authorization"] = "Bearer #{@session_token}" if @session_token
|
271
|
+
if headers
|
272
|
+
headers.each do |k,v|
|
273
|
+
h[k] = v
|
274
|
+
end
|
275
|
+
end
|
276
|
+
return self.http_get(url, h)
|
277
|
+
end
|
278
|
+
|
279
|
+
def contact_post(url, data, compatibility_options)
|
280
|
+
headers = {
|
281
|
+
"ApiKey" => @api_key,
|
282
|
+
"Accept" => "application/json",
|
283
|
+
"ContactToken" => @contact_token_id
|
284
|
+
}
|
285
|
+
headers["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
286
|
+
headers["Authorization"] = "Bearer #{@session_token}" if @session_token
|
287
|
+
return self.http_post(url, headers, data)
|
288
|
+
end
|
289
|
+
|
290
|
+
def contact_put(url, data, compatibility_options)
|
291
|
+
headers = {
|
292
|
+
"ApiKey" => @api_key,
|
293
|
+
"Accept" => "application/json",
|
294
|
+
"ContactToken" => @contact_token_id
|
295
|
+
}
|
296
|
+
headers["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
297
|
+
headers["Authorization"] = "Bearer #{@session_token}" if @session_token
|
298
|
+
return self.http_put(url, headers, data)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Start User context
|
302
|
+
def user_get(url, headers = nil, compatibility_options)
|
303
|
+
h = {
|
304
|
+
"Accept" => "application/json",
|
305
|
+
"ApiKey" => @api_key
|
306
|
+
}
|
307
|
+
h["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
308
|
+
h["Authorization"] = "Bearer #{@session_token}" if @session_token
|
309
|
+
if headers
|
310
|
+
headers.each do |k,v|
|
311
|
+
h[k] = v
|
312
|
+
end
|
313
|
+
end
|
314
|
+
return self.http_get(url, h)
|
315
|
+
end
|
316
|
+
|
317
|
+
def user_post(url, data, compatibility_options)
|
318
|
+
headers = {
|
319
|
+
"Accept" => "application/json",
|
320
|
+
"ApiKey" => @api_key
|
321
|
+
}
|
322
|
+
headers["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
323
|
+
headers["Authorization"] = "Bearer #{@session_token}" if @session_token
|
324
|
+
return self.http_post(url, headers, data)
|
325
|
+
end
|
326
|
+
|
327
|
+
def user_put(url, data, compatibility_options)
|
328
|
+
headers = {
|
329
|
+
"Accept" => "application/json",
|
330
|
+
"ApiKey" => @api_key
|
331
|
+
}
|
332
|
+
headers["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
333
|
+
headers["Authorization"] = "Bearer #{@session_token}" if @session_token
|
334
|
+
return self.http_put(url, headers, data)
|
335
|
+
end
|
336
|
+
|
337
|
+
def user_delete(url, data, compatibility_options)
|
338
|
+
headers = {
|
339
|
+
"Accept" => "application/json",
|
340
|
+
"ApiKey" => @api_key
|
341
|
+
}
|
342
|
+
headers["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
343
|
+
headers["Authorization"] = "Bearer #{@session_token}" if @session_token
|
344
|
+
return self.http_delete(url, headers, data)
|
345
|
+
end
|
346
|
+
# End User Context
|
347
|
+
|
348
|
+
def public_get(url, headers = nil, compatibility_options)
|
349
|
+
h = {
|
350
|
+
"Accept" => "application/json",
|
351
|
+
"ApiKey" => @api_key
|
352
|
+
}
|
353
|
+
h["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
354
|
+
h["ContactToken"] = @contact_token_id if @contact_token_id
|
355
|
+
h["Visit-Id"] = @visit_id if @visit_id
|
356
|
+
if headers
|
357
|
+
headers.each do |k,v|
|
358
|
+
h[k] = v
|
359
|
+
end
|
360
|
+
end
|
361
|
+
self.http_get(url, h)
|
362
|
+
end
|
363
|
+
|
364
|
+
def public_post(url, headers = nil, data, compatibility_options)
|
365
|
+
h = {
|
366
|
+
"Accept" => "application/json",
|
367
|
+
"ApiKey" => @api_key
|
368
|
+
}
|
369
|
+
h["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
370
|
+
h["ContactToken"] = @session_token if @session_token
|
371
|
+
if headers
|
372
|
+
headers.each do |k,v|
|
373
|
+
h[k] = v
|
374
|
+
end
|
375
|
+
end
|
376
|
+
self.http_post(url, h, data)
|
377
|
+
end
|
378
|
+
|
379
|
+
def public_put(url, headers = nil, data, compatibility_options)
|
380
|
+
h = {
|
381
|
+
"Accept" => "application/json",
|
382
|
+
"ApiKey" => @api_key
|
383
|
+
}
|
384
|
+
h["Content-Type"] = "application/json" unless compatibility_options['no_content_type']
|
385
|
+
h["ContactToken"] = @contact_token_id if @contact_token_id
|
386
|
+
if headers
|
387
|
+
headers.each do |k,v|
|
388
|
+
h[k] = v
|
389
|
+
end
|
390
|
+
end
|
391
|
+
self.http_put(url, h, data)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Gomez Garcia, Omar Mora, Luis Payan, Oscar Castillo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.8.3
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 1.8.3
|
@@ -24,9 +21,6 @@ dependencies:
|
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.8.3
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: 1.8.3
|
@@ -34,80 +28,80 @@ dependencies:
|
|
34
28
|
name: httparty
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: 0.18.0
|
40
|
-
- - "
|
34
|
+
- - "~>"
|
41
35
|
- !ruby/object:Gem::Version
|
42
36
|
version: 0.18.0
|
43
37
|
type: :runtime
|
44
38
|
prerelease: false
|
45
39
|
version_requirements: !ruby/object:Gem::Requirement
|
46
40
|
requirements:
|
47
|
-
- - "
|
41
|
+
- - ">="
|
48
42
|
- !ruby/object:Gem::Version
|
49
43
|
version: 0.18.0
|
50
|
-
- - "
|
44
|
+
- - "~>"
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: 0.18.0
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: redis
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
|
-
- - "
|
51
|
+
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
53
|
version: 4.2.2
|
60
|
-
- - "
|
54
|
+
- - "~>"
|
61
55
|
- !ruby/object:Gem::Version
|
62
56
|
version: 4.2.2
|
63
57
|
type: :runtime
|
64
58
|
prerelease: false
|
65
59
|
version_requirements: !ruby/object:Gem::Requirement
|
66
60
|
requirements:
|
67
|
-
- - "
|
61
|
+
- - ">="
|
68
62
|
- !ruby/object:Gem::Version
|
69
63
|
version: 4.2.2
|
70
|
-
- - "
|
64
|
+
- - "~>"
|
71
65
|
- !ruby/object:Gem::Version
|
72
66
|
version: 4.2.2
|
73
67
|
- !ruby/object:Gem::Dependency
|
74
68
|
name: addressable
|
75
69
|
requirement: !ruby/object:Gem::Requirement
|
76
70
|
requirements:
|
77
|
-
- - "
|
71
|
+
- - ">="
|
78
72
|
- !ruby/object:Gem::Version
|
79
73
|
version: 2.7.0
|
80
|
-
- - "
|
74
|
+
- - "~>"
|
81
75
|
- !ruby/object:Gem::Version
|
82
76
|
version: 2.7.0
|
83
77
|
type: :runtime
|
84
78
|
prerelease: false
|
85
79
|
version_requirements: !ruby/object:Gem::Requirement
|
86
80
|
requirements:
|
87
|
-
- - "
|
81
|
+
- - ">="
|
88
82
|
- !ruby/object:Gem::Version
|
89
83
|
version: 2.7.0
|
90
|
-
- - "
|
84
|
+
- - "~>"
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: 2.7.0
|
93
87
|
- !ruby/object:Gem::Dependency
|
94
88
|
name: rails-reverse-proxy
|
95
89
|
requirement: !ruby/object:Gem::Requirement
|
96
90
|
requirements:
|
97
|
-
- - "
|
91
|
+
- - ">="
|
98
92
|
- !ruby/object:Gem::Version
|
99
93
|
version: 0.9.1
|
100
|
-
- - "
|
94
|
+
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
96
|
version: 0.9.1
|
103
97
|
type: :runtime
|
104
98
|
prerelease: false
|
105
99
|
version_requirements: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
|
-
- - "
|
101
|
+
- - ">="
|
108
102
|
- !ruby/object:Gem::Version
|
109
103
|
version: 0.9.1
|
110
|
-
- - "
|
104
|
+
- - "~>"
|
111
105
|
- !ruby/object:Gem::Version
|
112
106
|
version: 0.9.1
|
113
107
|
description:
|
@@ -216,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
210
|
- !ruby/object:Gem::Version
|
217
211
|
version: '0'
|
218
212
|
requirements: []
|
219
|
-
|
220
|
-
rubygems_version: 2.7.6.2
|
213
|
+
rubygems_version: 3.0.3.1
|
221
214
|
signing_key:
|
222
215
|
specification_version: 4
|
223
216
|
summary: MINTS gem allows to connect your Rails App to MINTS.CLOUD
|