Google Calendar API Recurrent Event, EXDate not working - python

I want to create a recurrent event into Google Calendar with one day exclusive. I used Google Calendar APi explorer.
Below is the Request Data
{
"end": {
"dateTime": "2020-02-24T19:00:00+05:00",
"timeZone": "Asia/Karachi"
},
"start": {
"dateTime": "2020-02-24T18:30:00+05:00",
"timeZone": "Asia/Karachi"
},
"description": "PSL live Streaming ..",
"summary": "PSL live Streaming ..",
"location": "National Stadium Karachi",
"recurrence": [
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU",
"EXDATE;VALUE=DATE:20200225"
],
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "email",
"minutes": 15
},
{
"method": "popup",
"minutes": 15
}
]
}
I got response
{
"kind": "calendar#event",
"status": "confirmed",
"summary": "PSL live Streaming ..",
"description": "PSL live Streaming ..",
"location": "National Stadium Karachi",
"start": {
"dateTime": "2020-02-24T18:30:00+05:00",
"timeZone": "Asia/Karachi"
},
"end": {
"dateTime": "2020-02-24T19:00:00+05:00",
"timeZone": "Asia/Karachi"
},
"recurrence": [
"EXDATE;VALUE=DATE:20200225",
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU"
],
"sequence": 0,
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "email",
"minutes": 15
},
{
"method": "popup",
"minutes": 15
}
]
}
}
This event should not be created on 25th, but when i go to google calendar is see event is also created on 25h.
Any hint, what's been wrong here?

You provided a dateTime in start and end, and a date in EXDATE.
Since you provided a dateTime for start and end, you should also provide a dateTime in EXDATE, and the time part should match the one you provided in start. Otherwise, the API won't know what event to exclude.
That is to say, the recurrence should be like this:
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU",
"EXDATE;TZID=Asia/Karachi:20200225T183000"
Reference:
RFC5545

Related

Sharepoint Calendar get todays meetings (also recurrent ones) using python

