Skip to content

Instantly share code, notes, and snippets.

@mmcguff
Created August 26, 2020 16:33
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 mmcguff/dc1728f6446647d1deea913ddc32eeb9 to your computer and use it in GitHub Desktop.
Save mmcguff/dc1728f6446647d1deea913ddc32eeb9 to your computer and use it in GitHub Desktop.
Code for the custom Sugar CRM Custom connector
{
title: "SugarCRM",
connection: {
fields: [
{
name: "base_url",
hint: "Provide the REST endpoint for your Sugar CRM Instance. " \
"The REST version and the release version are different. See " \
"<a href='https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.0/Integration/Web_Services/' " \
"target='_blank'>Docs</a> for more details.",
optional: false
},
{
label: "Client Id",
name: "client_id",
optional: false,
},
{
label: "Client Secret",
name: "client_secret",
optional: true
},
{
name: "username",
hint: "Enter your sugar CRM username.",
optional: false
},
{
name: "password",
hint: "Enter your sugar CRM password.",
control_type: "password",
optional: false
},
],
authorization: {
type: 'custom-auth',
acquire: lambda do | connection|
response = post(connection["base_url"] + '/oauth2/token',
grant_type: "password",
client_id: connection["client_id"],
client_secret: connection["client_secret"],
username: connection["username"],
password: connection["password"],
platform: "leadMethod"
)
{
access_token: response["access_token"],
refresh_token: response["refresh_token"]
}
end,
refresh_on: [401, 403],
refresh: lambda do | connection, refresh_token|
response = post(connection["base_url"] + '/oauth2/token',
grant_type: "refresh_token",
refresh_token: refresh_token,
client_id: connection["refresh_token"],
client_secret: connection["client_secret"],
platform: "leadMethod"
),
{
access_token: response["access_token"],
refresh_token: response["refresh_token"]
}
end,
# TODO: This access token isn't showing up the way it should.
# Ass a work around for building action we can insert out own token but this must get fixed.
apply: lambda do |connection, access_token|
headers(Authorization: "Bearer #{connection["access_token"]}")
end,
},
},
test: lambda do |connection |
post(connection['base_url'] + '/oauth2/token',
grant_type: "password",
client_id: connection["client_id"],
client_secret: connection["client_secret"],
username: connection["username"],
password: connection["password"],
platform: "leadMethod"
)
end,
object_definitions: {
opporutnity: {
fields: ->(){
[
{name: "id", type: "string"},
{name: "name", type: "string"},
{name: "date_entered", type: "string"},
{name: "date_modified", type: "string"},
{name: "modified_user_id", type: "string"},
{name: "modified_by_name", type: "string"},
{name: "modified_by_link", type: "object",
properties: [
{name: "full_name", type:"string"},
{name: "id", type:"string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "user_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "user_hash", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "system_generated_password", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "pwd_last_change", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "authenticate_id", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "sugar_login", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_admin", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "external_auth_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "last_login", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "title", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "department", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "license_type", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "portal_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "show_on_employees", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "employee_status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_group", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "created_by", type: "string"},
{name: "created_by_name", type: "string"},
{name: "created_by_link", type: "object",
properties: [
{name: "full_name", type: "string"},
{name: "id", type: "string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "user_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "user_hash", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "system_generated_password", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "pwd_last_change", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "authenticate_id", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "sugar_login", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_admin", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "external_auth_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "last_login", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "title", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "department", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "license_type", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "portal_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "show_on_employees", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "employee_status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_group", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "descritpion", type: "string"},
{name: "deleted", type: "boolean"},
{name: "opportutnity_type", type: "string"},
{name: "account_name", type: "string"},
{name: "accounts", type: "object",
properties: [
{name: "name", type: "string"},
{name: "id", type: "string"},
{name: "_acl", type: "object",
properties: [
{name: "fields", type: "array", of: "object"},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "_hash", type: "string"}
]}
]},
{name: "account_id", type: "string"},
{name: "campaign_id", type: "string"},
{name: "campaign_name", type: "string"},
{name: "campaign_opportunitites", type: "object",
properties: [
{name: "name", type: "string"},
{name: "id", type: "string"},
{name: "_acl", type: "object",
properties: [
{name: "fields", type: "array", of: "object"},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "_hash", type: "string"}
]}
]},
{name: "lead_source", type: "string"},
{name: "amount", type: "string"},
{name: "amount_usdollar", type: "string"},
{name: "date_closed", type: "string"},
{name: "date_closed_timestamp", type: "integer"},
{name: "next_step", type: "string"},
{name: "sales_stage", type: "string"},
{name: "sales_status", type: "string"},
{name: "probability", type: "string"},
{name: "best_case", type: "string"},
{name: "worst_case", type: "string"},
{name: "commit_stage", type: "string"},
{name: "service_start_date", type: "string"},
{name: "service_open_revenue_line_items", type: "string"},
{name: "service_start_date_cascade", type: "string"},
{name: "total_revenue_line_items", type: "integer"},
{name: "closed_revenue_line_items", type: "integer"},
{name: "included_revenue_line_items", type: "integer"},
{name: "renewal_parent_id", type: "string"},
{name: "widget_sales_stage", type: "string"},
{name: "widget_date_closed", type: "string"},
{name: "widget_amount", type: "string"},
{name: "sales_stage_cascade", type: "string"},
{name: "date_closed_cascade", type: "string"},
{name: "contact_role", type: "string"},
{name: "mkto_sync", type: "boolean"},
{name: "mkto_id", type: "string"},
{name: "following", type: "boolean"},
{name: "my_favorite", type: "boolean"},
{name: "tag", type: "array", of: "string"},
{name: "locked_fields", type: "array", of: "string"},
{name: "assigned_user_id", type: "string"},
{name: "assigned_user_name", type: "string"},
{name: "assigned_user_link", type: "object",
properties: [
{name: "full_name", type:"string"},
{name: "id", type:"string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "user_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "user_hash", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "system_generated_password", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "pwd_last_change", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "authenticate_id", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "sugar_login", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_admin", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "external_auth_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "last_login", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "title", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "department", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "license_type", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "portal_only", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "show_on_employees", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "employee_status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "reports_to_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "is_group", type: "object",
properties: [
{name: "read", type: "string"},
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "team_count", type: "string"},
{name: "team_count_link", type: "object",
properties: [
{name: "full_name", type:"string"},
{name: "id", type:"string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_entered", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_modified", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_user_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_by_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "description", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "deleted", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_user_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "activities", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "name_2", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "associated_user_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "private", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "users", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "teams_sets", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "activities_teams", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "following", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "following_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "my_favorite", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "favorite_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "commentlog", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "commentlog_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "locked_fields", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "locked_fields_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "team_name", type:"array", of: "object",
properties: [
{name: "id", type: "string"},
{name: "name", type: "string"},
{name: "name_2", type: "string"},
{name: "primary", type: "boolean"},
{name: "selected", type: "boolean"},
]},
{name: "currency_id", type: "string"},
{name: "base_rate", type: "string"},
{name: "currency_name", type: "string"},
{name: "currencies", type: "object",
properties: [
{name: "full_name", type:"string"},
{name: "id", type:"string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "symbol", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "iso4217", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "conversion_rate", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "status", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "deleted", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_entered", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_modified", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "edit", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "create", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "currency_symbol", type: "string"},
{name: "opportunities_dna_dna_1_name", type: "string"},
{name: "opportunities_dna_dna_1", type: "object",
properties: [
{name: "name", type: "string"},
{name: "id", type: "string"},
{name: "_acl", type: "object",
properties: [
{name: "fields", type: "array", of: "string"},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "opportunities_dna_dna_1dna_dna_idb", type: "string"},
{name: "actuated_linear_guide_system_c", type: "string"},
{name: "actual_close_date_c", type: "string"},
{name: "admin_fix_c", type: "boolean"},
{name: "asp_c", type: "boolean"},
{name: "bwc_products_c", type: "boolean"},
{name: "bwc_strategy_c", type: "array", of: "string"},
{name: "bwc_products_pricing_c", type: "string"},
{name: "actual_close_date_c", type: "string"},
{name: "closed_won_cbk_c", type: "boolean"},
{name: "hepco_pricing_c", type: "string"},
{name: "dna_alert_1_c", type: "boolean"},
{name: "hepcoproducts_c", type: "boolean"},
{name: "distributor_name_c", type: "string"},
{name: "dna_alert_2_c", type: "boolean"},
{name: "dna_alert_3_c", type: "boolean"},
{name: "distributor_c", type: "boolean"},
{name: "dna_status_c", type: "string"},
{name: "lopro_c", type: "boolean"},
{name: "mrkto2_expected_revenue_c", type: "string"},
{name: "is_nda_c", type: "boolean"},
{name: "mkto2_campaign_c", type: "string"},
{name: "lopro_pricing_c", type: "string"},
{name: "nda_alert_1_c", type: "boolean"},
{name: "nda_alert_2_c", type: "boolean"},
{name: "nda_status_c", type: "string"},
{name: "nda_alert_3_c", type: "boolean"},
{name: "negotiation_date_c", type: "string"},
{name: "new_account_c", type: "boolean"},
{name: "notes_c", type: "string"},
{name: "new_oem_c", type: "string"},
{name: "order_value_c", type: "string"},
{name: "opportunity_closed_by_c", type: "string"},
{name: "opp_admin_notes_c", type: "string"},
{name: "other_c", type: "boolean"},
{name: "other_estimated_pricing_c", type: "string"},
{name: "proposal_date_c", type: "string"},
{name: "prototype_c", type: "boolean"},
{name: "qualified_date_c", type: "string"},
{name: "qualification_notes_c", type: "string"},
{name: "quote_value_c", type: "string"},
{name: "rsm_c", type: "string"},
{name: "region_c", type: "string"},
{name: "send_notification_c", type: "boolean"},
{name: "sales_won_notes_c", type: "string"},
{name: "spflo_notes_c", type: "string"},
{name: "trace_c", type: "boolean"},
{name: "spflo_alert_sent_c", type: "boolean"},
{name: "signature_motion_pricing_c", type: "string"},
{name: "signature_motion_c", type: "boolean"},
{name: "spflo_flag_c", type: "string"},
{name: "start_date_c", type: "string"},
{name: "total_age_in_days_c", type: "integer"},
{name: "territory_c", type: "string"},
{name: "trace_pricing_c", type: "string"},
{name: "is_dna_c", type: "boolean"},
{name: "primary_contact_c", type: "string"},
{name: "contact_count_c", type: "integer"},
{name: "recentcampaign_c", type: "string"},
{name: "risk_level_c", type: "string"},
{name: "primary_contact_campaign_c", type: "string"},
{name: "opportunity_campaign_c", type: "string"},
{name: "hdyhau_c", type: "string"},
{name: "gfx_products_c", type: "boolean"},
{name: "gfx_estimated_pricing_c", type: "string"},
{name: "close_reason_c", type: "string"},
{name: "sugar_syspro_id", type: "integer"},
{name: "mql_campaign_c", type: "string"},
{name: "dri_workflow_template_id", type: "string"},
{name: "dri_workflow_template_name", type: "string"},
{name: "dri_workflow_template_link", type: "object",
properties: [
{name: "full_name", type:"string"},
{name: "id", type:"string"},
{name: "_acl", type:"object",
properties: [
{name: "fields", type: "object",
properties: [
{name: "id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_entered", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "date_modified", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_user_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_by_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "description", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "deleted", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "created_by_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "modified_user_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "activities", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "following", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "following_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "my_favorite", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "favorite_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "tag", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "tag_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "commentlog", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "commentlog_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "locked_fields", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "locked_fields_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_set_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "acl_team_set_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_count", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "acl_team_names", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "team_count_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "teams", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "available_modules", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "disabled_stage_actions", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "disabled_activity_actions", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "dri_workflows", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "dri_subworkflow_templates", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "dri_workflow_task_templates", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "forms", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "copies", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "tasks", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "meetings", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "calls", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "accounts", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "contacts", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "leads", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "cases", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "opportunities", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "active_limit", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "points", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "related_activities", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "active", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "assignee_rule", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "target_assignee", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "web_hooks", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "copied_template_id", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "copied_template_name", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
{name: "copied_template_link", type: "object",
properties: [
{name: "write", type: "string"},
{name: "create", type: "string"},
]},
]},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "edit", type: "string"},
{name: "delete", type: "string"},
{name: "import", type: "string"},
{name: "massupdate", type: "string"},
{name: "create", type: "string"},
{name: "_hash", type: "string"},
]},
]},
{name: "timestamp_status_qualify_c", type: "string"},
{name: "timestamp_status_discovery_c", type: "string"},
{name: "timestamp_status_champion_c", type: "string"},
{name: "timestamp_status_stakeholder_c", type: "string"},
{name: "timestamp_status_evaluation_c", type: "string"},
{name: "timestamp_status_negotiation_c", type: "string"},
{name: "timestamp_status_won_c", type: "string"},
{name: "timestamp_status_closed_c", type: "string"},
{name: "compamy_c", type: "string"},
{name: "quote_notes_c", type: "string"},
{name: "negotiation_notes_c", type: "string"},
{name: "generate_withdrawal_letter_c", type: "string"},
{name: "customer_goal_c", type: "string"},
{name: "diagnostic_notes_c", type: "string"},
{name: "usage_scenario_notes_c", type: "string"},
{name: "solutions_considered_c", type: "string"},
{name: "key_stakeholders_c", type: "string"},
{name: "mql_date_c", type: "string"},
{name: "key_stakeholders_count_c", type: "integer"},
{name: "stakeholder_feedback_count_c", type: "integer"},
{name: "verbal_approval_received_c", type: "string"},
{name: "verbal_approval_notes_c", type: "string"},
{name: "request_quote_creation_c", type: "string"},
{name: "sales_process_path_c", type: "string"},
{name: "request_engr_support_c", type: "string"},
{name: "mrkto2_is_closed_c", type: "boolean"},
{name: "close_reason_details_c", type: "string"},
{name: "last_user_activity_date_c", type: "string"},
{name: "engagement_actions_c", type: "string"},
{name: "total_sales_order_amount_c", type: "string"},
{name: "product_summary_c", type:"array", of:"string"},
{name: "generate_icd_c", type: "string"},
{name: "generate_scd_c", type: "string"},
{name: "generate_ccd_c", type: "string"},
{name: "mrkto2_is_won_c", type: "boolean"},
{name: "opportunities_so_sales_orders_1_name", type: "string"},
{name: "opportunities_so_sales_orders_1_right", type: "object",
properties: [
{name: "name", type: "string"},
{name: "id", type: "string"},
{name: "_acl", type: "object",
properties: [
{name: "fields", type: "array", of: "string"},
{name: "admin", type: "string"},
{name: "developer", type: "string"},
{name: "_hash", type: "string"},
]}
]},
{name: "opportunities_so_sales_orders_1so_sales_orders_idb", type: "string"},
{name: "distance", type: "string"},
{name: "geolocation", type: "string"},
{name: "gc_status_c", type: "string"},
{name: "wmaps_balloon_c", type: "string"},
{name: "gc_latitude_c", type: "number"},
{name: "gc_longitude_c", type: "number"},
{name: "gc_status_detail_c", type: "string"},
{name: "gc_date_c", type: "string"},
{name: "wmaps_pushpin_icon_c", type: "string"},
{name: "contact_id_c", type: "string"},
{name: "mrkto2_fiscal_quarter_c", type: "string"},
{name: "mrkto2_forecastcategoryname_c", type: "string"},
{name: "mrkto2_forecastcategoryname_c", type: "string"},
{name: "_acl", type: "object",
properites: [
{names: "fields", type: "object"}
]},
{name: "_module", type: "string"},
]}
},
opporutnity_update_fields: {
fields: ->() {
[
{name: "name", type: "string"},
{name: "account_id", type: "string"},
{name: "date_closed", type: "string"},
{name: "assigned_user_id", type: "string"},
{name: "region_c", type: "string"},
{name: "sales_stage", type: "string"},
{name: "opportunity_type", type: "string"},
{name: "lead_source", type: "string"},
{name: "next_step", type: "string"},
{name: "mkto_sync", type: "boolean"}
]
}
}
},
actions: {
read_opporutnity: {
input_fields: lambda do
[
{ name: "id", optional: false }
]
end,
execute: lambda do |connection, input|
get(connection["base_url"] + "/Opportunities/#{input["id"]}")
end,
output_fields: lambda do |object_definitions|
object_definitions["opporutnity"]
end
},
update_opporutnity: {
input_fields: lambda do |object_definitions|
[
{ name: "id", optional: false }
].concat(object_definitions["opporutnity"])
end,
execute: lambda do |connection, input|
input.map {|k, v|}
updated_input = input.reject { |k,v| k == 'id' or v == nil or v == "" or v == "null" }
puts(updated_input)
put(connection["base_url"] + "/Opportunities/#{input["id"]}", updated_input)
end,
output_fields: lambda do |object_definitions|
object_definitions["opporutnity"]
end
},
},
triggers: {
new_or_modified_opportunitites: {
#type: :paging_desc,
input_fields: -> () {
[
{
name: "date_modified",
type: :timestamp,
optional: false
},
{
name: "offset",
type: :integer,
optional: false,
value: 0
}
]
},
poll: -> (connection, input) {
max_num = 1;
offset = input["offset"];
can_poll_more = true;
params = {
max_num: max_num,
offset: offset
}.reject {|k, v| v.present? == false}
date_modified_since = (input["date_modified"]).to_time.utc.iso8601
# response = post(connection["base_url"] + "/Opportunities/filter",
response = post("https://lead-method-sugar-crm-api.herokuapp.com/gateway/Opportunities/filter",
{
"filter":[
{
"date_modified":{
"$gte": "#{date_modified_since}"
}
}
]
}
).params(params)
opportuntities = response["records"][0];
if response["next_offset"] == -1
can_poll_more = false
end
{
events: opportuntities,
offset: response["next_offset"],
can_poll_more: can_poll_more
}
},
output_fields: -> (object_definitions){
object_definitions["opporutnity"]
},
dedup: ->(event){
event["id"]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment