I'm receiving an invitee.created webhook from Calendly, which contains Invitee details. I need to get a reference to the Calendly User that hosts the event, so that I can report on it in my application (e.g. keep track of meetings booked with a specific user). How do I do that?
If you need to know which Calendly User (or Users, for collective events) the event was booked with, you need to call Get Event. The event_memberships array will contain a list of User references (URIs). Below is a more detailed step by step guide.
You received a webhook for the event invitee.created. The payload looks something like this:
{
"created_at": "2020-11-23T17:51:19.000000Z",
"created_by": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
"event": "invitee.created",
"payload": {
"cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA",
"created_at": "2020-11-23T17:51:18.327602Z",
"email": "test#example.com",
"event": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2",
"name": "John Doe",
"new_invitee": null,
"old_invitee": null,
"questions_and_answers": [],
"reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA",
"rescheduled": false,
"status": "active",
"text_reminder_number": null,
"timezone": "America/New_York",
"tracking": {
"utm_campaign": null,
"utm_source": null,
"utm_medium": null,
"utm_content": null,
"utm_term": null,
"salesforce_uuid": null
},
"updated_at": "2020-11-23T17:51:18.341657Z",
"uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2/invitees/AAAAAAAAAAAAAAAA",
"canceled": false
}
}
Here, the payload object is the Invitee. It has an event field that is a reference to the Event that the Invitee booked.
Make a GET call to webhook_data.payload.event - this will be the Get Event operation. The response will look like this:
{
"resource": {
"uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2",
"name": "15 Minute Meeting",
"status": "active",
"booking_method": "instant",
"start_time": "2019-08-24T14:15:22Z",
"end_time": "2019-08-24T14:15:22Z",
"event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2",
"location": {
"type": "physical",
"location": "Calendly Office"
},
"invitees_counter": {
"total": 0,
"active": 0,
"limit": 0
},
"created_at": "2019-01-02T03:04:05.678Z",
"updated_at": "2019-01-02T03:04:05.678Z",
"event_memberships": [
{
"user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2"
}
],
"event_guests": []
}
}
The event_memberships array in the above payload is an array of Users with whom the event is scheduled (can be more than one, if it's a collective event). You can then do a GET on these User URIs or just compare these URIs with what you've previously saved in the database.
Related
I have two tables name users and requests in MYSQL database here is json example of each sequelize model which I need to map to my models:
user:
{
"username": "",
"profileImage": "",
"deleted": false,
"active": false,
"id": 9,
"uuid": "9a6d5a15-8e11-42aa-ac56-0bec272c9287",
"firstName": "M",
"lastName": "Aslam",
"email": "hang#outlook.com",
"isGuest": false
}
and request
{
"id": 5,
"requestUUID": "ab966593-95e5-4fd8-b433-01b116e3edee",
"socialLinks": [
{
"url": "https://synavos.com",
"socialLinks": [
{
"platform": "facebook",
"handle": "https://www.facebook.com/synavos/"
},
{
"platform": "instagram",
"handle": "https://www.instagram.com/synavosbusiness/"
},
{
"platform": "youtube",
"handle": "https://www.youtube.com/channel/UCrZxxAV_OiRb9N3wIe3N94w"
}
]
},
{
"url": "https://www.confiz.com/",
"socialLinks": [
{
"platform": "facebook",
"handle": "http://www.facebook.com/ConfizCareers"
},
{
"platform": "youtube",
"handle": "https://www.youtube.com/channel/UCG64lwoDIbwtkZK8E_s140A"
}
]
}
]
}
while a user can have many requests while a request belongs to one user.
if the relation is one to mant (user can have many requests while a request belongs to one user) you can add to request a user_id field. then you can search all request of the user by SELECT * FROM requests where user_id = ?, [user.id], and if you want find the user of a specific request use SELECT ALL FROM users WHERE id = ?, [request.user_id]
i have below code i but data not show in console log please help me i am new in angular.. AND how to show data in HTML
this.$http.get(properties.client+'/123')
.then(response => {
$scope.clientdata= response.data;
console.log($scope.clientdata.address);
});
address array dose not show in console log,i don't know why RESPONSE BELOW
[{ "_id": "123",
"__v": 1,
"history": [],
"address": {
"street_address": "adsf",
"state": "adsf",
"zip_code": "adsf",
"phone_number": "asdf",
"country": "ads",
"city": "asdf",
"site_name": "adsf",
"_id": "123123",
"geolocation": {
"coordinates": [],
"type": "Point"
},
"location": {
"latitude": null,
"longitude": null
},
"id": "5835baaa71a30ca8319b6e36"
},
"current_status": "Assigned",
"time": 0
}]
Your clientdata is an array as per the post, try
console.log($scope.clientdata[0].address);
HTML
{{clientdata[0].address}}
From the structure of your JSON data, clientdata is an array of objects and as of current, there is only one object in the array. So, in order to access the address property of the object, you will have to access it in this way
$scope.clientdata[0].address
and in HTML
{{clientdata[0].address._id}}
and rest of the address object properties in similar fashion.
This is a Sails.js and Node.js application. I am trying to solve a problem I am having. I don't know which way to go to solve it. Which is why the title of my question doesn't really conform with it.
But, this is the scenario. I've this:
LIST OF ORDERS
{
"vehicleType": "30tonne",
"waybill": "7006722988",
"obdCreationDate": "01/11/16 1:21:50 PM",
"route": "5817895991a297ccb386469d",
"source": "agbara",
"destination": "ilorin",
"batchNumber": "ebf96f3322320fb2bedb7bf126f87ab8367f5bd6061cde78ab300e464df2c7af"
},
{
"vehicleType": "30tonne",
"waybill": "7006691063",
"obdCreationDate": "01/11/16 1:21:50 PM",
"route": "5817895e91a297ccb38646d9",
"source": "agbara",
"destination": "katsina",
"batchNumber": "ebf96f3322320fb2bedb7bf126f87ab8367f5bd6061cde78ab300e464df2c7af"
},
And I've this:
LIST OF TRANSPORTERS
{
"vehicles": [
{
"assetIdentification": "EWEW",
"vehicleType": "na",
"transporter": "5817891891a297ccb38645c1",
"organization": "5817878612a8dce1b2e4d359",
"status": "available",
"isDeleted": false,
"createdAt": "2016-10-31T18:20:32.963Z",
"updatedAt": "2016-10-31T18:20:32.963Z",
"id": "5800c3cc391eaa0709cffee5"
},
{
"assetIdentification": "RERE",
"vehicleType": "na",
"transporter": "5817891891a297ccb38645c1",
"organization": "5817878612a8dce1b2e4d359",
"status": "available",
"isDeleted": false,
"createdAt": "2016-10-31T18:20:32.965Z",
"updatedAt": "2016-10-31T18:20:32.965Z",
"id": "5800c4d9391eaa0709cffee6"
}
],
"rates": [
{
"fixedCost": 280759,
"variableCost": 0,
"vehicleType": "30tonne",
"organization": "5817878612a8dce1b2e4d359",
"route": "5817894b91a297ccb38645f9",
"transporter": "5817891891a297ccb38645c1",
"tripType": "normal",
"active": true,
"isDeleted": false,
"totalCost": 280759,
"createdAt": "2016-10-31T18:14:33.668Z",
"updatedAt": "2016-10-31T18:14:33.668Z",
"id": "58178a093ee3f7ffb3b14a47",
"_route": "5817894b91a297ccb38645f9"
},
{
"fixedCost": 280759,
"variableCost": 0,
"vehicleType": "30tonne",
"organization": "5817878612a8dce1b2e4d359",
"route": "5817894b91a297ccb38645fa",
"transporter": "5817891891a297ccb38645c1",
"tripType": "normal",
"active": true,
"isDeleted": false,
"totalCost": 280759,
"createdAt": "2016-10-31T18:14:33.866Z",
"updatedAt": "2016-10-31T18:14:33.866Z",
"id": "58178a093ee3f7ffb3b14a66",
"_route": "5817894b91a297ccb38645fa"
}
],
"organization": "5817878612a8dce1b2e4d359",
"name": "Some Organization",
"email": "sosoos#soso.so",
"phone": "8392398293829",
"active": true,
"isDeleted": false,
"slug": "some-orgs",
"createdAt": "2016-10-31T18:10:32.623Z",
"updatedAt": "2016-10-31T18:10:32.623Z",
"id": "5817891891a297ccb38645c1"
}
That record above (Transporters) is over 9000 and each transporter have rates over 200. And, the one before that (ORDERS) can come in any size.
So, this is the problem. Every Orders have routeId and vehicleType. Transporters have Array of vehicles with vehicleSize (s), Array of rates which each have rateId, vehicleType and totalCost(Cost for that route). The problem I am trying to solve is to get the cheapest rate to complete all the orders even if assigning 1 order to every transporter would make it cheap. I wrote one which I was having loops within loops to do all forms of combination and it got me the cheapest. But, running it against 30 Orders rendered the app unavailable for any other request and with 7GB dedicated RAM, we still run out of Memory every now and then and since JavaScript is synchronous, that would surely make the port the app's running useless unless it's done with that operation. 30 Orders takes 30mins to an hour.
I couldn't think of what to do. I tried going through if Permutation and Combination can solve it, but no. I'm not looking for a fully written solution. I just need suggestions on what to do and how to go about it. Any help would be greatly appreciated. Thanks.
It is a classical A* pathfinding task. To optimise you should create reverse index [vehicleType,route]=>[vehicle] with minimum rate for every combination of vehicleType and route, it takes single iteration through all rates, e.g. O(r). Then going through every order you can assign relevant vehicle from the index. It does not account for active and availability flags and same vehicle might be assigned multiple orders, but it will be easy to improve extending above index with array of resulting vehicles ordered by the price.
Reverse index is best to be built on a database side via map-reduce. Though you can build it in the node too:
let ratesByRouteVType = []
transporters
.rates
.forEach(r => {
let cmpRate = ratesByRouteVType[r.route+r.vehicleType]
if(!cmpRate || cmpRate.totalCost>r.totalCost)
ratesByRouteVType[r.route+r.vehicleType]=r
})
Im trying to get a value "status" from "customer" object with this simple script:
console.log(JSON.stringify(customer.subscriptions.data.plan.status));
When i execute this function, the console returns me:
TypeError: Cannot read property 'data' of undefined
"customer" Object:
customer: {
"object":"customer",
"created":xxxxxx,
"id":"xxxxxxx",
"livemode":false,
"description":null,
"email":"xxxx#xxxx.com",
"shipping":null,
"delinquent":false,
"metadata":{},
"subscriptions":{
"object":"list",
"total_count":1,
"has_more":false,
"url":"/v1/customers/xxxxxxxxx/subscriptions",
"data":[{
"id":"xxxxxxxxx",
"plan":{
"interval":"month",
"name":"xxxxxx",
"created":xxxxx,
"amount":xxxxx,
"currency":"eur",
"id":"6month",
"object":"plan",
"livemode":false,
"interval_count":6,
"trial_period_days":null,
"metadata":{},
"statement_descriptor":null,
"statement_description":null},
"object":"subscription",
"start":xxxxx,
"status":"active",
...,
Please help me.
Thanks.
The error doesn't match up with the data. It should be that it can't read status of undefined. This is because customer does have subscriptions, and subscriptions does have data, but then you're treating data as though it had a plan property, which it doesn't. data refers to an array, the first entry of which has a plan property. Also note that status is not a property of plan, it's a property of the same object that plan is a property of.
So accessing the first entry's status would be:
customer.subscriptions.data[0].status
// Note -------------------^^^
If there are subsequent entries in data, they would be at indexes 1, 2, 3, etc.
Example:
var customer = {
"object": "customer",
"created": "xxxxxx",
"id": "xxxxxxx",
"livemode": false,
"description": null,
"email": "xxxx#xxxx.com",
"shipping": null,
"delinquent": false,
"metadata": {},
"subscriptions": {
"object": "list",
"total_count": 1,
"has_more": false,
"url": "/v1/customers/xxxxxxxxx/subscriptions",
"data": [
{
"id": "xxxxxxxxx",
"plan": {
"interval": "month",
"name": "xxxxxx",
"created": "xxxxx",
"amount": "xxxxx",
"currency": "eur",
"id": "6month",
"object": "plan",
"livemode": false,
"interval_count": 6,
"trial_period_days": null,
"metadata": {},
"statement_descriptor": null,
"statement_description": null
},
"object": "subscription",
"start": "xxxxx",
"status": "active"
}
]
}
};
document.body.innerHTML = customer.subscriptions.data[0].status;
Is there a way to display the current number of members of my Facebook group on a SquareSpace code block (which only accepts HTML and JavaScript)?
Totally.
You can use Facebook Graph to accomplish what you want. Using an ordinary HTTPS request, I got this JSON-formatted results :
{
"id": "165227436975532",
"about": "Salon de Th\u00e9 style traditionnelle ..!!",
"can_post": false,
"category": "Restaurant/Cafe",
"category_list": [
{
"id": "203462172997785",
"name": "Tea Room"
}
],
"checkins": 66,
"cover": {
"cover_id": "476669145831358",
"offset_x": 0,
"offset_y": 54,
"source": "https://scontent.xx.fbcdn.net/hphotos-xpt1/v/t1.0-9/11536065_476669145831358_6075091507244297763_n.jpg?oh=7c6940ee3f2566884609fc59da224b67&oe=563A1B1D",
"id": "476669145831358"
},
"has_added_app": false,
"is_community_page": false,
"is_published": true,
"likes": 1246,
"link": "https://www.facebook.com/arabiccafe",
"location": {
"city": "Sousse",
"country": "Tunisia",
"latitude": 35.864546,
"longitude": 10.5988045,
"street": "Hammem Sousse",
"zip": "4011"
},
"name": "Arabica Cafe",
"parking": {
"lot": 0,
"street": 0,
"valet": 0
},
"phone": "21770198",
"talking_about_count": 6,
"username": "arabiccafe",
"were_here_count": 66
}
In order to get these info, you can use a normal XHR request (or jQuery.ajax if you use jQuery) and make a GET request to this URL :
https://graph.facebook.com/arabiccafe?access_token={your_token}
You can generate a token following these directives.