Invitations on Trello API - json

What is the JSON structure for an invitation, and under what circumstances is one returned. For example,
GET /1/boards/5144051cbd0da6681200201e/invitations?key=[myKey]
always returns an empty array, even after I invite a fake email.

That route no longer returns anything (and should probably be marked deprecated).
Instead of invitation objects, we add a member to the board representing the invited person (where member.memberType = "ghost") so that you can interact with that person (mention in comments, add to cards) before they join Trello. If you invited that person, you will be able to see the 'ghost' member's email address.

Related

ContactsApp.getContact() for contact with multiple emails returns a different contact for each email address

My company allows employees to have multiple email addresses in their account.
I am attempting to write an input form where someone can enter any of the emails for a contact and we'll resolve it to the same person.
I've tried doing this via ContactsApp.getContact(email).getPrimaryEmail() to resolve all different inputs to the same primary email, but it doesn't work as expected. Each email I search for returns a different Contact object with only a single email (the one I used to search).
Even if I use ContactsApp.getContact(email).getEmails() to list all emails to the employee, I can see it only returns one at a time.
When going to contacts.google.com, I see the information I expected. Searching for any of the emails will return the same contact, with the same primary email and all other emails listed.
Is there something I'm doing wrong? Or is this how ContactsApp works. If so, is there a workaround?
Thanks!
getPrimaryEmail() will only return an email address if the contact in question has had a default email set and this can only be done via the Google Contacts App, not on the web (go figure).
To solve your problem I would suggest loading all the contacts into an array variable first and then searching this for matching email addresses. I would do the data retrieval on page/view load (so it can be reused without multiple server calls) but have included it all together here for conciseness.
What I found strange about the ContactsApp (and presumable People API too) is that the contacts returned are just empty objects (when logged) with just a bunch of methods on them. However, once you have an array of objects you can write your own properties to those objects for easier access of data.
Therefore I would first of all retrieve all the users contacts, then add a property of .emails to each contact object in the array and then use .some, perhaps, to check if a match appears in .emails (which will also be an array).
Something like:
let strSearch = 'someone#somewhere.net' // EMAIL address to search based on user input
let arrContacts = ContactsApp.getContacts();
let contacts = arrContacts.map(contact => {
let emails = contact.getEmails();
contact.emails = emails.map(email => email.getAddress());
return contact;
});
let foundContact = contacts.filter(contact => contact.emails.some(email => email === strSearch));
Remember .getEmails() returns another array of objects that have the method .getAddress() on them in order to retrieve the actual address, that's why I'm getting an array of email objects with let emails = contact.getEmails(); then using emails.map here to put the actual email addresses into an array stored in the contact.emails property (that doesn't exist so we're actually creating it here).
After that we're filtering the contacts array down to a contact where the searched email address is matched to one of the email addresses in the contact.emails array. I haven't tested it so the last line might need playing around with slightly but I've used something very similar so would expect it to work.
You can then use foundContact[0] to reference the contact found and use the further methods of .getFullname() .getId() etc. to retrieve their data as required. If you need the contacts phone numbers or geographical address that's a whole other process of returning an array of objects using .getPhones() or getAddresses(), but I think that's beyond the scope of this question.

EWS API: Anything I call update_item for a meeting, it ends up canceling the meeting for any attendees

