Find all users within a thread of gmail API - google-api

I am using the gmail API to get recent hangouts messages/threads. But I can't find a way to view the recipient address. The only field in payload.headers is 'From'
code:
curl -H 'Authorization: Bearer **accessToken**' 'https://www.googleapis.com/gmail/v1/users/me/threads/**threadId**?q=is%3Achat'
response:
{
"id": "xxx",
"historyId": "1008967",
"messages": [{
"id": "xxx",
"threadId": "xxx",
"labelIds": [
"CHAT"
],
"snippet": "+Harry Howard",
"historyId": "1008953",
"internalDate": "1481641738948",
"payload": {
"partId": "",
"mimeType": "text/html",
"filename": "",
"headers": [{
"name": "From",
"value": "xxx"
}],
"body": {
"size": 13,
"data": "K0hhcnJ5IEhvd2FyZA=="
}
},
"sizeEstimate": 100
}]
}
In the case of emails, there is a 'To' field ( and sometimes cc etc).
FYI: I am using node-gmail-api npm module but just testing this with curl

Use Users.threads:list to find all users within a thread. See an example here.
HTTP request
GET https://www.googleapis.com/gmail/v1/users/userId/threads
This request requires authorization with at least one of the following scopes
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.metadata
Response
If successful, this method returns a response body with the following structure:
{
"threads": [
users.threads Resource
],
"nextPageToken": string,
"resultSizeEstimate": unsigned integer
}

Related

Cannot retreive virtual card number in test mode via stripe API using Go examples

Trying to follow the example here: https://stripe.com/docs/issuing/cards/virtual
When I add params.AddExpand("number"), no number is returned, yet via the dashboard I was able to see the card numbers. Here's sample code and redacted info for the Req and Resp.
func (ac *appContext) CardRetrieve(id string) *stripe.IssuingCard {
stripe.Key = ac.Config.Stripe.SecretKey
params := stripe.IssuingCardParams{}
params.AddExpand("number")
params.AddExpand("cvc")
ic_num, _ := card.Get(id, &params)
return ic_num
}
Returns:
{
"id": "ic_redacted",
"object": "issuing.card",
"brand": "Visa",
"cancellation_reason": null,
"cardholder": {
"id": "ich_redacted",
"object": "issuing.cardholder",
"billing": {
"address": {
"city": "A Beach",
"country": "US",
"line1": "404 Main St.",
"line2": "Suite #302",
"postal_code": "19001",
"state": "DE"
}
},
"company": null,
"created": 1613338532,
"email": "redacted#notreal.com",
"individual": {
"dob": {
"day": 20,
"month": 10,
"year": 1990
},
"first_name": "User",
"last_name": "Testing",
"verification": {
"document": {
"back": null,
"front": null
}
}
},
"livemode": false,
"metadata": {
},
"name": "User Testing",
"phone_number": "+15165551212",
"requirements": {
"disabled_reason": "under_review",
"past_due": [
]
},
"spending_controls": {
"allowed_categories": [
],
"blocked_categories": [
],
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "active",
"type": "individual"
},
"created": 1613338532,
"currency": "usd",
"exp_month": 1,
"exp_year": 2024,
"last4": "0088",
"livemode": false,
"metadata": {
},
"replaced_by": null,
"replacement_for": null,
"replacement_reason": null,
"shipping": null,
"spending_controls": {
"allowed_categories": null,
"blocked_categories": null,
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "inactive",
"type": "virtual"
}
What confuses me is the documentation found here:
https://stripe.com/docs/issuing/cards/virtual
It says: You can retrieve both the full unredacted card number and CVC from the API. For security reasons, these fields are only available for virtual cards and will be omitted unless you explicitly request them with the expand property. Additionally, they are only available through the Retrieve a card endpoint. That links to the issue card retrieval end point, but the params defined in the virtual cards example references the CardParams{} struct.
No of the examples show what imported module their aliasing for card to exec card.Get, but it stands to reason given the flow of the documentation that this should be IssuingCardParams{} and that the card alias is referencing: "github.com/stripe/stripe-go/issuing/card"
I also find it strange that we're defining params in the example but not passing it into the card.Get()
Edit:
I went digging through the module and it seems like to get the card details you have to call: details, _ := card.Details(id, params) but I get a 404 when trying to call that. The object returned is actually the right object and I see number and cvc, albeit nil.
I get the following error:
2021/02/15 00:33:06 Request error from Stripe (status 404): {"status":404,"message":"Unrecognized request URL (GET: /v1/issuing/cards/ic_redacted/details). Please see https://stripe.com/docs
So it seems you need to include a /v72 in the import:
"github.com/stripe/stripe-go/v72"
The documentation should be updated to show this and the virtual card example for go should also be updated.

How to use Gmail API without raw attribute in JSON

I'm try to send email using google gmail API. I've used Request body JSON with bearer token and Content-Type - message/rfc822.
Then I've used link below to send post request but I received the following errors.how to fix this issue ???
Post request Link -
https://www.googleapis.com/upload/gmail/v1/users/kasunysoft#gmail.com/messages/send
Request Body
{
"threadId": "Hi kasunjith",
"payload": {
"mimeType": "message/rfc822",
"headers": [
{
"name": "To",
"value": "hvn#gmail.com"
},
{
"name": "From",
"value":"kasunysoft#gmail.com"
},
{
"name":"Subject",
"value":"Subject Text"
}
]
}
}
I got response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Recipient address required"
}
],
"code": 400,
"message": "Recipient address required"
}
}
This means that your format in sending email is not valid. Check the documentation for Users.messages and Users.messages: send for the proper format.
{
"id": string,
"threadId": string,
"labelIds": [
string
],
"snippet": string,
"historyId": unsigned long,
"internalDate": long,
"payload": {
"partId": string,
"mimeType": string,
"filename": string,
"headers": [
{
"name": string,
"value": string
}
],
"body": users.messages.attachments Resource,
"parts": [
(MessagePart)
]
},
"sizeEstimate": integer,
"raw": bytes
}
You can also check out the following SO post for more in depth discussion about you error.
400 error. Recipient address required. JavaScript
How to send a message successfully using the new Gmail REST API?

