Google calendar API free slots - api

i am really new to the coding and would like to ask for some advice regarding calendar API.
I managed to created a list of the events and and show a busy time in the calendar, but i cant figure out how to show output of the free slots between the events.
# Call the Calendar API
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
print('Getting the upcoming 10 events')
events_result = service.events().list(calendarId='<email>', timeMin=now,
maxResults=10, singleEvents=True,
orderBy='startTime').execute()
events = events_result.get('items', [])
if not events:
print('No upcoming events found.')
for event in events:
start = event['start'].get('dateTime', event['start'].get('date'))
#print(start, event['summary'])"""
cst = timezone('UTC')
the_datetime_start = cst.localize(datetime.datetime(2020, 6, 10, 0))
print(the_datetime_start)
the_datetime_end = cst.localize(datetime.datetime(2020, 6, 10, 16))
print(the_datetime_end)
body = {
"timeMin": the_datetime_start.isoformat(),
"timeMax": the_datetime_end.isoformat(),
"timeZone": 'UK',
"items": [{"id": '<email>'}]
}
eventsResult = service.freebusy().query(body=body).execute()
print(eventsResult)

Hard to give you a code answer with your information, but if you want to show your free slots, you just have to:
Get all the tasks you have on your planning
Order it
Compare the first end date/hour task with the second start date/hour task
The différence between is your free slot, so you have your free slot
Do it again for the second task and the third task, and repeat for the other task

Related

How to implement Schedule local notifications of React native push notification in react native

I am using react-native-push-notifications npm library to implement notifications feature in my app. However, I want to schedule the notifications before 5 miniutes at specific time and I am using PushNotification.localNotificationSchedule so how to implement this pls help , thanks in Advance!
This code is scheduling a notification for 5 minutes before 4:00 PM, 21st January 2023.
import PushNotification from 'react-native-push-notifications'
const time = new Date(2023, 1, 21, 16, 0, 0)
const fiveMinutesBefore = new Date(time.getTime() - 5 * 60 * 1000)
PushNotification.localNotificationSchedule({
message: "Notification message",
date: fiveMinutesBefore,
repeatType: 'minute',
repeatTime: 5,
number: 1,
});

I want a way to send messages on WhatsApp using Twilio without using Sandox. Could you help me find a solution for it?

I am making an alert app for a very small company which does not have a Facebook Business Page nor a website which I could link to get the WhatsApp API. Could you please suggest me an alternative way through which I could make use of Twilio but avoid using sandbox. I have been making this project for around a year now and still not able to solve the issue successfully. Please help me solve this problem.
I am also including the code snippet below for reference.
import pandas as pd
from twilio.rest import Client
import datetime
from datetime import date, timedelta
values=variables
df=pd.DataFrame(values)
df.drop(index=df.index[0],
axis=0,
inplace=True)
df.index = df.index-1
df['AMC_Start_Date']=df['AMC_Start_Date'].apply(lambda x:x.replace('/','-'))
df['AMC_End_Date']=df['AMC_End_Date'].apply(lambda x:x.replace('/','-'))
d1=date.today()
d1=pd.to_datetime(d1)
d2=df['AMC_Start_Date']
d2=pd.to_datetime(d2)
df['AMC_Start_Date'] = pd.to_datetime(df["AMC_Start_Date"])
df['AMC_End_Date'] = pd.to_datetime(df["AMC_End_Date"])
d2=df['AMC_Start_Date']
d3=df['AMC_End_Date']
t=d1-d2
s=d1-d3
account_sid=‘’
auth_token = 'a7'
client = Client(account_sid, auth_token)
def alert2():
from datetime import date, timedelta
dt = date.today() - timedelta(856)
t2=df['AMC_Start_Date']
t2=pd.to_datetime(t2,format='%Y-%m-%d')
t3=df['AMC_End_Date']
t3=pd.to_datetime(t3,format='%Y-%m-%d')
dt1=date.today()-timedelta(989)
num=['whatsapp:+9198--------','whatsapp:+91900-------']
i1=[i for i, e in enumerate(df['AMC_Start_Date']) if e == dt]
i2=[i for i, e in enumerate(df['AMC_End_Date']) if e == dt1]
NULL=[]
for j in range(len(num)):
if i1!=NULL and i2!=NULL:
strings1 = [str(integer) for integer in i1]
a_string = "". join(strings1)
an_integer = int(a_string)
a=df['Name_and_Address'][an_integer]
strings2 = [str(integer) for integer in i2]
a_string2 = "". join(strings2)
an_integer2 = int(a_string2)
b=df['Name_and_Address'][an_integer2]
body='Servicing scheduled today for {}'.format(a)
message = client.messages.create( from_='whatsapp:+141--------', body=body, to=num[j])
body='The service ends after two days for {}'.format(b)
message = client.messages.create( from_='whatsapp:+141-------', body=body, to=num[j])
elif i1!=NULL:
strings1 = [str(integer) for integer in i1]
a_string = "". join(strings1)
an_integer = int(a_string)
a=df['Name_and_Address'][an_integer]
body='Servicing scheduled today for {}'.format(a)
message = client.messages.create( from_='whatsapp:+141-------', body=body, to=num[j])
elif i2!=NULL:
strings2 = [str(integer) for integer in i2]
a_string2 = "". join(strings2)
an_integer2 = int(a_string2)
b=df['Name_and_Address'][an_integer2]
body='The service ends after two days for {}'.format(b)
message = client.messages.create( from_='whatsapp:+141------', body=body, to=num[j])
else:
body='There are no tasks scheduled for today'
message = client.messages.create( from_='whatsapp:+141-------', body=body, to=num[j])
alert2()
Twilio developer evangelist here.
The only way to use the WhatsApp API in production with your own number and no sandbox limits is to follow the instructions in the documentation here. The instructions don't say that you need a Facebook Page or website. You do need:
a Facebook Business Manager account
to complete Facebook Business Verification
Once you have done those parts, you should start your application by filling in this form.
Without a Facebook Business Manager account, you cannot use the API. If you can't create one of those, then I do not know of a way that you can use the API.

