trophonius 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trophonius_query.rb +102 -1
- 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: b5cfb56042719c5acb4e4005f9faa66a0f748e7929226a10bcc2993a531f0d14
|
4
|
+
data.tar.gz: a735cdd0c6af4547795fda4a06fbaacd9e006d295f538b7a18da620585ccb309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16a5eaaf5690005ff1830edcde19d9a91f7bf7eeaee8f379c123eb4ce1ffcc0bd607d1314f14525387da742744f80fc028882f85f1d3dcba42c9f4ff696f91b8
|
7
|
+
data.tar.gz: 1a22f058592aa168c601ca5419fa8beb6a0c277367a0e797228083e6d80aff79bec7dad65eb9c578cb89834ca2bfdf85b6047829eef0b3d8c38fe93f97770f52
|
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_script_param) if @post_request_script_param.present?
|
221
|
+
end
|
222
|
+
|
223
|
+
if @prerequest_script.present?
|
224
|
+
body.merge!(script: @prerequest_script)
|
225
|
+
body.merge!('script.param' => @prerequest_script_param) if @prerequest_script_param.present?
|
226
|
+
end
|
227
|
+
|
228
|
+
if @presort_script.present?
|
229
|
+
body.merge!(script: @presort_script)
|
230
|
+
body.merge!('script.param' => @presort_script_param) if @presort_script_param.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
|