How to add JSON array to elasticsearch using Postman

I have tried to add sample data set using postman as following way,
POST URL: http://localhost:9200/allData
Add to postman body as json
{
"index": "allData",
"type": "all",
"id": 1006,
"body": {
"id": 1006,
"url": "https://en.wikiversity.org/wiki/Principles_of_Management",
"title": "Principles of Management",
"author": "",
"rate": 0,
"ratedBy": 0,
"datePublished": "2018-01-01T00:00:00",
"publishedDate": "2018-01-01"
}
}
But it is given following error.
No handler found for uri [/] and method [POST]
Someone please help me to solve this issue. Thanks
There are certain issues with your request:
Elasticsearch index names cannot have uppercase so in your case it should be alldata not allData.
The format of the URL is wrong.
Your URL should be in the below format:
http://localhost:9200/{indexname}/{type}/{id}
which in your case must be:
http://localhost:9200/alldata/all/1006
So you should perform a POST request to the above url with the body as:
{
"id": 1006,
"url": "https://en.wikiversity.org/wiki/Principles_of_Management",
"title": "Principles of Management",
"author": "",
"rate": 0,
"ratedBy": 0,
"datePublished": "2018-01-01T00:00:00",
"publishedDate": "2018-01-01"
}
Have a look at the Elasticsearch Reference Guide.
Hope it helps !

What is the Json response we should send to microsoft botFramework to route my response to telegram channel

I am sending below response to the service url provided by botFramework request https://telegram.botframework.com/v3/conversations/-263387177/activities/
My intent is that using sendMessage method of telegram I am able to route a text to the telegram channel via microsoft botframework
The http post which I am sending is as below
{
"type": "message",
"locale": "en-Us",
"chat_id":-263387177,
"channelID":"telegram",
"from": {
"id": "GTSFIBot",
"name": "sapeops"
},
"text":"hi , Greetings!",
"replyToId": "1505813737353",
"recipient": {
"id": "DirectLineClient"
},
"conversation": {
"isGroup": true,
"id": "-263387177",
"name": "sapeops group"
},
"channelData": {
"method": "sendMessage",
"parameters": {
"chat_id": -263387177,
"parse_mode": "HTML",
"text": "<B>Greetings! How are you doing?</B>"
},
"chat": {
"id": -263387177,
"title": "sapeops group",
"type": "group",
"all_members_are_administrators": true
}
}
}
I get 502 bad gateway response and a below JSON.
{
"error": {
"code": "ServiceError",
"message": "Telegram API returned a result code indicating non-success"
}
}

how to fetch reviews and comments posted for app inside chrome web store?

here is the sample header field.
Request URL:https://chrome.google.com/reviews/components
Request payload:
req={
"appId": 94,
"version": "121024",
"reqId": "1363687747823-0.8877600133419037",
"hl": "en",
"specs": [
{
"type": "CommentThread",
"url": "http%3A%2F%2Fchrome.google.com%2Fwebstore%2Fpermalink%3Fid%3Danekiipncldokmaojfkbfecgfjjjekoc",
"groups": "chrome_webstore",
"sortby": "date",
"startindex": "0",
"numresults": "25",
"id": "1616"
}
],
"internedKeys": [],
"internedValues": []
}
response is json file which contain review.
how to make automated system which get appID and featch review related to that app.

Resources