Outlook calendar event id's are unique across tenant? - microsoft-graph-api

Am working with storing multiple tenants calendar events data on a single database. If calendar event-id are unique across tenant, I will use this as primary key to store unique events
Fetching data using Graph API events delta query
Thanks in advance..

My suggestion is that you'd better to use other key to be the primary key such as timestamp like 20210122125959333.
Upon your question, I googled for help, and based on this document, it seems that there will be 2 same event id. But based on this one, it seems that event ids are unique.
So I did some tests. I used creating event api to create calendar events, and I used the same parameters to test whether it will appear same id, and here is my conclusion.
First, if I used the sample parameter(my url is: https://graph.microsoft.com/v1.0/me/calendar/events) in this document, after executing the api for several times, it will always return similar reponse but the event ids are the same(you can see details in screenshoot), but when I querying events by api, I can only get one event.
Then I set "transactionId" as "" and change the subject of event in parameter json(because when I just change the value of subject, it will return an error describes that I can't use the same transactionId), after executing serveral times, I can get different event ids even using the same parameter.
So my suggestion is you shouldn't use event id as primary key unless your system doesn't care the operation metioned above which returning the same id and prepare to set up a good validation to avoid appearing same event id.

Related

Does every published Rails Event Store event have a timestamp?

Does every Rails Event Store event that's been published automatically get assigned a timestamp? I'm trying to build functionality that relies upon a timestamp automatically being present for events deserialized from the event_store within a job, but I don't know that I can rely on that. I'm hoping that one does not need to manually add a timestamp to the event's metadata in order for a timestamp to be present, since it doesn't appear that that's been done anywhere in the code base I'm working on. I'm aware that the docs indicate that the return value of the RubyEventStore::Event#timestamp method can be nil, but I'm hoping that it won't be nil for published events.
Unless you provide your own timestamp (the :timestamp key in metadata) each stored event will have metadata enriched with current time - see https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/client.rb#L311
It can be nil. But only if your clock provided to RailsEventStore client will return nil.
In upcoming Rails Event Store 2.0 release we will also add the validity time (valid_at attribute in metadata) that will allow to implement BI Temporal event sourcing. Stay tuned.

How to get calendar ID for an event when making Get Event call?

On creating a new event in a user's calendar, I receive a push notification that contains the id of the newly created event. In order to get more details about this event, I make the Get Event call:
https://learn.microsoft.com/en-us/graph/api/event-get?view=graph-rest-1.0
This returns all the event details for that particular event, but it does not seem to be returning the id of the calendar in which the event was created. I need it to attach this event to existing calendar in my local cache.
I have looked at the API spec but do not see calendar id field anywhere.
I would like to get an idea on how to get calendar id after making a get event call.
There is a relationship of Event resource with Calendar resource and Microsoft Graph lets you query relationships of one resource with another via expand parameter.
In case of Event resource its properties along with associated Calendar properties within a single query could be requested like this:
GET https://graph.microsoft.com/v1.0/me/events/{event-id}/?$expand=calendar
The response will contain among another properties the Id of Calendar
References
Use query parameters to customize responses

ASP.NET Model Id in ViewModel - is it safe?

Scenario:
(with an ASP.NET web app - Core or MVC)
I have a database with Users and Items for each user.
That means the UserId is a foreign key in the Items table.
From the browser I login as a User. I get my Items as a list of ItemViewModels, which are mapped (AutoMapper) to ItemViewModels via a simple api GET request.
I want to update one of the items (which should belong to me - the logged in user) via a simple API call. So I send the modified item back to the server via a PUT request as an ItemViewModel.
First approach:
The simplest approach would be to include the Item's database ID, ItemId, in the ItemViewModel - so when I receive the item to be updated as an ItemViewModel, I can map it back to the existing item in the database.
This however sounds pretty unsafe to me, as anyone could modify the PUT request with any ItemId and affect items which don't belong to the user who executed the request. Is there anything I'm missing about this approach?
Second approach:
Don't pass the database PK ItemId in the ItemViewModel.
Instead use an additional form of identification: let's say that user X has 10 items. And they are numbered from 1 to 10 using a property named UserItemId(which also exists in the database).
I can then pass this UserItemId in the ItemViewModel and when I get it back I can map it to an existing Item in the database (if all was ok with the request) or discard it and reject the request if the UserItemId didn't match anything from the logged in user's items.
Is anyone using this approach?
Pros:
The user only has access to it's own items and can't affect anyone else's since it doesn't know the actual Item ID (primary key), and any modifications are restricted to it's items.
Cons:
A great deal of extra management must be implemented on the server side for this approach to work.
Any other approaches ?
Please consider that the case mentioned above applies to all entities in the database which a client side implementation can CRUD, so it's not just the simple case described above.
The proposed solution should work for the entire app data.
I know this question has been asked here and here but the first one doesn't have a satisfying answer and I don't think the second one really applies to my situation, since it just deals with the UserId.
Thanks.
EDIT
Please consider the Item above as an aggregate root which contains multiple complex subItems each with a table in the db. And the question applies for them as much as for the main Item. That means that each subItem is passed as a ViewModel to the client.
I should mention that regarding further securing the update request:
For the first approach I can easily check if the user is allowed to change the item. But I should do this for all subItems too.
For the second approach I can check if the user can update the Item as follows: I get the userItemId of the incoming ViewModel -> I get all the logged in user's items from the database and try to find a match with the same userItemId, if I get a hit then I proceed with the update.
I think your application is not secure, if you only hide the Id.
You must check, before changing the database entity, if the user is allowed to change the entity.
In your case you should check, if your Id from the authenticated user is the UserId in your item.
If your ViewModel ist similar or identical for your API you could use a FilterAttribute in your controller.

Eventbrite event_search not reporting capacity

I'm using Eventbrite's event_search to display upcoming events, along with some idea of remaining tickets. The problem is, event_search is reporting capacity = 0 for all events.
When I use organizer_list_events I can see the correct capacities, but I'd rather not use that method as I don't want to display or have to filter past and 'draft' events.
Am I missing something? Is there another way to retrieve event capacity?
The V1 event_search method only retrieves publicly available date, of which capacity is not. Capacity is considered private data that is only accessible to the administrators of the event, which is why you can get that data with the organizer_list_events method.
Y0u could move up to the V3 method User Owned Events and pass in the 'status' parameter to 'live' in order to only get the upcoming events.

Name on Check in QuickBooks SDK

I have a customer requirement to export the checks written in QuickBooks into a specific format because their bank allows fraud prevention by uploading a file and they verify the name on the check against what you give them before clearing it.
I looked at the QuickBooks SDK (we use the XML to communicate in general) and It references a field on the check called PayeeEntityRef with a FullName property, but typically in QuickBooks that data structure would indicate what the entity is called, not what appears on the check (Vendors have a NameOnCheck property, for example, which can be something other than their name).
Without coding up multiple test cases to demonstrate QuickBooks behavior here, does anyone have experience with getting the name as it was printed on the check? What is the best way to do it?
It's somewhat possible to get what you are wanting, but there are going to be some hiccups that you'll need to let you client know about. The main problem being that there's no way to retrieve the actual name printed on the check.
You would first need to query for the Checks/Bill Payment - Checks for the bank account. Then, using the PayeeEntityRef (I would use the ListID component) figure out which "List" the entity is on; Customer, Vendor, Employee, or Other. I don't know of any way to tell which list the PayeeEntityRef is from other than doing a query for each of the lists.
If the PayeeEntityRef is a Vendor or Employee, then you can retrieve the NameOnCheck value. The only thing you would need to keep in mind is that if the NameOnCheck has been modified AFTER the check was printed, the names will not match.
If the PayeeEntityRef is a Customer or Other name, then you have to do a little bit more. The value that QuickBooks uses for the printed name is based on what fields are filled out for the customer record. It first will use the CompanyName field if it is not null. Next, it will try to use the First/Middle/LastName fields, if they are not null. Finally, it will use the Name field as a last resort. Keep in mind that this is not the FullName field, just the Name field.
I haven't tested this with an "Other" name, as I have my clients try not to use that list, but I would imagine it's similar to how Customers work.

Resources