I'm using the EWS API (targeting Exchange 2010) I cannot figure out why anything I make a request to update a calendar meeting/item. Is there something I'm missing or is this the expected behavior? I'm able to make a change from Outlook to the meeting without it sending out a cancellation email to all attendees except the organizer.
The below is a sample of the relevant portion of the SOAP request. I replaced the actual attendee's email addresses, item ID and change key.
{:send_meeting_invitations_or_cancellations=>"SendOnlyToChanged",:conflict_resolution=>"AutoResolve", :item_changes=>[{:updates=>[{:set_item_field=>{:field_uRI=>{:field_uRI=>"item:Subject"},
:calendar_item=>{:sub_elements=>[{:subject=>{:text=>"Thursday 11AM Recurring"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"item:Body"}, :calendar_item=>{:sub_elements=>[{:body=>{"BodyType"=>"HTML", :text=>"HI"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:Location"},:calendar_item=>{:sub_elements=>[{:location=>{:text=>"LA, CA"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:Start"}, :calendar_item=>{:sub_elements=>[{:start=>{:text=>"2019-03-07T19:00:00.0000000"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:StartTimeZone"}, :calendar_item=>{:sub_elements=>[{:start_time_zone=>{"Id"=>"UTC"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:End"}, :calendar_item=>{:sub_elements=>[{:end=>{:text=>"2019-03-07T19:30:00.0000000"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:EndTimeZone"},:calendar_item=>{:sub_elements=>[{:end_time_zone=>{"Id"=>"UTC"}}]}}},
{:set_item_field=>{:field_uRI=>{:field_uRI=>"calendar:RequiredAttendees"},:calendar_item=>{:sub_elements=>[{:required_attendees=>{:sub_elements=>[
{:mailbox=>{:name=>"Joe ABC",:email_address=>"joe#abc.com", :routing_Type=>"SMTP"}},
{:mailbox=>{:name=>"John ABC", :email_address=>"john#abc.com",:routing_Type=>"SMTP"}}]}}]}}}],
:item_id=>{:id=>"AAMkAGJjNWIzNzI2LTM1N2YtNDVkMi05NzU5LTRj",
:change_key=>"DwAAABYAAADWK9s0Y5iSSLP"}}]}
If you use Set_Item_Field to update the required attendees this will overwrite the current property so if any attendees aren't in the updated collection your effectively canceling the meeting for those attendees. If you want to use Set_Item_Field to update attendees then you need to include all the attendees for that type because your replacing the collection for the recipient type not appending to it.

MoonMail: Tracking clicks per email

I'm looking to extract a list of email addresses belonging to users who clicked a specific link in a MoonMail email campaign. Is this possible? The documentation only states there's an incrementClickCount function, but doesn't describe individual tracking or filtering.
The same happens with opens.
The function saveClicks stores the information about a link click in Clicks DynamoDB table. It contains campaignId, linkId and recipientId (which is the Base64 representation of the email)

Sort numbers by string

Hi I am using an API from Postcode Anywhere, the idea being to add a company by searching by postcode to select the address, this is pretty standard and the code works fine.
Just some background info, PAW works in two stages, 1 the post code search criteria is sent off to their services, which returns an array of possible addresses, you then select the address you want, and in stage 2, the full PAF file for that ID is returned and stored to the table.
The problem I am having is that the array they send includes an Address Field which includes house number and street address in one field, making it difficult to sort alphanumerically.
This is the sample data I have in my table:
and this is how it looks in my application:
As you can see it is not ideal and I have no control on how they send the data.
Does anyone have any ideas on how I can search a string based on numbers that can be 1, 11, 2, instead of 01, 02, 03, etc, or at the very least be able to split this into two rows. Also please note, that it most cases, the post code search will result business/property names as well as house numbers, as seen in this example.
Any thoughts would be greatly appreciated.
Have you considered using a different API provider for the data, Allies Computing (who I work for) have a single step API, where the initial postcode search returns all fields in the response. It also orders these results by premise number/name.
Give it a try here - https://developers.alliescomputing.com/postcoder-web-api/address-lookup/premise
There are also other providers of PAF data that do it this way such as Crafty Clicks and Ideal Postcodes.
It might also be worth checking the PAF license with your provider to ensure you comply with that too.

Appointment.Bind() and Mailbox

I retrieve an appointment by its unique ID. Now I want to find out which mailbox it is in.
I tried using appointment.Organizer, but this does not work for meetings, or for normal appointments - since appointments can be moved around between mailboxes, the Organizer can be different from the user that has the appointment in his calendar.
Is there a function to get a folder, given only an appointment and an ExchangeService?
If you want to get the SMTP address of the mailbox associated with a particular EWSId one way that should work is using convertId to convert the EWSId to a StoreId and just use generic mailbox address in the Mailbox field then the results you get back (if that ID is good) should contain the Mailbox its associated with eg
String EWSId = "AQMkADY4ZDQ4M2UyLTRhYjItNDhkYy1hMG...";
AlternateId aiRequest = new AlternateId();
aiRequest.UniqueId = EWSId;
aiRequest.Mailbox = "user#mailbox.com";
aiRequest.Format = IdFormat.EwsId;
AlternateId aiResultsStore = (AlternateId)service.ConvertId(aiRequest, IdFormat.StoreId);
Console.WriteLine(aiResultsStore.Mailbox);
Cheers
Glen