Skip to content

Instantly share code, notes, and snippets.

@kandadaboggu
Last active March 18, 2016 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kandadaboggu/548775b39fd0ba32129f to your computer and use it in GitHub Desktop.
Save kandadaboggu/548775b39fd0ba32129f to your computer and use it in GitHub Desktop.
{
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