Last active
          July 3, 2018 21:24 
        
      - 
      
- 
        Save gregory/3c98a10cc009ae9f333cd0018523afc5 to your computer and use it in GitHub Desktop. 
Revisions
- 
        gregory revised this gist Jul 3, 2018 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ Just a Handy Nylas client based on curl ```sh curl https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/40917888cd1e903bbd9ab0cbe33d6863728bcf4b/nylas.sh --output /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Apr 9, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ Just a Handy Nylas client based on curl ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/40917888cd1e903bbd9ab0cbe33d6863728bcf4b/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Apr 9, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -62,15 +62,15 @@ main() { Usage: TOKEN=token AT=TIME_DETLA $0 stream - to stream deltas # will stream deltas TOKEN=token AT=TIME_DELTA $0 cursor # will return a Nylas cursor TOKEN=token $0 [get|post|delete|head|put] /ENDPOINT [ARGS] # will hit Nylas TOKEN=token $0 search "from:[email protected]" # will search for threads TOKEN=token $0 download FILE_ID # will download a file locally Examples: TOKEN=token AT=-1H $0 stream --data-urlencode "include_types=file" |jq TOKEN=token AT=-3M $0 cursor TOKEN=token $0 get /messages/:id TOKEN=token $0 get /files/:id TOKEN=token $0 put /threads/:id -d '{"folder_id":FOLDER_ID}' 
- 
        gregory revised this gist Jan 17, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ Just a Handy Nylas client based on curl ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/d0dad6c8cb1e9e58aa3d9b731b3bf3ed9384b904/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Jan 17, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ Just a Handy Nylas client based on curl ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/7c691b224c915d16edebf7c05ae606542b5a75ca/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Jan 17, 2018 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,6 +36,9 @@ main() { download) $CURL -O -J "$NYLAS_API/files/$*/download" ;; upload) $CURL "$NYLAS_API/files -F filename=$1 -F image=@$2" ;; search) QUERY=$1 shift @@ -77,4 +80,4 @@ EOL ;; esac } [[ "$0" == "$BASH_SOURCE" ]] && main $@ 
- 
        gregory revised this gist Oct 3, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Just a Handy Nylas client based on curl ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/f320e13168fe15a954f8d558c4a52d5dd92a684a/nylas.sh > /usr/local/bin/nylas 
- 
        gregory revised this gist Oct 3, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #instructions ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/f320e13168fe15a954f8d558c4a52d5dd92a684a/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Oct 3, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -47,7 +47,7 @@ main() { METHOD=`echo "$command" | tr '[a-z]' '[A-Z]'` ENDPOINT=$1 shift $CURL -X $METHOD $NYLAS_API$ENDPOINT $* ;; *) cat<<-EOL 
- 
        gregory revised this gist Oct 2, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #instructions ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/eebe45c7600d213e957554f8a89c480eef4005cb/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` 
- 
        gregory revised this gist Oct 2, 2017 . 2 changed files with 55 additions and 64 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,10 @@ #instructions ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/e5210767faa50b8b58ed555bf8716eb20703e516/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas /usr/local/bin/nylas ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,73 +1,80 @@ #!/bin/bash SED=/usr/bin/sed CURL="/usr/bin/curl -s" DATE=/bin/date TOKEN=${TOKEN:?"TOKEN environment variable expected"} NYLAS_API="https://$TOKEN:@api.nylas.com" setCursor() { if [ -z $AT ]; then CURSOR=$($CURL -X POST "$NYLAS_API/delta/latest_cursor" |$SED -n 's/\s*"cursor": "\(.*\)"/\1/p'|tr -d '[:space:]') else TIME_IN_S=$($DATE -v "$AT" '+%s') CURSOR=$($CURL --data "{\"start\":$TIME_IN_S}" "$NYLAS_API/delta/generate_cursor" |$SED -n 's/\s*"cursor": "\(.*\)"/\1/p'|tr -d '[:space:]') fi } main() { command=$1 shift case "$command" in stream) if [ -z "$CURSOR" ]; then setCursor fi $CURL -G -N $NYLAS_API/delta/streaming --data-urlencode "cursor=$CURSOR" $* ;; cursor) setCursor $* if [ -z "$TIME_IN_S" ]; then echo "Latest Cursor> $CURSOR" else echo "Cursor at $(date -r $TIME_IN_S)> $CURSOR" fi ;; download) $CURL -O -J "$NYLAS_API/files/$*/download" ;; search) QUERY=$1 shift $CURL -G -N $NYLAS_API/threads/search/streaming --data-urlencode "q=$QUERY" ;; *) case "$command" in get|post|delete|head|put) METHOD=`echo "$command" | tr '[a-z]' '[A-Z]'` ENDPOINT=$1 shift $CURL -X $METHOD $NYLAS_API/$ENDPOINT $* ;; *) cat<<-EOL ------------------------------------------------------------------- NOTE: For more info about the TIME_DELTA, check 'man date at -v' ------------------------------------------------------------------- Usage: TOKEN=token AT=TIME_DETLA $0 stream - to stream deltas # will stream deltas TOKEN=token $0 [get|post|delete|head|put] /ENDPOINT [ARGS] # will hit Nylas TOKEN=token $0 cursor # will return a Nylas cursor TOKEN=token $0 search "from:[email protected]" # will search for threads TOKEN=token $0 download FILE_ID # will download a file locally Examples: TOKEN=token $0 AT=-1H stream --data-urlencode "include_types=file" |jq TOKEN=token $0 cursor -3M TOKEN=token $0 get /messages/:id TOKEN=token $0 get /files/:id TOKEN=token $0 put /threads/:id -d '{"folder_id":FOLDER_ID}' EOL ;; esac ;; esac } [[ "$0" == "$BASH_SOURCE" ]] && main $@ 
