Skip to content

Commit 20f2292

Browse files
authored
Merge pull request #157 from johnhuffmanattrackvia/TrackVia-GetRecord-SandboxAccess
adding an action to fetch a record by ID and adding the sandbox acces…
2 parents df118ab + 8706ff6 commit 20f2292

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

custom_connectors/oauth2/trackvia.rb

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
hint: 'Enter your TrackVia subdomain. e.g. customdomain.trackvia.com. By default, <b>go.trackvia.com</b> will be used.',
1010
optional: 'true'
1111
},
12+
{
13+
name: 'account_id',
14+
control_type: :number,
15+
label: 'Account ID',
16+
hint: 'Specify the account to connect to',
17+
optional: true
18+
},
1219
{
1320
name: 'client_id',
1421
control_type: :text,
@@ -66,6 +73,7 @@
6673
apply: lambda { |connection, access_token|
6774
params(user_key: connection['user_key'])
6875
headers(Authorization: "Bearer #{access_token}")
76+
headers('account-id': connection['account_id']) if connection['account_id'].present?
6977
}
7078
},
7179

@@ -261,6 +269,69 @@
261269
},
262270
actions: {
263271
# GET requests
272+
get_record: {
273+
description: "Get <span class='provider'>record</span> in <span class='provider'>TrackVia</span>",
274+
help: 'Get a record in TrackVia',
275+
276+
config_fields: [
277+
{
278+
name: 'app_name',
279+
label: 'Application',
280+
control_type: 'select',
281+
pick_list: 'apps',
282+
optional: false,
283+
hint: 'Select a TrackVia application from the list above'
284+
},
285+
{
286+
name: 'view_id',
287+
label: 'View',
288+
control_type: 'select',
289+
pick_list: 'views',
290+
pick_list_params: { app_name: 'app_name' },
291+
optional: false,
292+
hint: 'Select an available view from the list above.',
293+
toggle_hint: 'Select from list',
294+
toggle_field: {
295+
name: 'view_id',
296+
label: 'View ID',
297+
type: :integer,
298+
disable_formula: true,
299+
control_type: 'plain_text',
300+
toggle_hint: 'Enter custom value',
301+
hint: 'Select the required view. ID can be found at the end of URL.'
302+
}
303+
},
304+
{
305+
name: 'id',
306+
type: 'integer',
307+
label: 'ID',
308+
control_type: 'number',
309+
optional: false,
310+
hint: <<-HINT
311+
Internal ID of the record. Select the required record.<br/>
312+
If the URL ends like tables/15/views/341/records/view/51/form/584, then <b>51</b> is the record ID.
313+
HINT
314+
}
315+
],
316+
317+
execute: lambda do |_connection, input, e_i_s, e_o_s|
318+
response = get("views/#{input['view_id']}/records/#{input['id']}")
319+
.after_error_response(/.*/) do |_code, body, _header, message|
320+
error("#{message} : #{body}")
321+
end&.[]('data')
322+
call(:format_output, response, e_o_s)
323+
end,
324+
325+
output_fields: lambda { |object_definitions|
326+
object_definitions['list_record']
327+
},
328+
329+
sample_output: lambda { |_connection, input, e_o_s|
330+
record = call(:get_fields_sample_output, view_id: input['view_id'])
331+
call(:format_output, record, e_o_s)
332+
}
333+
},
334+
264335
get_all_view_records: {
265336
description: "Get all <span class='provider'>records</span> from a view in <span class='provider'>TrackVia</span>",
266337
help: "Fetches records of a specified view in TrackVia. Maximum of 1000 records will be returned.",
@@ -1010,4 +1081,4 @@
10101081
}
10111082
}
10121083
}
1013-
}
1084+
}

0 commit comments

Comments
 (0)