My main goal is to get all today meetings in a sharepoint site (using python)
What i already do:
Filter meetings properly and get the specific fields
?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType, Duration,TimeZone)
Request all meetings with all needed info, inclusive RecurrenceData (XLM)
There is the HTTP request and a response sample (some items and info as been removed):
REQUEST:
https://graph.microsoft.com/v1.0/sites/[SITE]/sites/[SITE]/lists/[ID]/items?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,Eventype, Duration,TimeZone)
RESPONSE:
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))",
"value": [
{
"#odata.etag": "[TAG]",
"createdDateTime": "2019-09-09T17:42:40Z",
"eTag": "[TAG]",
"id": "2065",
"lastModifiedDateTime": "2019-09-10T08:51:34Z",
"webUrl": "https://[BUISNESS COMPANY].sharepoint.com/teams/[THINGS]/[THINGS]/Lists/[ROOM NAME]/2022_.000",
"createdBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"lastModifiedBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"parentReference": {
"id": "[ID]",
"siteId": "[BUISNESS COMPANY].sharepoint.com,[UID],[UID]"
},
"contentType": {
"id": "[THINGS]",
"name": "Event"
},
"https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))/$entity",
"fields": {
"#odata.etag": "[TAG]",
"Title": "TITLE",
"EventDate": "2019-12-10T10:00:00Z",
"EndDate": "2169-09-12T10:00:00Z",
"fRecurrence": true,
"EventType": 1,
"Duration": 3600,
"RecurrenceData": "<recurrence><rule><firstDayOfWeek>mo</firstDayOfWeek><repeat><monthlyByDay tu=\"TRUE\" weekdayOfMonth=\"second\" monthFrequency=\"3\" /></repeat><repeatForever>FALSE</repeatForever></rule></recurrence>",
"TimeZone": [THINGS],
"UniqueId": "[UID]"
}
}, {...}, {...}, ... ]
In "EventDate": "2019-12-10T10:00:00Z" and the "EndDate": "2169-09-12T10:00:00Z" we have the start and end date of the "event", however this event is recurent, and have some "rules" -> RecurrenceData.
QUESTIONS:
HOW CAN I PARSE THE RULES (using python) TO KNOW IF WE HAVE THIS MEETING TODAY (2022-11-08 18:00:00) OR NOT;
2)OR, HOW CAN I MEKE A REQUEST TO THE SERVER AND RECEVE ONLY THE TODAYS MEETINGS (DOESN'T METTER IF RECURENT OR NOT)
Maybe usefull links:
In C#
Sherepoint recurrence data schema

Create new key value in JSON data using Python / Pandas?

I'm trying to work with the Campaign Monitor API, posting JSON data through the API to update subscriber lists. I'm currently one change away from being able to send data,
Right now, my JSON data looks like this
{
"EmailAddress": "subscriber1#example.com",
"Name": "New Subscriber One",
"CustomFields": [
{
"Key": "website",
"Value": "http://example.com"
},
{
"Key": "interests",
"Value": "magic"
},
{
"Key": "interests",
"Value": "romantic walks"
},
{
"Key": "age",
"Value": "",
"Clear": true
}
],
},
{
"EmailAddress": "subscriber2#example.com",
"Name": "New Subscriber Two",
},
{
"EmailAddress": "subscriber3#example.com",
"Name": "New Subscriber Three",
}
}
I still need to add a new key value at the beginning of the JSON payload, incorporating the 'Subscribers' : my_json_data. How would I go about easily adding on the Subscribers key and placing my full and current json data into a list?
Final result should look like
{
'Subscribers' : [
{
"EmailAddress": "subscriber1#example.com",
"Name": "New Subscriber One",
"CustomFields": [
{
"Key": "website",
"Value": "http://example.com"
},
{
"Key": "interests",
"Value": "magic"
},
{
"Key": "interests",
"Value": "romantic walks"
},
{
"Key": "age",
"Value": "",
"Clear": true
}
],
},
{
"EmailAddress": "subscriber2#example.com",
"Name": "New Subscriber Two",
},
{
"EmailAddress": "subscriber3#example.com",
"Name": "New Subscriber Three",
}
}
]
}
I've tried to approach this with creating a new dictionary however when I convert that back to JSON I get more issues and headaches. Is there any easy way to keep everything as a JSON formatted dataset and add in the leading 'Subscribers' key?
this should do it assuming you've got a valid JSON.
your_new_json = {}
your_new_json['Subscribers'] = [your_current_json]

Python - PayPal recurring Payments - Agreement Details are not shown

