trophonius 1.2.6.3 → 1.2.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ae60ee7f5268ca52e52b3debe45b23fb345a1e6fb82e98753225cf05d2bfdab
4
- data.tar.gz: 5851e544d81d093338fec8b5ae2cd5f54888e9e52c291d0a3a2566e89af29726
3
+ metadata.gz: f64c4285e902e34390d654a1766180aebae9a4c3bb483286d442b02284813390
4
+ data.tar.gz: c85fc16b8bd2179865d3d75709be1b44a15d17aded4ae5ee6a2820bbf16e0488
5
5
  SHA512:
6
- metadata.gz: 564cf24b8f721c61e1522973d863bf5aa0c78c80745d31571183475b01cac5aa2b7f05aaa373ad1d375801223b75e18dfb2d631b6ed44064cedf2e8cb61eaef3
7
- data.tar.gz: c3351a53038cb94963b37dd0b1e1b943ccc8a5991b26fcf31879d0e7de1980bb5b2e76d0ea029ff288b43dc455a9d7fb01c2ef8a808fd44f7dddd172f0c351e6
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/sessions"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/sessions/#{
87
- Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'token') : @token
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
140
- Trophonius.config.layout_name
141
- }/records?_limit=1"
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 =
@@ -169,9 +169,11 @@ module Trophonius
169
169
  def self.create(fieldData)
170
170
  url =
171
171
  URI(
172
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
173
- layout_name
174
- }/records"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
203
- Trophonius.config.database
204
- }/layouts/#{layout_name}/records/#{response['response']['recordId']}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
223
- self.layout_name
224
- }/_find?_limit=1"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
264
- layout_name
265
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
287
- layout_name
288
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
310
- layout_name
311
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
435
- Trophonius.config.database
436
- }/layouts/#{layout_name}/records?_offset=#{@offset}&_limit=#{@limit}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
442
- Trophonius.config.database
443
- }/layouts/#{layout_name}/records?_limit=#{count == 0 ? 1_000_000 : count}"
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 = ''
@@ -101,9 +101,11 @@ module Trophonius
101
101
  def run_query(method, *args, &block)
102
102
  url =
103
103
  URI(
104
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
105
- @trophonius_model.layout_name
106
- }/_find"
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
 
@@ -34,9 +34,11 @@ module Trophonius
34
34
 
35
35
  url =
36
36
  URI(
37
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
38
- Trophonius.config.database
39
- }/layouts/#{layout}/_find"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
98
- Trophonius.config.database
99
- }/layouts/#{layout}/_find"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
160
- layout_name
161
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
177
- layout_name
178
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
195
- layout_name
196
- }/records/#{record_id}"
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
- "http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{
231
- layout_name
232
- }/records/#{record_id}/containers/#{container_name}/#{container_repetition}"
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)
@@ -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 = 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
- )
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
- if Connection.valid_connection?
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 = URI("http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{layout_name}/records?_limit=1")
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 = URI("http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{layout_name}/records?_limit=1&script=#{script}&script.param=#{scriptparameter}")
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 = URI("http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{layout_name}/records?_limit=10000000_sort=#{sort_order}#{Trophonius.config.count_result_script == '' ? '' : "&script=#{Trophonius.config.count_result_script}"}")
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 = URI("http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{Trophonius.config.database}/layouts/#{layout_name}/records?_limit=10000000#{Trophonius.config.count_result_script == '' ? '' : "&script=#{Trophonius.config.count_result_script}"}")
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.3
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: 6.0.3.1
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: 6.0.3.1
61
- description: An easy to use link between Ruby (on Rails) and FileMaker using the FileMaker
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.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.