MS graph "Multiple Customer" Bookings - Unable to retrieve customer information - api

How to retrieve multiple customer bookings customer data from MS Graph?
MS Graph is the API to access MS Bookings. I am attempting to retrieve customer information, which works for bookings with single customers. However you can have multiple customers.
API Documentation
Here are the api calls for a single customer, to access bookings.
1 Get User Token
https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token
2 Get List of Bookings for date period
https://graph.microsoft.com/beta/bookingBusinesses/{{BookingBusinessId}}/appointments
3 Get Booking with ID
https://graph.microsoft.com/beta/bookingBusinesses/{{BookingBusinessId}}/appointments/{{BookingId}}
The response object for a single customer booking, will include the following for customer information in the json object. However the multiple, will provide null. Pls Note, I have blanked out most values and represented this with a leading and ending "_".
Single customer booking
"id": "_bookid_",
"selfServiceAppointmentId": "_selfserviceappId_",
"additionalInformation": "",
"isLocationOnline": true,
"onlineMeetingUrl": "_teamsbookingid_",
"customerId": "_CustomerId_",
"customerName": "_customerName_",
"customerEmailAddress": "_email_",
"customerPhone": "_phone_",
"customerNotes": "_notes_",
Multiple customer booking
"id": "[bookid]",
"selfServiceAppointmentId": "[selfserviceappId]",
"additionalInformation": "",
"isLocationOnline": false,
"onlineMeetingUrl": null,
"customerId": null,
"customerName": null,
"customerEmailAddress": null,
"customerPhone": null,
"customerNotes": null,
The Calendar view delta object will instead of listing the customer details, will add the following note.
"NOTE: This is a Multi customer booking. Log into Bookings to see customer information and notes for this event."
Has anyone been able to solve multi customer bookings with MS Graph to retrieve customer data?

Related

Update list of dates in SQL