In my python project I have to implement paypal recurring payments.
I have installed the paypal sdk and created a file to create a PayPal payment page, like this:
import paypalrestsdk
from paypalrestsdk import BillingPlan
from paypalrestsdk import BillingAgreement
from paypalrestsdk import Payment
import webbrowser
from urllib import parse
paypalrestsdk.configure({
'mode': 'sandbox', # sandbox or live
'client_id': <my app client id>,
'client_secret': <my app secret>})
def create_bill():
billing_plan = BillingPlan({
"name": "Plan with Regular and Trial Payment Definitions",
"description": "Plan with regular and trial payment definitions.",
"type": "INFINITE",
"payment_definitions": [
{
"name": "Regular payment definition",
"type": "REGULAR",
"frequency": "MONTH",
"frequency_interval": "1",
"amount": {
"value": "100",
"currency": "USD"
},
"cycles": "0",
"charge_models": [
{
"type": "SHIPPING",
"amount": {
"value": "10",
"currency": "USD"
}
},
{
"type": "TAX",
"amount": {
"value": "12",
"currency": "USD"
}
}
]
},
{
"name": "Trial payment definition",
"type": "TRIAL",
"frequency": "WEEK",
"frequency_interval": "5",
"amount": {
"value": "9.19",
"currency": "USD"
},
"cycles": "2",
"charge_models": [
{
"type": "SHIPPING",
"amount": {
"value": "1",
"currency": "USD"
}
},
{
"type": "TAX",
"amount": {
"value": "2",
"currency": "USD"
}
}
]
}
],
"merchant_preferences": {
"setup_fee": {
"value": "1",
"currency": "USD"
},
"return_url": "https://example.com",
"cancel_url": "https://example.com/cancel",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE",
"max_fail_attempts": "0"
}
})
# Create billing plan
if billing_plan.create():
print("Billing Plan [%s] created successfully" % billing_plan.id)
# Activate billing plan
if billing_plan.activate():
billing_plan = BillingPlan.find(billing_plan.id)
print("Billing Plan [%s] state changed to %s" % (billing_plan.id, billing_plan.state))
return billing_plan
else:
print(billing_plan.error)
else:
print(billing_plan.error)
def create_agreement(ret_bil):
billing_agreement = BillingAgreement({
"name": "Fast Speed Agreement",
"description": "Agreement for Fast Speed Plan",
"start_date": "2018-03-29T00:37:04Z",
"plan": {
"id": str(ret_bil.id)
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "StayBr111idge Suites",
"line2": "Cro12ok Street",
"city": "San Jose",
"state": "CA",
"postal_code": "95112",
"country_code": "US"
}
})
if billing_agreement.create():
# Extract redirect url
for link in billing_agreement.links:
if link.method == "REDIRECT":
# Capture redirect url
redirect_url = str(link.href)
# REDIRECT USER TO redirect_url
webbrowser.open(redirect_url)
else:
print(billing_agreement.error)
if __name__ == "__main__":
create_agreement(create_bill())
But when I run the code above, Paypal starts with agreement description but I can't see the item details and description defined in the BilingPlan (I expected to see the detail about items, trial period, amount, recurrence etc)
Is there something wrong in my code? This is the first time I implement Paypal in my project; have I written my code correctly to implement recurrent payments?
So many Thanks in advance
PayPal will not show the recurring period, amount and service details.
You have to show that in your website's page and proceed to PayPal.

django - iterate between json response objects