HERE-API - how to create an app_id, app_code and api_key

I'm trying to replicate the examples from the fleet telematics examples at (https://tcs.ext.here.com/examples/v3.1/fleet_telematics_api) into my app, but the authentication need app_id and app_code, I have only an api_key.
I want to be able to create the truckOverlayProvider to show and hide the truck restrictions.
What do I need and how can I achieve that, is there any tutorial step by step for this subject?
Just create a Freemium account at https://developer.here.com/ and you will find there in your dashboard your AppID and api_key.
Check this post:
https://developer.here.com/blog/announcing-two-new-authentication-types
Update: I am sharing also a screenshot:
Looking at the code for the example that you shared, here's how they are making the call for truck overlay:
var truckOverlayProvider = new H.map.provider.ImageTileProvider({
label: "Tile Info Overlay",
descr: "",
min: 12,
max: 20,
getURL: function(col, row, level) {
server_rr++;
if (server_rr > 4) server_rr = 1;
return ["https://",
server_rr,
".base.maps.api.here.com/maptile/2.1/truckonlytile/newest/normal.day/",
level,
"/",
col,
"/",
row,
"/256/png8",
"?style=fleet",
"&app_code=",
app_code,
"&app_id=",
app_id
].join("");
}
});
var truckOverlayLayer = new H.map.layer.TileLayer(truckOverlayProvider);
map.addLayer(truckOverlayLayer);
Looking more closely at the call:
https://1.base.maps.ls.hereapi.com/maptile/2.1/info?xnlp=CL_JSMv3.1.22.0&apikey=API_KEY&output=json
Here's more resources on getting map tiles truck information overlay

expo notification how set start time

The challenge is: how can I set up the start date for notification in the new expo API. In the old API (which is depricated today) it was feasible but I can't see the solution in the new doc
For example: set up a notification on every 2nd day start from a user given date (e.g. 12th of Jan).
I went through on these types
export type SchedulableNotificationTriggerInput =
| DateTriggerInput
| TimeIntervalTriggerInput
| DailyTriggerInput
| WeeklyTriggerInput
| CalendarTriggerInput;
but no success so far.
As far as I can tell you should be able to set the start date this way:
const dateString = "21/01/2021"; // Jan 21
const trigger = new Date(dateString);
trigger.setMinutes(0);
trigger.setSeconds(0);
Notifications.scheduleNotificationAsync({
content: {
title: 'Happy new hour!',
},
trigger,
});
You should play around with trigger.setMinutes and trigger.setSeconds to set a specific hour on your specific day.

function with loop for urls won't return all of them

I am working on a project to pull details from state reports on restaurant inspections. Each inspection has its own url. I am able to gather the values into a dictionary, but only return one at a time. In the call to the function, if I don't specify a specific library entry, I get an error: ''list' object has no attribute 'timeout'' If it ask for a specific entry, I get a good return. How can I get them all?
# loop through the url list to gather inspection details
detailsLib = {}
def get_inspect_detail(urlList):
html = urlopen(urlList)
soup = bs4.BeautifulSoup(html.read(), 'lxml')
details = soup.find_all('font', {'face': 'verdana'})[10:]
result = []
for detail in details:
siteName = details[0].text
licNum = details[2].text
siteRank = details[4].text
detailsLib = {
'Restaurant': siteName,
'License': licNum,
'Rank': siteRank,
}
result.append(detailsLib)
return result
get_inspect_detail(urlList[21])
So I can get the 21st restaurant on the list, repeating 36 times, but not all of them.
Another question for another day is where to do the clean-up. The details will need some regex work but I'm unsure whether to do that inside the function (one at a time), or outside the function by calling all values from a specific key in the library.
Call get_inspect_detail() once per item in urlList, and save all the results.
all_results = []
for url in urlList:
details = get_inspect_detail(url)
all_results.extend(details)