Google Rest api to get primary mail [closed] - api

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to get the gmail primary mail using Google rest API.Currently i am using the GET https://www.googleapis.com/gmail/v1/users/userId/messages Rest API but that will give the social and promotion mail.I am referring this site:https://developers.google.com/gmail/api/v1/reference/users/messages/list

Try adding this as a filter in your query when calling messages.list
[ in:inbox -category:{social promotions updates forums} ]
that only gives you the good stuff. It's basically saying give me everything in the inbox apart from social, promotions, updates and forums.
Or in my inbox I also seem to have updates so you'd change to
[ in:inbox -category:{social promotions forums} ]
Cheers
John

Its pretty straight forward actually
We can query the messages by using labels. Labels are of two types System labels and User Labels.
For primary we can use System label called "INBOX" and get the emails that belong to that category. There are other system labels like CATEGORY_PROMOTIONS, CATEGORY_SOCIAL etc.
You can use the Try It! feature with Google to test it out.
Get labels:
https://developers.google.com/gmail/api/v1/reference/users/labels/list
For a given label, say INBOX in your case query the messages
https://developers.google.com/gmail/api/v1/reference/users/messages/list
You can also get the STARRED, CATEGORY_PERSONAL for starred and important emails from the inbox.
Edited for sample code.
Java Code Sample available within the link, but a snippet here:
public static void listLabels(Gmail service, String userId) throws IOException {
ListLabelsResponse response = service.users().labels().list(userId).execute();
List<Label> labels = response.getLabels();
for (Label label : labels) {
System.out.println(label.toPrettyString());
}
}

Related