I have a response object that I am receiving from an api call. The response has several objects that are returned in a single call. What I want to do is grab information from each of the objects returned and store them in varialbes to use them within the application. I know to grab info from a json response when it returns a single objects but I am getting confused with multiples objects... I know how to automate the iteration process through something like a forloop... it wont iterate.
here is a sample response that I am getting:
I want to grab the _id from both items.
{
'user':"<class 'synapse_pay_rest.models.users.user.User'>(id=..622d)",
'json':{
'_id':'..6e80',
'_links':{
'self':{
'href':'https://uat-api.synapsefi.com/v3.1/users/..22d/nodes/..56e80'
}
},
'allowed':'CREDIT-AND-DEBIT',
'client':{
'id':'..26a34',
'name':'Charlie Brown LLC'
},
'extra':{
'note':None,
'other':{
},
'supp_id':''
},
'info':{
'account_num':'8902',
'address':'PO BOX 85139, RICHMOND, VA, US',
'balance':{
'amount':'750.00',
'currency':'USD'
},
'bank_long_name':'CAPITAL ONE N.A.',
'bank_name':'CAPITAL ONE N.A.',
'class':'SAVINGS',
'match_info':{
'email_match':'not_found',
'name_match':'not_found',
'phonenumber_match':'not_found'
},
'name_on_account':' ',
'nickname':'SynapsePay Test Savings Account - 8902',
'routing_num':'6110',
'type':'BUSINESS'
},
<class 'synapse_pay_rest.models.nodes.ach_us_node.AchUsNode'>({
'user':"<class 'synapse_pay_rest.models.users.user.User'>(id=..622d)",
'json':{
'_id':'..56e83',
'_links':{
'self':{
'href':'https://uat-api.synapsefi.com/v3.1/users/..d622d/nodes/..6e83'
}
},
'allowed':'CREDIT-AND-DEBIT',
'client':{
'id':'599378ec6aef1b0021026a34',
'name':'Charlie Brown LLC'
},
'extra':{
'note':None,
'other':{
},
'supp_id':''
},
'info':{
'account_num':'8901',
'address':'PO BOX 85139, RICHMOND, VA, US',
'balance':{
'amount':'800.00',
'currency':'USD'
},
'bank_long_name':'CAPITAL ONE N.A.',
'bank_name':'CAPITAL ONE N.A.',
'class':'CHECKING',
'match_info':{
'email_match':'not_found',
'name_match':'not_found',
'phonenumber_match':'not_found'
},
'name_on_account':' ',
'nickname':'SynapsePay Test Checking Account - 8901',
'routing_num':'6110',
'type':'BUSINESS'
},
})
Here is the code that I have:
It wont grab any values...
the iteration needs to be done to the nodes variable which is hte json response object.
def listedLinkAccounts(request):
currentUser = loggedInUser(request)
currentProfile = Profile.objects.get(user = currentUser)
user_id = currentProfile.synapse_id
synapseUser = SynapseUser.by_id(client, str(user_id))
options = {
'page':1,
'per_page':20,
'type': 'ACH-US',
}
nodes = Node.all(synapseUser, **options)
print(nodes)
response = nodes
_id = response["_id"]
print(_id)
return nodes
here is a sample api response from the api documenation:
{
"error_code": "0",
"http_code": "200",
"limit": 20,
"node_count": 5,
"nodes": [
{
"_id": "594e5c694d1d62002f17e3dc",
"_links": {
"self": {
"href": "https://uat-api.synapsefi.com/v3.1/users/594e0fa2838454002ea317a0/nodes/594e5c694d1d62002f17e3dc"
}
},
"allowed": "CREDIT-AND-DEBIT",
"client": {
"id": "589acd9ecb3cd400fa75ac06",
"name": "SynapseFI"
},
"extra": {
"other": {},
"supp_id": "ABC124"
},
"info": {
"account_num": "7443",
"address": "PLACE DE LA REPUBLIQUE 4 CROIX 59170 FR",
"balance": {
"amount": "0.00",
"currency": "USD"
},
"bank_long_name": "3 SUISSES INTERNATIONAL",
"bank_name": "3 SUISSES INTERNATIONAL",
"name_on_account": " ",
"nickname": "Some Account"
},
"is_active": true,
"timeline": [
{
"date": 1498307689471,
"note": "Node created."
},
{
"date": 1498307690130,
"note": "Unable to send micro deposits as node type is not ACH-US."
}
],
"type": "WIRE-INT",
"user_id": "594e0fa2838454002ea317a0"
},
{
...
},
{
...
},
...
],
"page": 1,
"page_count": 1,
"success": true
}

LUIS.ai json migrated to Rasa format json is not returning the entities but correct intent is returned

I have migrated the json downloaded from LUIS app to RASA format using command: python -m rasa_nlu.train -c config_spacy.json
My configuration file looks like this:
{
"path" : "./models",
"data" : "./data/examples/rasa/BookACab.json",
"pipeline" : ["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy",
"ner_crf", "ner_synonyms", "intent_classifier_sklearn",
"ner_duckling"]
}
A model was generated with json in RASA format as below. However, when I query this model using
http://localhost:5000/parse?q=book a ride later
the correct high scoring intent relating to the text I entered and all its related entities are returned. But when I try another text like:
http://localhost:5000/parse?q=I want to go ride today 5pm
The intent returned is correct one but it's Entities object is empty. As you can see below json,this utterance is also having entities mapped to it similar to the working example.
Please help me to know if this is an issue for everyone with RASA or am I doing any mistake? Thank You!
{
"rasa_nlu_data": {
"common_examples": [
{
"entities": [
{
"entity": "RideTime",
"value": "later",
"start": 0,
"end": 5
}
],
"intent": "None",
"text": "later"
},
{
"entities": [],
"intent": "ServiceRequestEnquiry",
"text": "wake up"
},
{
"entities": [],
"intent": "ConfirmationNo",
"text": "no not now"
},
{
"entities": [],
"intent": "ConfirmationNo",
"text": "not sure"
},
{
"entities": [],
"intent": "ConfirmationNo",
"text": "no bot"
},
{
"entities": [],
"intent": "ConfirmationNo",
"text": "no goride bot"
},
{
"entities": [
{
"entity": "RideTime",
"value": "later",
"start": 12,
"end": 17
}
],
"intent": "BookCab",
"text": "book a ride later"
},
{
"entities": [
{
"entity": "RideTime",
"value": "now",
"start": 21,
"end": 24
}
],
"intent": "BookCab",
"text": "i want go for a ride now"
},
{
"entities": [
{
"entity": "RideTime",
"value": "today",
"start": 12,
"end": 17
}
],
"intent": "BookCab",
"text": "book a ride today"
},
{
"entities": [
{
"entity": "RideTime",
"value": "today 5pm",
"start": 18,
"end": 27
}
],
"intent": "BookCab",
"text": "I want to go ride today 5pm"
},
{
"entities": [
{
"entity": "RideTime",
"value": "today",
"start": 12,
"end": 17
}
],
"intent": "BookCab",
"text": "book a ride today 5pm"
},
{
"entities": [
{
"entity": "RideTime",
"value": "later",
"start": 13,
"end": 18
}
],
"intent": "BookCab",
"text": "book shuttle later"
},
{
"entities": [
{
"entity": "RideTime",
"value": "now",
"start": 15,
"end": 18
}
],
"intent": "None",
"text": "i want to book now"
},
{
"entities": [
{
"entity": "RideTime",
"value": "booknow",
"start": 10,
"end": 17
}
],
"intent": "None",
"text": "i want to booknow"
},
{
"entities": [
{
"entity": "RideTime",
"value": "book later",
"start": 10,
"end": 20
}
],
"intent": "None",
"text": "i want to book later"
}
],
"regex_features": []
}
}
It would be helpful if you could include the pipeline you are using with Rasa. You can find this in your configuration file. Assuming you haven't changed the default pipeline in config_spacy.json then you're using ner_crf for entity recognition.
It's very likely that because of library differences Rasa just requires more training data than LUIS did. Qualitatively the mitie pipeline generally requires less training data, but the trade off is that it takes more time to train.
So the basic answer to your question is: If you want to use ner_crf then you need to increase the amount of training data you are providing for entity recognition.
That being said: is RideTime your only entity? If so you should look into adding ner_duckling to your pipeline, which can recognize dates. This would perform better than you trying to train dates by yourself.
So using your training data above and the pipeline:
["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy", "ner_crf", "ner_synonyms", "intent_classifier_sklearn", "ner_duckling"]
Here is the result:
{
"entities": [
{
"additional_info": {
"grain": "hour",
"others": [
{
"grain": "hour",
"value": "2017-07-26T17:00:00.000Z"
}
],
"value": "2017-07-26T17:00:00.000Z"
},
"end": 27,
"entity": "time",
"extractor": "ner_duckling",
"start": 18,
"text": "today 5pm",
"value": "2017-07-26T17:00:00.000Z"
}
],
"intent": {
"confidence": 0.5469262356494486,
"name": "BookCab"
},
"intent_ranking": [
{
"confidence": 0.5469262356494486,
"name": "BookCab"
},
{
"confidence": 0.2812606328712321,
"name": "None"
},
{
"confidence": 0.08727531874740564,
"name": "ConfirmationNo"
},
{
"confidence": 0.0845378127319134,
"name": "ServiceRequestEnquiry"
}
],
"text": "I want to go ride today 5pm"
}
This complete training set works quite well for me. It was just a matter of adding more training examples. So as you test more, if you come across an example that doesn't work as expected, add it to the training data and re-train. Thus teaching your model to handle more varied requests.
https://gist.github.com/wrathagom/7f05fbda75c785977bd07cd89e62ddd7

Categories

Resources