Skip to content

ht68rohit/gmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gamil OMG Microservice

Open Microservice Guide Build Status codecov

An OMG service for Gmail, this service uses the gmail API and perform gmail operations.

Direct usage in Storyscript:

Note: use scope "https://mail.google.com/" for send, receive and labels operation while authorization and for "filter operations" use scope "https://www.googleapis.com/auth/gmail.settings.basic".

Authorization
gmail authorization scope:'https://mail.google.com/'
Access Token
gmail accessToken authorizationCode:'authorization code generated from URL of authorization'
Refresh Token
gmail refreshToken token:'{"access_token": "access token","token_type": "Bearer","refresh_token": "refresh token","expiry": "2019-10-04T15:57:07.922121141Z"}'
Send Mail
gmail sendMail accessToken:'access token' userId:'[email protected]' to:'["[email protected]",[email protected]]' subject:'mail subject' body:'mail body'
Create Label
gmail createLabel accessToken:'access token' userId:'[email protected]' name:'OMG Label' backgroundColor:'#fce8b3' textColor:'#d5ae49' labelListVisibility:'labelShow' messageListVisibility:'show' 
Delete Label:
gmail deleteLabel accessToken:'access token' userId:'[email protected]' labelId:'label Id'
Patch Label:
gmail patchLabel accessToken:'access token' userId:'[email protected]' labelId:'label Id' name:'OMG Label' backgroundColor:'#fce8b3' textColor:'#d5ae49' labelListVisibility:'labelShow' messageListVisibility:'show' 
List Label
gmail labelList accessToken:'access token' userId:'[email protected]' 
Create Filter
gmail createFilter accessToken:'access token' userId:'[email protected]'  addLabelId='Label Id' removeLabelId='Label Id' excludeChats=false from:'[email protected]' to:'[email protected]' subject:'Mail subject' hasAttachment=false negatedQuery:'Negated query for filter' query:'query for filter' size=1 sizeComparison:smaller 
Delete Filter
gmail deleteFilter accessToken:'access token' userId:'[email protected]' filterId:'filter Id'
List Filter
gmail filterList accessToken:'access token' userId:'[email protected]' 
Receive Mail
gmail subscribe receive mail userId:'email address' accessToken:'access token'

Curious to learn more?

✨🍰✨

Usage with OMG CLI

Authorization
omg run authorization -a scope=<OPERATION_SCOPE> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Access Token
$ omg run accessToken -a authorizationCode=<AUTHORIZATION_CODE> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Refresh Token
$ omg run refreshToken -a token=<TOKEN_MAPPED_OBJECT> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Send Mail
$ omg run sendMail -a accessToken=<ACCESS_TOKEN> -a userId=<SENDER_EMAIL_ADDRESS> -a to=[LIST_OF_RECEIVER_EMAIL_ADDRESS] -a subject=<MAIL_SUBJECT> -a body=<MESSAGE_BODY> -a accessToken=<ACCESS_TOKEN> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Create Label
omg run createLabel -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -a name=<LABEL_NAME> -a backgroundColor=<Label_BACKGROUND_COLOR> -a textColor=<Label_TEXT_COLOR> -a labelListVisibility=<LABEL_LIST_VISIBILITY> -a messageListVisibility=<MESSAGE_LIST_VISIBILITY> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Delete Label:
omg run deleteLabel -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -a labelId=<LABEL_ID> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Patch Label:
omg run patchLabel -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -a labelId=<LABEL_ID> -a name=<LABEL_NAME> -a backgroundColor=<Label_BACKGROUND_COLOR> -a textColor=<Label_TEXT_COLOR> -a labelListVisibility=<LABEL_LIST_VISIBILITY> -a messageListVisibility=<MESSAGE_LIST_VISIBILITY> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
List Label
omg run labelList -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Create Filter
omg run createFilter -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -a addLabelId=<ADD_LABEL_ID> -a removeLabelId=<REMOVE_LABEL_ID> -a excludeChats=<EXCLUDE_CHATS> -a from=<SENDER_EMAIl_ADDRESS> -a to=<RECEIVER_EMAIL_ADDRESS> -a subject=<MAIL_SUBJECT> -a hasAttachment=<HAS_ATTACHMENT> -a negatedQuery=<NEGATED_QUERY> -a query=<QUERY> -a size=<SIZE_OF_MESSAGE> -a sizeComparison=<SIZE_COMPARISON> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Delete Filter
omg run deleteFilter -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -a filterId=<FILTER_ID> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
List Filter
omg run filterList -a accessToken=<ACCESS_TOKEN> -a userId=<EMAIL_ADDRESS> -e CREDENTIAL_JSON=<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>
Receive Mail
$ omg run subscribe receive mail -a userId=<EMAIL_ADDRESS> -a accessToken=<ACCESS_TOKEN> -e CREDENTIAL_JSON==<BASE64_DATA_OF_CREDENTIAL_JSON_FILE>

Note: the OMG CLI requires Docker to be installed.

License

MIT License.