Last active
March 18, 2016 01:13
-
-
Save kandadaboggu/548775b39fd0ba32129f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
title: 'Harvest', | |
# HTTP basic auth example. | |
connection: { | |
fields: [ | |
{ | |
name: 'subdomain', | |
control_type: 'subdomain', | |
url: '.harvestapp.com', | |
hint: 'Your subdoaminas found in your Harvest URL' | |
}, | |
{ | |
name: 'username', | |
optional: true, | |
hint: 'Your username; leave empty if using API key below' | |
}, | |
{ | |
name: 'password', | |
control_type: 'password', | |
label: 'Password or personal API key' | |
} | |
], | |
authorization: { | |
type: 'basic_auth', | |
# Basic auth credentials are just the username and password; framework handles adding | |
# them to the HTTP requests. | |
credentials: ->(connection) { | |
# Freshdesk-specific quirk: If only using API key to authenticate, API expects it as username, | |
# but we prefer to store it in 'password' to keep it obscured (control_type: 'password' above). | |
if connection['username'].blank? | |
user(connection['password']) | |
else | |
user(connection['username']) | |
password(connection['password']) | |
end | |
} | |
} | |
}, | |
object_definitions: { | |
}, | |
test: ->(connection) { | |
get("https://#{connection['subdomain']}.harvestapp.com/account/who_am_i") | |
}, | |
actions: { | |
search_users: { | |
input_fields: ->(object_definitions) { | |
}, | |
execute: ->(connection, input) { | |
{ | |
results: get("https://#{connection['subdomain']}.harvestapp.com/people.json", input).map do |row| | |
row['user'] | |
end | |
} | |
}, | |
output_fields: ->(object_definitions) { | |
[ | |
{ | |
name: 'users', | |
type: 'array', | |
of: 'object', | |
properties: [ | |
{ name: 'id', type: 'integer' }, | |
{ name: 'first_name' }, | |
{ name: 'last_name' }, | |
{ name: 'email' }, | |
{ name: 'telephone' }, | |
{ name: 'department' }, | |
{ name: 'cost_rate' }, | |
{ name: 'is_admin', type: 'boolean' }, | |
{ name: 'is_active', type: 'boolean' }, | |
{ name: 'is_contractor', type: 'boolean' }, | |
{ name: 'has_access_to_all_future_projects', type: 'boolean' }, | |
{ name: 'created_at', type: 'date_time' }, | |
{ name: 'updated_at', type: 'date_time' }, | |
] | |
} | |
] | |
} | |
} | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment