johnthepink / alfred2-basecrm

Alfred 2 Base CRM Workflow
http://www.packal.org/workflow/base-crm
4 stars 1 forks source link

Improved Search Functionality #5

Closed SethCalkins closed 10 months ago

SethCalkins commented 9 years ago

Improve Search Functionality

Purpose

X-DEVICE-UNIQUE-ID X-Basecrm-Device-UUID

https://sync.futuresimple.com/api/v1/search.json

URL Params.

term={query}

Headers

curl -o output -X GET "https://sync.futuresimple.com/api/v1/search.json?term=Mic" \
     -H "User-Agent: Base/806 CFNetwork/711.1.12 Darwin/14.0.0" \
     -H "Connection: keep-alive" \
     -H "Accept: */*" \
     -H "X-CLIENT-VERSION: 2.19" \
     -H "Accept-Language: en-US" \
     -H "X-DEVICE-UNIQUE-ID: 00AA0000-000A-000A-0000-AAA00A0AAAAA" \
     -H "X-Basecrm-Device-UUID: 00AA0000-000A-000A-0000-AAA00A0AAAAA" \
     -H "X-PLATFORM-VERSION: 8.1" \
     -H "Host: sync.futuresimple.com" \
     -H "X-Futuresimple-Token: {API KEY}" \
     -H "X-DEVICE-ID: iPhone7,1" \
     -H "Content-Type: application/json" \
     -H "X-CLIENT-TYPE: ios-iphone" \
     -H "Accept-Encoding: gzip, deflate" \
     -H "X-Futuresimple-Api-Token: {API KEY}" \
     -H "X-Pipejump-Auth: {API KEY}" \
     -L \
     -m 30 \

Results In Returned in JSON

