trophonius 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trophonius_date.rb +4 -0
- data/lib/trophonius_query.rb +102 -1
- data/lib/trophonius_record.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41021eda82dc3be50251329863f57e9bf5df2586abfe8069b40dbdae7e2a7aba
|
4
|
+
data.tar.gz: ec72927694b15fcb213caf261b92a12c8f08d5fbb7c111d3d0bcdae5947092b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e819bde6be251232e782d3c7b850f75cf718d04ae505f5bd30f457f28fb8b4b44973f5b9445137fa76c404a3e26d60a3d2a1adb8bccc6907392c19480910f9
|
7
|
+
data.tar.gz: 3dabf32b65b0611822c977afa256f5069a9a90c7f789969cb4ecde497462e67a357e20c30bd3b4ddf43fc1a4c6bd5bb71a5911e390c18447e04d31d9c0d3f65a
|
data/lib/trophonius_date.rb
CHANGED
data/lib/trophonius_query.rb
CHANGED
@@ -7,6 +7,7 @@ require 'trophonius_error'
|
|
7
7
|
module Trophonius
|
8
8
|
class Trophonius::Query
|
9
9
|
attr_reader :response
|
10
|
+
attr_accessor :presort_script, :presort_scriptparam, :prerequest_script, :prerequest_scriptparam, :post_request_script, :post_request_scriptparam
|
10
11
|
|
11
12
|
##
|
12
13
|
# Creates a new instance of the Trophonius::Query class
|
@@ -20,6 +21,12 @@ module Trophonius
|
|
20
21
|
@trophonius_model = trophonius_model
|
21
22
|
@limit = limit
|
22
23
|
@offset = offset
|
24
|
+
@presort_script = ''
|
25
|
+
@presort_scriptparam = ''
|
26
|
+
@prerequest_script = ''
|
27
|
+
@prerequest_scriptparam = ''
|
28
|
+
@post_request_script = ''
|
29
|
+
@post_request_scriptparam = ''
|
23
30
|
end
|
24
31
|
|
25
32
|
##
|
@@ -60,6 +67,66 @@ module Trophonius
|
|
60
67
|
args[1]
|
61
68
|
end
|
62
69
|
|
70
|
+
##
|
71
|
+
# Adds a post-request script to the request
|
72
|
+
#
|
73
|
+
# @param [args] arguments containing a String with the name of the script
|
74
|
+
# @return [Trophonius::Model] updated base model
|
75
|
+
def set_post_request_script(args)
|
76
|
+
args[1].current_query.post_request_script = args[0]
|
77
|
+
args[1]
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Adds a post-request scriptparameter to the request
|
82
|
+
#
|
83
|
+
# @param [args] arguments containing a String with the name of the scriptparameter
|
84
|
+
# @return [Trophonius::Model] updated base model
|
85
|
+
def set_post_request_script_param(args)
|
86
|
+
args[1].current_query.post_request_scriptparam = args[0]
|
87
|
+
args[1]
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Adds a pre-request script to the request
|
92
|
+
#
|
93
|
+
# @param [args] arguments containing a String with the name of the script
|
94
|
+
# @return [Trophonius::Model] updated base model
|
95
|
+
def set_prerequest_script(args)
|
96
|
+
args[1].current_query.prerequest_script = args[0]
|
97
|
+
args[1]
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Adds a pre-request scriptparameter to the request
|
102
|
+
#
|
103
|
+
# @param [args] arguments containing a String with the name of the scriptparameter
|
104
|
+
# @return [Trophonius::Model] updated base model
|
105
|
+
def set_prerequest_script_param(args)
|
106
|
+
args[1].current_query.prerequest_scriptparam = args[0]
|
107
|
+
args[1]
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Adds a pre-sort script to the request
|
112
|
+
#
|
113
|
+
# @param [args] arguments containing a String with the name of the script
|
114
|
+
# @return [Trophonius::Model] updated base model
|
115
|
+
def set_presort_script(args)
|
116
|
+
args[1].current_query.presort_script = args[0]
|
117
|
+
args[1]
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Adds a pre-request scriptparameter to the request
|
122
|
+
#
|
123
|
+
# @param [args] arguments containing a String with the name of the scriptparameter
|
124
|
+
# @return [Trophonius::Model] updated base model
|
125
|
+
def set_presort_script_param(args)
|
126
|
+
args[1].current_query.presort_scriptparam = args[0]
|
127
|
+
args[1]
|
128
|
+
end
|
129
|
+
|
63
130
|
##
|
64
131
|
# Adds a find request to the original query, resulting in an "Or" find-request for FileMaker
|
65
132
|
#
|
@@ -125,7 +192,6 @@ module Trophonius
|
|
125
192
|
}/layouts/#{@trophonius_model.layout_name}/_find"
|
126
193
|
)
|
127
194
|
)
|
128
|
-
|
129
195
|
new_field_data = @current_query.map { |_q| {} }
|
130
196
|
|
131
197
|
@trophonius_model.create_translations if @trophonius_model.translations.keys.empty?
|
@@ -149,6 +215,21 @@ module Trophonius
|
|
149
215
|
end
|
150
216
|
end
|
151
217
|
|
218
|
+
if @post_request_script.present?
|
219
|
+
body.merge!(script: @post_request_script)
|
220
|
+
body.merge!('script.param' => @post_request_scriptparam) if @post_request_scriptparam.present?
|
221
|
+
end
|
222
|
+
|
223
|
+
if @prerequest_script.present?
|
224
|
+
body.merge!(script: @prerequest_script)
|
225
|
+
body.merge!('script.prerequest.param' => @prerequest_scriptparam) if @prerequest_scriptparam.present?
|
226
|
+
end
|
227
|
+
|
228
|
+
if @presort_script.present?
|
229
|
+
body.merge!(script: @presort_script)
|
230
|
+
body.merge!('script.presort.param' => @presort_scriptparam) if @presort_scriptparam.present?
|
231
|
+
end
|
232
|
+
|
152
233
|
if @portal_limits
|
153
234
|
portal_hash = { portal: @portal_limits.map { |portal_name, limit| "#{portal_name}" } }
|
154
235
|
body.merge!(portal_hash)
|
@@ -157,6 +238,7 @@ module Trophonius
|
|
157
238
|
|
158
239
|
body = body.to_json
|
159
240
|
response = Request.make_request(url, "Bearer #{Request.get_token}", 'post', body)
|
241
|
+
|
160
242
|
if response['messages'][0]['code'] != '0'
|
161
243
|
if response['messages'][0]['code'] == '101' || response['messages'][0]['code'] == '401'
|
162
244
|
resp = RecordSet.new(@trophonius_model.layout_name, @trophonius_model.non_modifiable_fields).send(method, *args, &block)
|
@@ -178,7 +260,26 @@ module Trophonius
|
|
178
260
|
else
|
179
261
|
r_results = response['response']['data']
|
180
262
|
ret_val = RecordSet.new(@trophonius_model.layout_name, @trophonius_model.non_modifiable_fields)
|
263
|
+
|
181
264
|
r_results.each do |r|
|
265
|
+
r['fieldData'].merge!('post_request_script_result' => response['response']['scriptResult']) if response['response']['scriptResult']
|
266
|
+
|
267
|
+
if response['response']['scriptResult.presort']
|
268
|
+
r['fieldData'].merge!('presort_script_result' => response['response']['scriptResult.presort'])
|
269
|
+
end
|
270
|
+
|
271
|
+
if response['response']['scriptResult.prerequest']
|
272
|
+
r['fieldData'].merge!('prerequest_script_result' => response['response']['scriptResult.prerequest'])
|
273
|
+
end
|
274
|
+
|
275
|
+
r['fieldData'].merge!('post_request_script_error' => response['response']['scriptError']) if response['response']['scriptError']
|
276
|
+
|
277
|
+
r['fieldData'].merge!('presort_script_error' => response['response']['scriptError.presort']) if response['response']['scriptError.presort']
|
278
|
+
|
279
|
+
if response['response']['scriptError.prerequest']
|
280
|
+
r['fieldData'].merge!('prerequest_script_error' => response['response']['scriptError.prerequest'])
|
281
|
+
end
|
282
|
+
|
182
283
|
hash = @trophonius_model.build_result(r)
|
183
284
|
ret_val << hash
|
184
285
|
end
|
data/lib/trophonius_record.rb
CHANGED