MS Graph and PHP : Add location that is recognized in Outlook - php

we are using the following code in order to add a room (Resource) to the location in Outlook calendar event:
$response = [
'Subject' => $subject,
'Body' => [
'ContentType' => 'HTML',
'Content' => 'This is event generated by Clebex!'
],
'Start' => [
'DateTime' => $declaration->datetime_from,
'TimeZone' => 'UTC'
],
'End' => [
'DateTime' => $declaration->datetime_to,
'TimeZone' => 'UTC'
],
'Attendees' => $attendees,
'Location' => [
[
'displayName' => 'Room 1',
'emailAddress' => 'room1#example.com',
'locationIdentifier' => [
'id' => $organizer,
'type' => 'room'
],
]
],
'isOnlineMeeting' => true,
'onlineMeetingProvider' => $meetingProvider
];
Outlook calendar event is created successfully, but location resource is not recognize as such by Outlook. Instead of that in the location field there is only a string 'Room 1'.
Is there a way to 'force' Outlook to read the information from the location and recognize it as the resource?
Many thanks!

So, after doing more research: solution is to add the room as attendee, with type 'resource' instead of 'required'.
After this, room is placed in Location field and is recognized as the resource in Outlook.

Related

Google Calendar API - Create Events to Send Updates

I am trying to add a few 'flags' to my Google Calendar Event. I am using the PHP API. Most specifically I am trying to set the ['sendUpdates'=>'all'] flag, so that whenever the event is modified, all those on the attendees list will get notified. I have tried to add this parameter upon inserting/creating the event. I have also tried using patch. But it does not seem to be working.
Here is some sample code:
$opts = [
'start' => [
'date' => '2021-10-11',
'timeZone' => 'US/Pacific'
],
'end' => [
'date' => '2021-10-11',
'timeZone' => 'US/Pacific'
],
'summary' => 'TEST EVENT',
'description' => 'Test description',
'attendees' => [['email'=>'test#test.com']],
'guestsCanModify' => false,
'guestsCanInviteOthers' => true,
'guestsCanSeeOtherGuests' => true,
'reminders' => [
'useDefault' => true,
],
'sendUpdates' => 'all',
];
$event = new \Google_Service_Calendar_Event($opts);
$new_event = $service->events->insert($calendar_id, $event);
Then after this didn't work, I just tried to 'patch' the event with the following:
$service->events->patch($calendar_id, $new_event['id'], $new_event, ['sendUpdates'=>'all']);
None of this is working to properly set the 'sendUpdates' flag. It DOES create the event. Pretty much ran out of options on how to fix this. Documentation is pretty unclear about how to do this, and can't find much on Stack Overflow or anywhere else.
Anyone have any suggestions?
You are very close to setting the sendUpdates parameter to all. Beforehand you have to keep in mind that sendUpdates is a parameter, not a property. Therefore you should set it in the method, not in the request body. So you only have to modify the script to look like this:
$opts = [
'start' => [
'date' => '2021-10-11',
'timeZone' => 'US/Pacific'
],
'end' => [
'date' => '2021-10-11',
'timeZone' => 'US/Pacific'
],
'summary' => 'TEST EVENT',
'description' => 'Test description',
'attendees' => [['email'=>'test#test.com']],
'guestsCanModify' => false,
'guestsCanInviteOthers' => true,
'guestsCanSeeOtherGuests' => true,
'reminders' => [
'useDefault' => true,
],
];
$optionalParameters = array(
"sendUpdates" => "all"
);
$event = new \Google_Service_Calendar_Event($opts);
$new_event = $service->events->insert($calendar_id, $event, $optionalParameters);

Laravel: Edit value only if it appears in the request?