How to create history data in pinia [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
I am using pinia in my project and I have two array states. Now I need to have the history of the entered data in these states.
For example: every time I push an object to array in state or change the data in an array, I want to be able to push the data of that array in an array in store.
The problem is that by pushing current data of the state in an array in another store, in in all indexes of the new areay, the new value of the first state will be replaced and I can't have the history of changes
The point is that in the first store, pinia's default settings must be available so I can use the features, but in the second store I need the data to be unchanging and only added to array.
Let me also add that for the second store there is no need for using pinia and I would be glad if you could suggest something else. (But whatever feature I use, by changing the state in the first store, my data changes)
Maybe VueUse is the correct pick here.
Have you tried using (heh) useRefHistory? That does exactly what you need: a history of your reactive values.
Recall that you can use storeToRefs to get this done.
Store values need to be watched and accumulated, e.g. with watch:
watch(
() => store.myData,
(data, oldData) => {
if (!isEqualDeep(data, oldData)
store.myDataHistory.push(cloneDeep(data)) // should preferably be inside an action
},
{ deep: true }
);

I'm tiring to create a new user in Moodle using auth_email_signup_user but I'm not sure how to format the request [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a few required custom profile fields that are date pickers and checkboxes. and I'm not sure what type to put them as in the request the only example the documentation has is one with type string. I keep getting the response
{
"exception": "invalid_parameter_exception",
"errorcode": "invalidparameter",
"message": "Invalid parameter value detected",
"debuginfo": ""
}
this is my request below:
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=fromapp&password=FakePass123&firstname=From&lastname=App&email=fake#mailinator.com&customprofilefields[0][type]=text&customprofilefields[0][name]=profile_field_Church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=date&customprofilefields[1][name]=profile_field_DOB&customprofilefields[1][value]=2014-06-19&customprofilefields[2][type]=checkbox&customprofilefields[2][name]=profile_field_Saved&customprofilefields[2][value]=1&customprofilefields[3][type]=text&customprofilefields[3][name]=profile_field_Sex&customprofilefields[3][value]=Male&customprofilefields[4][type]=text&customprofilefields[4][name]=profile_field_phone_no&customprofilefields[4][value]=1-868-479-8661&customprofilefields[5][type]=text&customprofilefields[5][name]=profile_field_Marital&customprofilefields[5][value]=Single
I'm not sure what I need to do to make this request work and the documentation doesn't give much insight or I just haven't found it
So after playing around with the request on postman what I discovered is that the only type you need to use is string. I also discovered that for date fields the value must be unixtime and for checkboxes the value must be either 0 or 1.
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=formapp7&password=fakepassword&firstname=From7&lastname=App7&email=fake#mailinator.com&customprofilefields[0][type]=string&customprofilefields[0][name]=profile_field_church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=string&customprofilefields[1][name]=profile_field_saved&customprofilefields[1][value]=Yes&customprofilefields[2][type]=string&customprofilefields[2][name]=profile_field_man&customprofilefields[2][value]=0&customprofilefields[3][type]=string&customprofilefields[3][name]=profile_field_born&customprofilefields[3][value]=1630813061&customprofilefields[4][type]=string&customprofilefields[4][name]=profile_field_single&customprofilefields[4][value]=Single&customprofilefields[5][type]=string&customprofilefields[5][name]=profile_field_aboutyou&customprofilefields[5][value]=Well i am new
This is an example of how a request would look where profile_field_man is a checkbox and profile_field_born is a date field. something also worth noting is that 'born' is the short name of the profile field mentioned before and the words 'profile_field_' must be prepended to it. I hope this helps anyone trying to use auth_email_signup_user

How do I associate a file with a key on google drive?

I'm trying to automate a process at my company where I have to send files to my customers every month.
These files are unique and each customer must receive their own. In addition, I wanted the client to be required to answer an NPS assessment form in order to have access to his file.
Honestly, I don't understand much about programming and I'm just trying to find a solution to do this automatically.
The solution I have in mind today is to use a google forms form and after filling out the form a link would be made available to access a google drive folder (that way the customer would be obliged to answer the form to have access to his file).
In the google drive, each file would be associated with a unique access key (for example, an identification number of that customer, in which he already knows what it is).
Then these customers should insert this key in the google drive folder in order to be able to access their file. That way I would be able to: get all the answers of the evaluation in a single form, make a standard message (or tutorial) available to all customers informing them how to access their file, and give access to the files automatically because the access key would be the same every month.
Sorry for the long text but I tried to describe my problem in the best way. I am accepting any kind of help or guidance. Even where I could get help about it. This automation would be very important to me because in addition to automating a process that costs a lot of time it would give me a very powerful tool to evaluate my services. Thanks in advance to everyone who took the time to read this question.
The best approach in this situation is to start by using Apps Script.
Apps Script is a powerful development platform which can be used to build web apps and specifically for your situation, automate tasks. What makes it special is the fact that it is easy to use and to create applications that integrate with G Suite.
Since you mention that the files are unique for each customer, what you can do is to store these values in a key - value list. However, depending on the number of the customers, you can store these value in a spreadsheet, something similar to this:
Making the files available only after submitting the Google Form mentioned can be done by taking advantage of Apps Script's triggers.
So essentially, you can use an onFormSubmit trigger which will execute every time the above mentioned form is submitted.
Code
You can also add another column in your spreadsheet to mark if the email was sent or not; taking this into account, this is how your spreadsheet will look like:
As for the code, this is just a short snippet which does the following:
opens the spreadsheet and retrieves the values for the File ID, Customer Email and Sent columns as the following arrays ids, emails and sent respectively;
retrieves the needed form and loops through the responses and checks if the last email of the form matches any of the ones from the spreadsheet;
if the conditions check, the file permissions are edited, an email is being sent, and the corresponding row on column C is being set to TRUE;
function editPermissions() {
let form = FormApp.openById('FORM_ID');
let sheet = SpreadsheetApp.openById('SPREADSHEET_ID').getSheetByName('SHEET_NAME');
let responses = form.getResponses();
let emails = sheet.getRange('EMAILS_RANGE').getValues();
let ids = sheet.getRange('IDS_RANGE').getValues();
let sent = sheet.getRange('SENT_RANGE').getValues();
for (let i = responses.length; i > 0; i--) {
let email = responses[i].getRespondentEmail();
for (let j = 0; j < emails.length; j++) {
if (emails[j][0] == email && sent[j][0] == false) {
// edit file permissions
// send email
// mark the associated row on the Sent col with TRUE
}
}
}
}
Trigger
As for making the function above run every time there's a new form submission, you will have to create an onFormSubmit trigger which will trigger the execution of the function.
Reference
Apps Script;
Apps Script Spreadsheet Service;
Apps Script Forms Service;
Apps Script Installable Triggers.

selenium webdriver word count from page source [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
how to get edit id count
i have tried as belowpagesource code
string[] rowcount=driver.getPageSource().split("a
The ideal method is the one suggested by Buaban, you should ideally use findElements for such purposes using the element attributes:
int rowcount = driver.findElements(By.xpath("\\a[contains(#id,'edit')]")).size();
But if still you want to go via getPageSource(), it's going to be a bit tricky. Since, you would be getting a string now without much distinction between elements and their attributes. You'll have to use some core java concepts here:
String str = driver.getPageSource();
String findStr = "id=\"edit";
int rowcount = str.split(findStr, -1).length-1;
Hope, it helps.
You can find the elements that id contains 'edit' then count the results. See code below:
int rowcount = driver.findElements(By.cssSelector("[id*='edit']")).size();

How to get Entire Product Category hierarchy of an ebay site? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
There is an existing stackoverflow question which answers this question but the call isn't working anymore.
I tried adding http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=YOUR-APP-ID&siteid=3&CategoryID=-1&version=729&IncludeSelector=ChildCategories&DetailLevel=ReturnAll
But it didn't help.
It is still possible to return the entire hierarchy in one call?
To the call but that didn't help.
this is what works for me. I am able to get all categories with this URL:
var url = "http://open.api.ebay.com/Shopping";
url += "?callname=GetCategoryInfo";
url += "&appid=YourAppId"; //replace with your appID
url += "&siteid=0"; //3 = UK | 0 = US
url += "&callbackname=cb_listCategories"; //callback function
url += "&CategoryID=-1";
url += "&version=729";
url += "&IncludeSelector=ChildCategories";
url += "&responseencoding=JSON"; //or XML for example
After that, it's just a matter of listing the categories on your html by creating a callback function, called "cb_listCategories" in my example.
Please let met know if I can help any further. Take care.