[
   {
      "data":{
         "id":73361776,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Michael",
         "last_name":"Calkins",
         "name":"Michael Calkins",
         "company_name":"Liquid Communications",
         "email":"<Email Address Redacted>",
         "created_at":"2014-10-22T17:39:11Z",
         "updated_at":"2014-11-08T00:56:35Z"
      },
      "metadata":{
         "title":"Michael Calkins",
         "subtitle":"Liquid Communications",
         "searchable_id":73361776,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":72150004,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Michael",
         "last_name":"Aalberg",
         "name":"Michael Aalberg",
         "company_name":null,
         "email":"<Email Address Redacted>",
         "created_at":"2014-10-06T16:56:22Z",
         "updated_at":"2014-10-06T16:56:22Z"
      },
      "metadata":{
         "title":"Michael Aalberg",
         "subtitle":null,
         "searchable_id":72150004,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":73262023,
         "account_id":402252,
         "user_id":553048,
         "first_name":null,
         "last_name":null,
         "name":"Dynamic Voice Data",
         "company_name":null,
         "email":"",
         "created_at":"2014-10-21T01:12:05Z",
         "updated_at":"2014-10-21T01:12:10Z"
      },
      "metadata":{
         "title":"Dynamic Voice Data",
         "subtitle":null,
         "searchable_id":73262023,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":72150007,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Michael",
         "last_name":"Splitt",
         "name":"Michael Splitt",
         "company_name":"In Sync Systems",
         "email":"<Email Address Redacted>",
         "created_at":"2014-10-06T16:56:23Z",
         "updated_at":"2014-10-20T16:29:58Z"
      },
      "metadata":{
         "title":"Michael Splitt",
         "subtitle":"In Sync Systems",
         "searchable_id":72150007,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":76915418,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Michael",
         "last_name":"Murphy",
         "name":"Michael Murphy",
         "company_name":"Total Technologies LLC",
         "email":null,
         "created_at":"2014-12-08T17:10:31Z",
         "updated_at":"2014-12-08T17:10:32Z"
      },
      "metadata":{
         "title":"Michael Murphy",
         "subtitle":"Total Technologies LLC",
         "searchable_id":76915418,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":72149857,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Bryan",
         "last_name":"Reynolds",
         "name":"Bryan Reynolds",
         "company_name":"Dynamic Voice Data",
         "email":"<Email Address Redacted>",
         "created_at":"2014-10-06T16:55:50Z",
         "updated_at":"2014-10-21T01:12:10Z"
      },
      "metadata":{
         "title":"Bryan Reynolds",
         "subtitle":"Dynamic Voice Data",
         "searchable_id":72149857,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":74994072,
         "account_id":402252,
         "user_id":553048,
         "first_name":"Troy",
         "last_name":"Stanton",
         "name":"Troy Stanton",
         "company_name":"Regency Tele-Com",
         "email":"<Email Address Redacted>",
         "created_at":"2014-11-14T16:08:23Z",
         "updated_at":"2014-11-14T16:08:24Z"
      },
      "metadata":{
         "title":"Troy Stanton",
         "subtitle":"Regency Tele-Com",
         "searchable_id":74994072,
         "searchable_type":"Contact",
         "data_type":"Contact"
      }
   },
   {
      "data":{
         "id":18586257,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":null,
         "last_name":null,
         "company_name":"Dynamics Solutions Group",
         "created_at":"2014-10-17T04:52:40Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Dynamics Solutions Group",
         "subtitle":"",
         "searchable_id":18586257,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929627,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Amici",
         "company_name":"Uinta Telecommunications, Llc",
         "created_at":"2014-10-06T00:35:38Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Uinta Telecommunications, Llc",
         "subtitle":"",
         "searchable_id":17929627,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929631,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Humphrey",
         "company_name":"360 Telecommunications",
         "created_at":"2014-10-06T00:35:38Z",
         "updated_at":null
      },
      "metadata":{
         "title":"360 Telecommunications",
         "subtitle":"",
         "searchable_id":17929631,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927964,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Georgia",
         "last_name":"Micola",
         "company_name":"Jacks Telecom",
         "created_at":"2014-10-06T00:34:34Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Jacks Telecom",
         "subtitle":"",
         "searchable_id":17927964,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927993,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Paez",
         "company_name":"Rising Phoenix Invesment Llc",
         "created_at":"2014-10-06T00:34:36Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Rising Phoenix Invesment Llc",
         "subtitle":"",
         "searchable_id":17927993,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929307,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Micka",
         "company_name":"Mgm Communications",
         "created_at":"2014-10-06T00:35:24Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Mgm Communications",
         "subtitle":"",
         "searchable_id":17929307,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17928428,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Meekins",
         "company_name":"Comtura Networks",
         "created_at":"2014-10-06T00:34:52Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Comtura Networks",
         "subtitle":"",
         "searchable_id":17928428,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17928440,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Kirchhoff",
         "company_name":"Datatel 360, Inc.",
         "created_at":"2014-10-06T00:34:52Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Datatel 360, Inc.",
         "subtitle":"",
         "searchable_id":17928440,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929037,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Snyder",
         "company_name":"Total Business Communications, Inc.",
         "created_at":"2014-10-06T00:35:14Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Total Business Communications, Inc.",
         "subtitle":"",
         "searchable_id":17929037,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17928621,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Mick",
         "last_name":"Mclane",
         "company_name":"Nowcomm, Inc.",
         "created_at":"2014-10-06T00:34:59Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Nowcomm, Inc.",
         "subtitle":"",
         "searchable_id":17928621,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17928663,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Mickey",
         "last_name":"Michalik",
         "company_name":"Classic Communications",
         "created_at":"2014-10-06T00:35:00Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Classic Communications",
         "subtitle":"",
         "searchable_id":17928663,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927907,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Bill",
         "last_name":"Shore",
         "company_name":"Telecom Dynamics, Inc",
         "created_at":"2014-10-06T00:34:31Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Telecom Dynamics, Inc",
         "subtitle":"",
         "searchable_id":17927907,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927988,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Randy",
         "last_name":"Kremlacek",
         "company_name":"Teledynamic Communications, Inc.",
         "created_at":"2014-10-06T00:34:35Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Teledynamic Communications, Inc.",
         "subtitle":"",
         "searchable_id":17927988,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929387,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Rich",
         "last_name":"Cutshall",
         "company_name":"Microcom",
         "created_at":"2014-10-06T00:35:27Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Microcom",
         "subtitle":"",
         "searchable_id":17929387,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17928833,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Aaron",
         "last_name":"Koon",
         "company_name":"Mid-Michigan Communications",
         "created_at":"2014-10-06T00:35:07Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Mid-Michigan Communications",
         "subtitle":"",
         "searchable_id":17928833,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":19220113,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michele",
         "last_name":"Kraulis",
         "company_name":"Perigee Telcom",
         "created_at":"2014-11-01T01:05:25Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Perigee Telcom",
         "subtitle":"",
         "searchable_id":19220113,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":19365954,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Moore",
         "company_name":"Toshiba Phone Systems",
         "created_at":"2014-11-03T19:09:05Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Toshiba Phone Systems",
         "subtitle":"",
         "searchable_id":19365954,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":19520417,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Pounds",
         "company_name":"Southern Datacom, Inc.",
         "created_at":"2014-11-04T22:18:02Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Southern Datacom, Inc.",
         "subtitle":"",
         "searchable_id":19520417,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":18584668,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Hardy",
         "company_name":"Hardy Communications \u0026 Cabling Inc.",
         "created_at":"2014-10-17T03:50:01Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Hardy Communications \u0026 Cabling Inc.",
         "subtitle":"",
         "searchable_id":18584668,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929518,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Harrison",
         "company_name":"Harrison Brothers Communications",
         "created_at":"2014-10-06T00:35:33Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Harrison Brothers Communications",
         "subtitle":"",
         "searchable_id":17929518,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929529,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Keith",
         "last_name":"Michal",
         "company_name":"Cewim, Llc",
         "created_at":"2014-10-06T00:35:34Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Cewim, Llc",
         "subtitle":"",
         "searchable_id":17929529,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929582,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Gardner",
         "company_name":"Telephone \u0026 Data Services",
         "created_at":"2014-10-06T00:35:36Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Telephone \u0026 Data Services",
         "subtitle":"",
         "searchable_id":17929582,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929674,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Hall",
         "company_name":"National Design Group, Inc.",
         "created_at":"2014-10-06T00:35:40Z",
         "updated_at":null
      },
      "metadata":{
         "title":"National Design Group, Inc.",
         "subtitle":"",
         "searchable_id":17929674,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929677,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Purcell",
         "company_name":"Pti Communications",
         "created_at":"2014-10-06T00:35:40Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Pti Communications",
         "subtitle":"",
         "searchable_id":17929677,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929683,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Morrison",
         "company_name":"Orion Networks",
         "created_at":"2014-10-06T00:35:40Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Orion Networks",
         "subtitle":"",
         "searchable_id":17929683,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929738,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Tatro",
         "company_name":"Consult-Techs.Com",
         "created_at":"2014-10-06T00:35:43Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Consult-Techs.Com",
         "subtitle":"",
         "searchable_id":17929738,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927922,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Newton",
         "company_name":"S3P Communications",
         "created_at":"2014-10-06T00:34:32Z",
         "updated_at":null
      },
      "metadata":{
         "title":"S3P Communications",
         "subtitle":"",
         "searchable_id":17927922,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17927968,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Ferreira",
         "company_name":"Ferreira Communications",
         "created_at":"2014-10-06T00:34:34Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Ferreira Communications",
         "subtitle":"",
         "searchable_id":17927968,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929274,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Kelly",
         "company_name":"Phone Medic, Llc",
         "created_at":"2014-10-06T00:35:23Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Phone Medic, Llc",
         "subtitle":"",
         "searchable_id":17929274,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":17929315,
         "account_id":402252,
         "user_id":553048,
         "owner_id":553048,
         "first_name":"Michael",
         "last_name":"Cummings",
         "company_name":"Mac Communications",
         "created_at":"2014-10-06T00:35:25Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Mac Communications",
         "subtitle":"",
         "searchable_id":17929315,
         "searchable_type":"Lead",
         "data_type":"Lead"
      }
   },
   {
      "data":{
         "id":27289694,
         "account_id":402252,
         "user_id":553048,
         "content":"Vodavi...usually sell Shor-tel....\nGave me a number for Michael.",
         "noteable_type":"SalesAccount",
         "noteable_id":76915418,
         "created_at":"2014-12-08T17:22:53Z",
         "updated_at":null
      },
      "metadata":{
         "title":"Vodavi...usually sell Shor-tel....\nGave me a number for Michael.",
         "subtitle":"",
         "searchable_id":76915418,
         "searchable_type":"SalesAccount",
         "data_type":"Note"
      }
   },
   {
      "data":{
         "id":26334698,
         "account_id":402252,
         "user_id":553048,
         "content":"Notes",
         "noteable_type":"SalesAccount",
         "noteable_id":75519917,
         "created_at":"2014-11-21T18:52:00Z",
         "updated_at":null
      },
      "metadata":{
         "title":Arbitrary Title",
         "subtitle":"",
         "searchable_id":75519917,
         "searchable_type":"SalesAccount",
         "data_type":"Note"
      }
   },
   {
      "data":{
         "id":8978581,
         "account_id":402252,
         "user_id":553048,
         "content":"Called Michael he said December would be great he will hold for us he indicated it was probably a better time than now anyways ",
         "taskable_type":"SalesAccount",
         "taskable_id":72150007,
         "done":true,
         "created_at":null,
         "updated_at":null
      },
      "metadata":{
         "title":"Called Michael he said December would be great he will hold for us he indicated it was probably a better time than now anyways ",
         "subtitle":"",
         "searchable_id":72150007,
         "searchable_type":"SalesAccount",
         "data_type":"Task"
      }
   },
   {
      "data":{
         "id":9629241,
         "account_id":402252,
         "user_id":555600,
         "content":"Call Michael Murphy to schedule appointment",
         "taskable_type":"SalesAccount",
         "taskable_id":76915418,
         "done":false,
         "created_at":null,
         "updated_at":null
      },
      "metadata":{
         "title":"Call Michael Murphy to schedule appointment",
         "subtitle":"",
         "searchable_id":76915418,
         "searchable_type":"SalesAccount",
         "data_type":"Task"
      }
   }
]
johnthepink commented 9 years ago

Interesting. Good find. I will take a look at this.

johnthepink commented 9 years ago

Hey @SCalkins I was able to get the new search endpoint working. It's a lot nicer and faster! I wanted to get you to test it before I merged. Make sure it's returning all your data and generating the right links and such.

This should make #4 a lot easier as well.

New workflow

SethCalkins commented 9 years ago

Sorry Didn't see you posted something --

I'm returning results from the workflow but, I get the same results regardless of what I type.

SethCalkins commented 9 years ago

Also, If I type >= 4 letters for {query} results are no longer showing

johnthepink commented 9 years ago

@SCalkins nice work on the code. I repackaged it for you to try it. If it works for you, I can turn caching back on, which will make it a bit faster.

Updated workflow