in my app the user can update the info of stripe connected account, however I ONLY want to actullay update the value of the fields that appear in the request payload, I could do this with a simple if check but the way I update the stripe array method makes this issue more complicated .
Is there any syntax sugar or trick to make this easier.
How my update method looks;
public function editConnectedAccount(Request $request)
{
$account = Account::retrieve($request->connectedAccountId);
Account::update(
$request->connectedAccountId,
[
'type' => 'custom',
'country' => 'ES',
'email' => $request->userEmail,
'business_type' => 'individual',
'tos_acceptance' => [ 'date' => Carbon::now()->timestamp, 'ip' => '83.46.154.71' ],
'individual' =>
[
'dob' => [ 'day' => $request->userDOBday, 'month' => $request->userDOBmonth, 'year' => $request->userDOByear ],
'first_name' => $request->userName,
'email' => $request->userEmail,
'phone' => $request->userPhone,
'last_name' => $request->userSurname,
//'ssn_last_4' => 7871,
'address' => [ 'city' => $request->userBusinessCity, 'line1' => $request->userBusinessAddress, 'postal_code' => $request->userBusinessZipCode, 'state' => $request->userBusinessCity ]
],
'business_profile' =>
[
'mcc' => 5812, //got it
'description' => '',
//'url' => 'https://www.youtube.com/?hl=es&gl=ES', //got it
],
'capabilities' => [
'card_payments' => ['requested' => true],
'transfers' => ['requested' => true],
],
]
);
return response()->json([
'account' => $account,
], 200);
Consider using a Form Request where you preform validation. This will neaten up your controller for a start and also make validation (never trust user input!) reusable.
Assuming validation is successful, calling $request->validated() from inside your controller method will return only the fields present and validated. You can then use either fill($request->validated()) or update($request->validated()).

How can I send custom payload paramter with the NotificationPusher component to apple devices?

I am struggling with the usage of the NotificationPusher component and the possibility to send custom parameters within the payload to apple products.
I've tried the following, since I've found this annotation within the docs on github.
$message = new Message("Hello there", [
'message' => [
'sound' => 'default'
],
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]);
This syntax sadly didn't led to the expected result. The apple devices wouldn't receive these parameters.
I've also tried this, but this also failed.
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom_lat' => 123,
'custom_lon' => 321,
'custom_radius' => 32,
'custom_date' => date('Y-m-d H:i:s'),
'custom_action' => 'update'
]
]);
What is the exact syntax so send custom parameters within the payload to apple devices with a push message?
I've dug trough the source code on github and have found out, that the 'custom' key of the array wasn't extracted by the ASPN Adapter.
But I've found a piece of code that extracted the complete 'message' array, so my guess was to add the 'custom' array within the 'message' part, what then also was the solution for my problem.
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]
]);
I faced the same need. Started debugging and found that KhorneHoly is right: You need to send the payload under custom key. The array format is a little bit different, though:
$message = new Message('This is the message', [
'custom'=> [
'payloadKey' => 'payloadContent'
]
]);
I'm using "sly/notification-pusher": "^2.3"
Hope it helps =)

Converting text to local language - laravel 5.6

I am implementing text to speech calls with laravel and Nexmo. In the application, i am able to place calls to my clients with `English language' as below. The text placed to my customers is
To add a reply, please leave a message after the beep, then press the pound key
Is there a way to convert the text from english to my native language ? So the call will be in the language i converted to ?
Please help? Beginner with this
$currentHost = 'http://abc123.ngrok.io';
Nexmo::calls()->create([
'to' => [[
'type' => 'phone',
'number' => $cc->user->phone_number
]],
'from' => [
'type' => 'phone',
'number' => config('services.nexmo.sms_from')
],
'answer_url' => [$currentHost.'/webhook/answer/'.$entry->id],
'event_url' => [$currentHost.'/webhook/event']
]);
return response()->json([
[
'action' => 'talk',
'text' => $ticket->content
],
[
'action' => 'talk',
'text' => 'To add a reply, please leave a message after the beep, then press the pound key',
'voiceName' => 'Brian'
],
[
'action' => 'record',
'endOnKey' => '#',
'beepStart' => true
]
]);

TYPO3 how to add virtual column to the TCA?

how can I add an virtual column to the TCA (TYPO3 8)? I have in a 1:n table with data and I want to display the count of the data in the backend to current element.
I need something like this:
$fields = [
'counts7d' => [
'exclude' => false,
'label' => 'last 7 days',
'config' => [
'type' => 'none',
'procFunc' => '\Namespace\MyClass->MyMethod',
'readOnly' => true,
'params' => [
'period => '7d'
]
]
],
'counts30d' => [
'exclude' => false,
'label' => 'last 30 days',
'config' => [
'type' => 'none',
'procFunc' => '\Namespace\MyClass->MyMethod',
'readOnly' => true,
'params' => [
'period => '30d'
]
]
],
];
pseudo function:
public function myMethod($element, $params){
$sql = "SELECT count(*) FROM TABLE WHERE pid=$element[uid] and date > $params[period]";
return sql_count…
}
The field should only be informative for the backend users.
Does anyone have an idea?
Thanks
Oliver
The TCA field type user is exactly what you are looking for:
'counts7d' => [
'exclude' => false,
'label' => 'last 7 days',
'config' => [
'type' => 'user',
'userFunc' => \Namespace\MyClass::class . '->MyMethod',
'parameters' => [
'period => '7d',
],
],
],
The TCA field type none is exactly what you are looking for. Type none is the only type that does not necessarily need a database field. To manipulate it you can use userFunc which allow you to use custom php function.

Categories