- 
        gregory revised this gist Jul 21, 2017 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,3 +13,14 @@ Then use it like this: TOKEN=SOME_TOKEN nylas [get|put|post] ENDPOINT(ex: /threads/:thread_id) ARGS Now you can also stream content from a cusror in the past like this: easter egg: TOKEN=SOME_TOKEN nylas stream ```sh Time ago ex -1H or -2d>-2d NOW YOU LL SEE ALL THE DELTA SINCE TWO DAYS AGO UP TO NOW :) ``` 
- 
        gregory revised this gist Jul 21, 2017 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #instructions You'll need to `brew install httpie jq` then save the file to your local. ex: ```sh curl -O https://gist.github.com/gregory/3c98a10cc009ae9f333cd0018523afc5/raw/e5210767faa50b8b58ed555bf8716eb20703e516/nylas.sh > /usr/local/bin/nylas chmod +x /usr/local/bin/nylas ``` Then use it like this: TOKEN=SOME_TOKEN nylas [get|put|post] ENDPOINT(ex: /threads/:thread_id) ARGS 
- 
        gregory renamed this gist Jul 21, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        gregory created this gist Jul 21, 2017 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ #!/bin/bash TOKEN=${TOKEN:?"TOKEN environment variable expected"} HTTP=/usr/local/bin/http BASE64=/usr/bin/base64 SED=/usr/bin/sed CURL=/usr/bin/curl DATE=/bin/date HEADERS="authorization: Basic $(echo -ne "$TOKEN:" |$BASE64) conent-type:json" NYLAS_API="https://api.nylas.com" setCursor() { cat<<-EOL Usage: -1H for an hour ago or -2d for two days ago More info in man date at -v EOL echo -n "Time ago ex -1H or -2d>" read delta timeInS=$($DATE -v "$delta" '+%s') CURSOR=$($HTTP POST "$NYLAS_API/delta/generate_cursor" "start:=$timeInS" "$HEADERS"|$SED -n 's/\s*"cursor": "\(.*\)"/\1/p'|tr -d '[:space:]') echo "Cursor Is: $CURSOR" } main() { command=$1 shift case "$command" in headers) echo $HEADERS ;; stream) if [ -z "$CURSOR" ]; then setCursor fi echo $CURSOR $HTTP --stream -f GET "$NYLAS_API/delta/streaming?cursor=$CURSOR" "$HEADERS"|jq #$($CURL --request GET --url "$NYLAS_API/delta/streaming?cursor=$CURSOR" --header "$HEADERS")|jq --stream ;; cursor) setCursor ;; download) FILENAME=$($HTTP GET "$NYLAS_API/$*" "$HEADERS"|jq '.filename'|tr -d '"') $HTTP -dco "$FILENAME" GET "$NYLAS_API$*/download" "$HEADERS" ;; post) $HTTP POST $NYLAS_API$* "$HEADERS" ;; put) $HTTP PUT $NYLAS_API$* "$HEADERS" ;; head) $HTTP HEAD $NYLAS_API$* "$HEADERS" ;; get) $HTTP -f GET $NYLAS_API$* "$HEADERS" ;; delete) $HTTP DELETE $NYLAS_API$* "$HEADERS" ;; *) cat<<-EOL Usage: $0 stream - to stream content $0 [post|get|delete] to post,get or delte $0 cursor to get a cursor Example: $0 get /messages/id $0 stream /delta/streaming?cursor=7da29uzsycsagb0r197njd5tn EOL ;; esac } [[ "$0" == "$BASH_SOURCE" ]] && main $@