trophonius 1.2.6.3 → 1.2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trophonius_connection.rb +13 -8
- data/lib/trophonius_model.rb +40 -24
- data/lib/trophonius_query.rb +5 -3
- data/lib/trophonius_record.rb +30 -18
- data/lib/trophonius_request.rb +50 -21
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f64c4285e902e34390d654a1766180aebae9a4c3bb483286d442b02284813390
|
4
|
+
data.tar.gz: c85fc16b8bd2179865d3d75709be1b44a15d17aded4ae5ee6a2820bbf16e0488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ba939131882022370de145757b09fc5c3b03775314ee08e298d383d0cf6a2d7796ae98706cf98b806dcd58ed7df5d6fd07656ec811df3b0d136775f5abf926
|
7
|
+
data.tar.gz: 2df0e98f4da6fc84658faf26632b65e52574efea36dea08b11131dfd5234b43f3612693efbf5d741e11c7c2fe0f924989ea7496db57e39c01a89c8d57756292a
|
@@ -38,7 +38,9 @@ module Trophonius
|
|
38
38
|
ssl_verifypeer = !Trophonius.config.local_network
|
39
39
|
url =
|
40
40
|
URI(
|
41
|
-
|
41
|
+
URI.escape(
|
42
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/sessions"
|
43
|
+
)
|
42
44
|
)
|
43
45
|
request =
|
44
46
|
Typhoeus::Request.new(
|
@@ -83,11 +85,12 @@ module Trophonius
|
|
83
85
|
def self.disconnect
|
84
86
|
url =
|
85
87
|
URI(
|
86
|
-
|
87
|
-
Trophonius.config.
|
88
|
-
|
88
|
+
URI.escape(
|
89
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
90
|
+
Trophonius.config.database
|
91
|
+
}/sessions/#{Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'token') : @token}"
|
92
|
+
)
|
89
93
|
)
|
90
|
-
puts url
|
91
94
|
ssl_verifyhost = Trophonius.config.local_network ? 0 : 2
|
92
95
|
ssl_verifypeer = !Trophonius.config.local_network
|
93
96
|
|
@@ -136,9 +139,11 @@ module Trophonius
|
|
136
139
|
def self.test_connection
|
137
140
|
url =
|
138
141
|
URI(
|
139
|
-
|
140
|
-
Trophonius.config.
|
141
|
-
|
142
|
+
URI.escape(
|
143
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
144
|
+
Trophonius.config.database
|
145
|
+
}/layouts/#{Trophonius.config.layout_name}/records?_limit=1"
|
146
|
+
)
|
142
147
|
)
|
143
148
|
begin
|
144
149
|
request =
|
data/lib/trophonius_model.rb
CHANGED
@@ -169,9 +169,11 @@ module Trophonius
|
|
169
169
|
def self.create(fieldData)
|
170
170
|
url =
|
171
171
|
URI(
|
172
|
-
|
173
|
-
|
174
|
-
|
172
|
+
URI.escape(
|
173
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
174
|
+
Trophonius.config.database
|
175
|
+
}/layouts/#{layout_name}/records"
|
176
|
+
)
|
175
177
|
)
|
176
178
|
new_field_data = {}
|
177
179
|
create_translations if @configuration.translations.keys.empty?
|
@@ -199,9 +201,11 @@ module Trophonius
|
|
199
201
|
else
|
200
202
|
url =
|
201
203
|
URI(
|
202
|
-
|
203
|
-
Trophonius.config.
|
204
|
-
|
204
|
+
URI.escape(
|
205
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
206
|
+
Trophonius.config.database
|
207
|
+
}/layouts/#{layout_name}/records/#{response['response']['recordId']}"
|
208
|
+
)
|
205
209
|
)
|
206
210
|
ret_val = build_result(Request.make_request(url, "Bearer #{Request.get_token}", 'get', '{}')['response']['data'][0])
|
207
211
|
ret_val.send(:define_singleton_method, 'result_count') { 1 }
|
@@ -219,9 +223,11 @@ module Trophonius
|
|
219
223
|
def self.find_by(fieldData)
|
220
224
|
url =
|
221
225
|
URI(
|
222
|
-
|
223
|
-
|
224
|
-
|
226
|
+
URI.escape(
|
227
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
228
|
+
Trophonius.config.database
|
229
|
+
}/layouts/#{self.layout_name}/_find?_limit=1"
|
230
|
+
)
|
225
231
|
)
|
226
232
|
new_field_data = {}
|
227
233
|
create_translations if @configuration.translations.keys.empty?
|
@@ -260,9 +266,11 @@ module Trophonius
|
|
260
266
|
def self.find(record_id)
|
261
267
|
url =
|
262
268
|
URI(
|
263
|
-
|
264
|
-
|
265
|
-
|
269
|
+
URI.escape(
|
270
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
271
|
+
Trophonius.config.database
|
272
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
273
|
+
)
|
266
274
|
)
|
267
275
|
response = Request.make_request(url, "Bearer #{Request.get_token}", 'get', '{}')
|
268
276
|
if response['messages'][0]['code'] != '0'
|
@@ -283,9 +291,11 @@ module Trophonius
|
|
283
291
|
def self.delete(record_id)
|
284
292
|
url =
|
285
293
|
URI(
|
286
|
-
|
287
|
-
|
288
|
-
|
294
|
+
URI.escape(
|
295
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
296
|
+
Trophonius.config.database
|
297
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
298
|
+
)
|
289
299
|
)
|
290
300
|
response = Request.make_request(url, "Bearer #{Request.get_token}", 'delete', '{}')
|
291
301
|
if response['messages'][0]['code'] != '0'
|
@@ -306,9 +316,11 @@ module Trophonius
|
|
306
316
|
def self.edit(record_id, fieldData)
|
307
317
|
url =
|
308
318
|
URI(
|
309
|
-
|
310
|
-
|
311
|
-
|
319
|
+
URI.escape(
|
320
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
321
|
+
Trophonius.config.database
|
322
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
323
|
+
)
|
312
324
|
)
|
313
325
|
new_field_data = {}
|
314
326
|
create_translations if @configuration.translations.keys.empty?
|
@@ -431,16 +443,20 @@ module Trophonius
|
|
431
443
|
unless @limit.empty? || @offset.empty?
|
432
444
|
url =
|
433
445
|
URI(
|
434
|
-
|
435
|
-
Trophonius.config.
|
436
|
-
|
446
|
+
URI.escape(
|
447
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
448
|
+
Trophonius.config.database
|
449
|
+
}/layouts/#{layout_name}/records?_offset=#{@offset}&_limit=#{@limit}"
|
450
|
+
)
|
437
451
|
)
|
438
452
|
else
|
439
453
|
url =
|
440
454
|
URI(
|
441
|
-
|
442
|
-
Trophonius.config.
|
443
|
-
|
455
|
+
URI.escape(
|
456
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
457
|
+
Trophonius.config.database
|
458
|
+
}/layouts/#{layout_name}/records?_limit=#{count == 0 ? 1_000_000 : count}"
|
459
|
+
)
|
444
460
|
)
|
445
461
|
end
|
446
462
|
@limit = ''
|
data/lib/trophonius_query.rb
CHANGED
@@ -101,9 +101,11 @@ module Trophonius
|
|
101
101
|
def run_query(method, *args, &block)
|
102
102
|
url =
|
103
103
|
URI(
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
URI.escape(
|
105
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
106
|
+
Trophonius.config.database
|
107
|
+
}/layouts/#{@trophonius_model.layout_name}/_find"
|
108
|
+
)
|
107
109
|
)
|
108
110
|
new_field_data = @current_query.map { |_q| {} }
|
109
111
|
|
data/lib/trophonius_record.rb
CHANGED
@@ -34,9 +34,11 @@ module Trophonius
|
|
34
34
|
|
35
35
|
url =
|
36
36
|
URI(
|
37
|
-
|
38
|
-
Trophonius.config.
|
39
|
-
|
37
|
+
URI.escape(
|
38
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
39
|
+
Trophonius.config.database
|
40
|
+
}/layouts/#{layout}/_find"
|
41
|
+
)
|
40
42
|
)
|
41
43
|
|
42
44
|
if model.translations.key?(relation[:foreign_key])
|
@@ -94,9 +96,11 @@ module Trophonius
|
|
94
96
|
|
95
97
|
url =
|
96
98
|
URI(
|
97
|
-
|
98
|
-
Trophonius.config.
|
99
|
-
|
99
|
+
URI.escape(
|
100
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
101
|
+
Trophonius.config.database
|
102
|
+
}/layouts/#{layout}/_find"
|
103
|
+
)
|
100
104
|
)
|
101
105
|
|
102
106
|
if fk_model.translations.key?(relation[:foreign_key])
|
@@ -156,9 +160,11 @@ module Trophonius
|
|
156
160
|
def save
|
157
161
|
url =
|
158
162
|
URI(
|
159
|
-
|
160
|
-
|
161
|
-
|
163
|
+
URI.escape(
|
164
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
165
|
+
Trophonius.config.database
|
166
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
167
|
+
)
|
162
168
|
)
|
163
169
|
body = "{\"fieldData\": #{modified_fields.to_json}}"
|
164
170
|
response = Request.make_request(url, "Bearer #{Request.get_token}", 'patch', body)
|
@@ -173,9 +179,11 @@ module Trophonius
|
|
173
179
|
def delete
|
174
180
|
url =
|
175
181
|
URI(
|
176
|
-
|
177
|
-
|
178
|
-
|
182
|
+
URI.escape(
|
183
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
184
|
+
Trophonius.config.database
|
185
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
186
|
+
)
|
179
187
|
)
|
180
188
|
response = Request.make_request(url, "Bearer #{Request.get_token}", 'delete', '{}')
|
181
189
|
response['messages'][0]['code'] != '0' ? Error.throw_error(response['messages'][0]['code']) : true
|
@@ -191,9 +199,11 @@ module Trophonius
|
|
191
199
|
def update(fieldData)
|
192
200
|
url =
|
193
201
|
URI(
|
194
|
-
|
195
|
-
|
196
|
-
|
202
|
+
URI.escape(
|
203
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
204
|
+
Trophonius.config.database
|
205
|
+
}/layouts/#{layout_name}/records/#{record_id}"
|
206
|
+
)
|
197
207
|
)
|
198
208
|
fieldData.keys.each { |field| modifiable_fields[field] = fieldData[field] }
|
199
209
|
body = "{\"fieldData\": #{fieldData.to_json}}"
|
@@ -227,9 +237,11 @@ module Trophonius
|
|
227
237
|
def upload(container_name:, container_repetition: 1, file:)
|
228
238
|
url =
|
229
239
|
URI(
|
230
|
-
|
231
|
-
|
232
|
-
|
240
|
+
URI.escape(
|
241
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
242
|
+
Trophonius.config.database
|
243
|
+
}/layouts/#{layout_name}/records/#{record_id}/containers/#{container_name}/#{container_repetition}"
|
244
|
+
)
|
233
245
|
)
|
234
246
|
|
235
247
|
response = Request.upload_file_request(url, "Bearer #{Request.get_token}", file)
|
data/lib/trophonius_request.rb
CHANGED
@@ -4,7 +4,6 @@ require 'base64'
|
|
4
4
|
require 'trophonius_connection'
|
5
5
|
require 'uri'
|
6
6
|
require 'net/http'
|
7
|
-
|
8
7
|
module Trophonius
|
9
8
|
module Trophonius::Request
|
10
9
|
##
|
@@ -24,19 +23,21 @@ module Trophonius
|
|
24
23
|
def self.make_request(url_param, auth, method, body, params = '')
|
25
24
|
ssl_verifyhost = Trophonius.config.local_network ? 0 : 2
|
26
25
|
ssl_verifypeer = !Trophonius.config.local_network
|
27
|
-
request =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
request =
|
27
|
+
Typhoeus::Request.new(
|
28
|
+
url_param,
|
29
|
+
method: method.to_sym,
|
30
|
+
body: body,
|
31
|
+
params: params,
|
32
|
+
ssl_verifyhost: ssl_verifyhost,
|
33
|
+
ssl_verifypeer: ssl_verifypeer,
|
34
|
+
headers: { 'Content-Type' => 'application/json', Authorization: auth.to_s }
|
35
|
+
)
|
36
36
|
temp = request.run
|
37
37
|
begin
|
38
38
|
JSON.parse(temp.response_body)
|
39
|
-
rescue Exception
|
39
|
+
rescue Exception => e
|
40
|
+
puts "Error was #{e}"
|
40
41
|
Error.throw_error('1631')
|
41
42
|
end
|
42
43
|
end
|
@@ -52,7 +53,7 @@ module Trophonius
|
|
52
53
|
#
|
53
54
|
# @return [JSON] parsed json of the response
|
54
55
|
def self.upload_file_request(url_param, auth, file)
|
55
|
-
url = URI(url_param)
|
56
|
+
url = URI(url_param.to_s)
|
56
57
|
|
57
58
|
https = Net::HTTP.new(url.host, url.port)
|
58
59
|
https.use_ssl = true
|
@@ -75,11 +76,7 @@ module Trophonius
|
|
75
76
|
#
|
76
77
|
# @return [String] a valid FileMaker token
|
77
78
|
def self.get_token
|
78
|
-
|
79
|
-
Connection.token
|
80
|
-
else
|
81
|
-
Connection.connect
|
82
|
-
end
|
79
|
+
Connection.valid_connection? ? Connection.token : Connection.connect
|
83
80
|
end
|
84
81
|
|
85
82
|
##
|
@@ -87,7 +84,14 @@ module Trophonius
|
|
87
84
|
#
|
88
85
|
# @return [JSON] The first record from FileMaker
|
89
86
|
def self.retrieve_first(layout_name)
|
90
|
-
url =
|
87
|
+
url =
|
88
|
+
URI(
|
89
|
+
URI.escape(
|
90
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
91
|
+
Trophonius.config.database
|
92
|
+
}/layouts/#{layout_name}/records?_limit=1"
|
93
|
+
)
|
94
|
+
)
|
91
95
|
make_request(url, "Bearer #{get_token}", 'get', '{}')
|
92
96
|
end
|
93
97
|
|
@@ -96,7 +100,14 @@ module Trophonius
|
|
96
100
|
#
|
97
101
|
# @return [JSON] The script result from FileMaker
|
98
102
|
def self.run_script(script, scriptparameter, layout_name)
|
99
|
-
url =
|
103
|
+
url =
|
104
|
+
URI(
|
105
|
+
URI.escape(
|
106
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
107
|
+
Trophonius.config.database
|
108
|
+
}/layouts/#{layout_name}/records?_limit=1&script=#{script}&script.param=#{scriptparameter}"
|
109
|
+
)
|
110
|
+
)
|
100
111
|
make_request(url, "Bearer #{get_token}", 'get', '{}')
|
101
112
|
end
|
102
113
|
|
@@ -107,9 +118,27 @@ module Trophonius
|
|
107
118
|
def self.retrieve_all(layout_name, sort)
|
108
119
|
if !sort.empty?
|
109
120
|
sort_order = sort.to_json.to_s
|
110
|
-
url =
|
121
|
+
url =
|
122
|
+
URI(
|
123
|
+
URI.escape(
|
124
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
125
|
+
Trophonius.config.database
|
126
|
+
}/layouts/#{layout_name}/records?_limit=10000000_sort=#{sort_order}#{
|
127
|
+
Trophonius.config.count_result_script == '' ? '' : "&script=#{Trophonius.config.count_result_script}"
|
128
|
+
}"
|
129
|
+
)
|
130
|
+
)
|
111
131
|
else
|
112
|
-
url =
|
132
|
+
url =
|
133
|
+
URI(
|
134
|
+
URI.escape(
|
135
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
136
|
+
Trophonius.config.database
|
137
|
+
}/layouts/#{layout_name}/records?_limit=10000000#{
|
138
|
+
Trophonius.config.count_result_script == '' ? '' : "&script=#{Trophonius.config.count_result_script}"
|
139
|
+
}"
|
140
|
+
)
|
141
|
+
)
|
113
142
|
end
|
114
143
|
make_request(url, "Bearer #{get_token}", 'get', '{}')
|
115
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trophonius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.6.
|
4
|
+
version: 1.2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kempen Automatisering
|
@@ -42,24 +42,18 @@ dependencies:
|
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '6.0'
|
48
45
|
- - ">="
|
49
46
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
47
|
+
version: '5.0'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '6.0'
|
58
52
|
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
description:
|
62
|
-
Data-API.
|
54
|
+
version: '5.0'
|
55
|
+
description: A lightweight, easy to use link between Ruby (on Rails) and FileMaker
|
56
|
+
using the FileMaker Data-API.
|
63
57
|
email:
|
64
58
|
executables: []
|
65
59
|
extensions: []
|
@@ -97,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
91
|
- !ruby/object:Gem::Version
|
98
92
|
version: '0'
|
99
93
|
requirements: []
|
100
|
-
rubygems_version: 3.0.
|
94
|
+
rubygems_version: 3.0.3
|
101
95
|
signing_key:
|
102
96
|
specification_version: 4
|
103
97
|
summary: Link between Ruby (on Rails) and FileMaker.
|