I have a controller to make a room which needs a JsonBody in order to add the room:
{
"roomName": "Sol",
"properties": "Geluidsdichte kamer",
"capacity": 40,
"buildingName": "16A",
"location": "Leuven",
"reservableDates": ["2022-12-03", "2022-12-04", "2022-12-05"],
"imageUrl":"www"
}
Here we find a reservableDates object which is just a list of dates when the room is available for reservation
Now the backend code to put this code into the database isn't relevant for my problem so I will not state this here.
However the output I get in my database is this...
select * from rooms inner join rooms_reservable_dates
on room_id = rooms_room_id;
Now I have another function in my backend so I can update a room (For example change its available reservable dates, but the problem is that I don't know how to write the query so I can change the reservable dates while also updating the roomName for example.
I'm using JpaRepository in SpringBoot so I have to make a custom query for this.
In Postgresql I have 2 tables Rooms (with all the properties found in the picture except for the reservable_dates) and the other table is rooms_reservable_dates (which has the roomId and the dates that the room is available.
Thank you very much

When and why are the attributes `propertyIds` and `categoryIds` in the product-response

I am doing a simple search on some products using the api-endpoint {{endpoint}}/api/search/product. What i sometimes see is that there are some products, where the attributes propertyIds and categoryIds are null, while there are sometimes products where these properties are not null.
However: All the examples have actual categories and properties assigned and are visible through other attributes.
My question is: What is the reason for this and how do this values get populated?
"minPurchase": 1,
"purchaseUnit": null,
"referenceUnit": null,
"shippingFree": false,
"purchasePrices": null,
"markAsTopseller": null,
"weight": null,
"width": null,
"height": null,
"length": null,
"releaseDate": null,
"ratingAverage": null,
"categoryTree": null,
"propertyIds": null,
"optionIds": null,
"streamIds": null,
"tagIds": null,
"categoryIds": null,
"childCount": null,
Example for one with Ids:
"b8a475de8b284e17b0ff4dba3729deff"
],
"propertyIds": [
"2c3257b006e240369ab32334096bca40",
"521eab63f64a47ae9f51801d57b4a0ae",
"6322d1a7de254bec8fe813d4dae43e97",
"8253d82499b44fdfbcea4f0238ba3258",
"a8c03127e8644749814ee6ca0f71cba7",
"b5b467f25ff3402ebbd4264b785153ec",
"d37c8640fd43427795365dae9cb750da"
],
"optionIds": null,
"streamIds": null,
"tagIds": null,
"categoryIds": [
"4c84f6cacaa7417fa18524d78156c9e4",
"b8a475de8b284e17b0ff4dba3729deff"
],
"childCount": 5,
"customFieldSetSelectionActive": null,
"sales": 0,
Both attributes propertyIds and categoryIds contain the IDs of assigned properties (such as color, size, material, etc.) and categories (a structural element used to group products in our navigation).
When one of those fields is null in a product, it simply means that no category or property is assigned to the product.
If you want to read the specific properties of categories of a product, the IDs are useless of course - but sometimes, you just need the ID to build a reference or a link.
If you want to see the actual properties and categories, you specify it in the request body as associations:
// POST /api/search/product
{
"associations": {
"properties": {},
"categories": {}
}
}
Another useful use case for *Ids fields are multi-assignments:
// POST /api/_action/sync
[{
"action": "upsert",
"entity": "product",
"payload": [{
"id": "0b3db9fe80af4d2bb81ecd649983a648",
"propertyIds": [
"13bc59c320a2400ea8d841da15f7b0f8", // Size: XL
"2fbb5fe2e29a4d70aa5854ce7ce3e20b", // Color: red
"0060b9b2b3804244bf8ba98cdad50234" // Material: cotton
]
}]
}]
Also see Bulk Imports
In Shopware there's the concept of indexing frequently read but rarely written data. This may for example be the count of variants for a product or, what you were wondering about, the IDs of associated entities. The indexed data is then updated whenever you update the entity, e.g. the product.
The idea is that unless you update the entity, that indexed data would never change and it is therefore safe to store it right with the entity in its table.
Let's say you then want to evaluate if a product has more than a certain count of variants, is part of a category or has certain properties. Then, instead of doing executing costly database queries to count rows or having a bunch of SQL joins to associated data, you can use these pre-indexed fields for your evaluation.
If you think that you're missing some data that should've been indexed, you can use the CLI command bin/console dal:refresh:index.

How to create the following data structure in an SQL environment

I have a FireStore database and I need to convert it to SQL. My SeminarsAndTraining document looks like this:
{
"st_name": "SOL Level 1",
"attendance": [
{"date": "01/29/2021", "present": ["9103", "1282"], "absent": ["8127"]},
{"date": "01/29/2021", "present": ["1203", "1224"], "absent": ["0927"]}
]
}
I have multiple of these SeminarsAndTraining documents inside a collection. The object inside the attendance array contains the date for the attendance and the students' id is stored in the present and absent array.
Problem 1
I know you can't have arrays in SQL, so what is the best approach to this?.
"attendance": [
{"date": "01/29/2021", "present": ["9103", "1282"], "absent": ["8127"]},
{"date": "01/29/2021", "present": ["1203", "1224"], "absent": ["0927"]}
]
In a relational database you'll typically have these tables
SeminarsAndTraining, which stores st_name
SeminarsAndTraining_attendance, which stores the date of each attendance, and the ID of the SeminarsAndTraining it belong to.
SeminarsAndTraining_attendance_present, which stores each ID from the present field, and the ID of the SeminarsAndTraining_attendance it belong too.
SeminarsAndTraining_attendance_absent, which stores each ID from the abssent field, and the ID of the SeminarsAndTraining_attendance it belong too.
You could probably merge the last two tables, and include a present_or_absent value for each.

Django get objects that are foreign key of two models

I have the following three models where Budget and Sale both contain a foreign key to Customer:
class Customer(models.Model):
name = models.CharField(max_length=45)
# ...
class Budget(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
# ...
class Sale(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
# ...
I want to get a queryset of all Customer objects for which both a Budget and Sale exists. I initially tried getting the intersection of the customer field of all Budget and Sale objects:
customers = {
budget.customer for budget in Budget.objects.all()
} & {
sale.customer for sale in Sale.objects.all()
}
This returns the correct objects, but becomes horribly inefficient as the size of my database grows.
How can I retrieve these objects in a more efficient way? Thanks for any help!
You can filter with:
Customer.objects.filter(
budget__isnull=False,
sale__isnull=False
).distinct()
Django can follow ForeignKeys in reverse. It uses the related_query_name=… parameter [Django-doc] for the name of relation. If that is not specified, it falls back on the related_name=… parameter [Django-doc] parameter, and if that is not specified, it will use the name of the model in lowercase, so budget and sale. We here make LEFT OUTER JOINs on the Budget and Sale table, and check if for both there is a non-null row. Likely the Django ORM will optimize this to INNER JOINs.

How to use the Shopify API to change the payment status of orders?

I'm building an iOS app for my own Shopify store. I created a private app and using the API key and password to call APIs with the format:
https://apikey:password#hostname/admin/resource.json
Problem occurs when I try to use the API to make the payment status change for orders. (I can create a new order without problem). I don't find any API for changing the financial status of an order. I cannot change the financial status by modifying an order or I even cannot make any transaction by API no matter the "kind" of transactions is: "authorisation", "capture" or "sale".
So how can I change the financial status of an order using the API?
Here is an example for the request and response of using the API:
Object Called:
/admin/orders/#{order_id}/transactions.json
request:
{
"transaction": {
"amount": 50,
"test":true,
"kind": "sale"
}
}
response:
{"errors":{"kind":["sale is not a valid transaction"]}}
Just a couple of things to try:
I noticed in the Transaction doco there are quotes around the amount, which you don't have in your code (e.g. try "50.00" instead of 50):
POST /admin/orders/#{id}/transactions.json
{
"transaction": {
"amount": "10.00",
"kind": "capture"
}
}
Also, have you seen this discussion on the Shopify forums?
...it seems to work so long as the amount of the transaction doesn't exceed the total outstanding balance of the order. From what I have gathered you can not charge or create a transaction for more than the initial sale amount of the order...
You cannot create a transaction or modify the financial_status of any order created via the Shopify API. Refer http://docs.shopify.com/api/order which explicitly says this.
So essentially, you need to pass the financial_status as 'paid' when creating the order and in case your payment was not successful from the gateway, DELETE the order. http://docs.shopify.com/api/order.html#destroy
I got some problem with changing the status of the order earlier , later i solved, to get rid of error you should take care of the following things.
Price of the order should be equal or less than the exact price of the order
Price < exact order price, order will be labeled as Partial Paid
Price = to the exact order price , order will be labbeled as Paid
Paid Price > exact order price , you will get error
Order with status paid, you will get error to change the status of
payment
POST /admin/orders/#{id}/transactions.json
{
"transaction": {
"amount": "10.00",
"kind": "capture"
}
}
$order_get = $shopify('GET', '/admin/orders/'.$order_id.'.json' );
$total_price = $order_get['total_price'];
if( $order_get['financial_status'] != 'paid' ){
$arguments = array( "order" => array(
'note' => 'Paid'
)
);
$order_put = $shopify('PUT', '/admin/orders/'.$order_id.'.json', $arguments);
$arg = array( "transaction" => array(
"amount" => $total_price,
"kind" => "capture"
)
);
$order_put = $shopify('POST', '/admin/orders/'.$order_id.'/transactions.json', $arg);
}
You're not able to write to the financial_status field to mark an order as paid. The financial_status is a result of the transactions that have taken place on an order. So if an order financial_status is currently authorized, you can mark the order as paid by capturing any funds still owing via our Transaction API - or by marking the order as paid within the admin.