How to Identify if change has been made by private-app in Hubspot Webhook? - hubspot

If any change is made to Hubspot data via Private-App, I'm getting below Webhook,
[{'eventId': 9928183, 'subscriptionId': 131457, 'portalId': 14032763, 'appId': 446003, 'occurredAt': 1662391386131, 'subscriptionType': 'contact.propertyChange', 'attemptNumber': 0, 'objectId': 237212451, 'propertyName': 'lead_time_zone', 'propertyValue': 'Asia Calcutta', 'changeSource': 'INTEGRATION'}]
here the changeSource is INTEGRATION
We have multiple Integrations with our Hubspot account, how do I know if the webhook is triggered because of Private-app Integration?

Related

How to get a Workday worker / employee web profile URL?

I wish to retrieve a Workday worker (aka employee) web profile URL via the Workday API. The use case is that I'm building a chatbot to retrieve user information and I want to be able to deep link to the worker (employee) web profile.
The issue is that I cannot do either of the following:
get a web profile URL from the API
create a web profile URL from data in the API
A web profile URL looks like the following. The userId looks like 1234 right before the .htmld extension as that is the only number that changes between employee profiles.
https://www.myworkday.com/{myCompany}/d/inst/1$715/247${1234}.htmld
A search URL in the webUI returns a slightly different URL but has the same numerical userId at the end, e.g. the 1234 before .htmld here:
https://www.myworkday.com/{myCompany}/d/inst/autocompletesearch/247${1234}.htmld
A worker API call is like the following with a 32 byte hexadecimal workerId like deadbeefdeadbeefdeadbeefdeadbeef. Searching for the API workerId in the web UI returns no results.
https://services1.myworkday.com/ccx/api/api/v1/{myCompany}/workers/{workerId}
The API result does not have the web profile userId, e.g. 1234, any where in it, or a URL that can render a web page.
{
"id":"deadbeefdeadbeefdeadbeefdeadbeef",
"descriptor":"Joe Cool",
"href":"https://services1.myworkday.com/ccx/api/api/v1/{myCompany}/workers/deadbeefdeadbeefdeadbeefdeadbeef",
"supervisoryOrganizationsManaged":"https://services1.myworkday.com/ccx/api/api/v1/{myCompany}/workers/deadbeefdeadbeefdeadbeefdeadbeef/supervisoryOrganizationsManaged",
"yearsOfService":"1",
"primaryWorkEmail":"joe.cool#example.com",
"isManager":false,
"location":{
"descriptor":"Santa Rosa, California",
"id":"deadbeefdeadbeefdeadbeefdeadbeef"
},
"primarySupervisoryOrganization":{
"descriptor":"Peanuts (Charles 'Sparky' Schulz)",
"id":"deadbeefdeadbeefdeadbeefdeadbeef",
"href":"https://services1.myworkday.com/ccx/api/api/v1/{myCompany}/supervisoryOrganizations/deadbeefdeadbeefdeadbeefdeadbeef"
},
"businessTitle":"beagle"
}
Can anyone help provide info on how to get a web profile URL from the Workday API?
The ID returned from workday's API is actually the Workday ID, not Worker ID. The Workday ID or WID is a direct reference to any object in Workday. This is often referred to as an "Integration ID". Workday doesn't document this very well, but workday's URLs do have an interesting thing you can take advantage of for deep linking to any Workday Object:
https://www.myworkday.com/{myCompany}/d/inst/{sourceReferenceWID}/{WID}.htmld
As long as you have the Workday ID (WID) of an object, you can deeplink directly. The sourceReferenceWID is just for logging purposes, so you can enter any text you want. I tested this in my own tenant with the text "deeplink" replacing {sourceReferenceWID} just for fun. For your example, the following URL should work for Joe Cool:
https://www.myworkday.com/{myCompany}/d/inst/deeplink/deadbeefdeadbeefdeadbeefdeadbeef.htmld
This is not officially documented, so Workday may change how this works and your mileage may vary.
It's not a delivered REST API, but you could create a RaaS with the Business Object "Worker from Prompt". There is a field called "Worker Instance URL". When you call the endpoint, you can use the WID (Workday ID), the Employee_ID, or Contingent_Worker_ID for the filter.
https://wd2-impl-services1.workday.com/ccx/service/customreport2/{tenant}/{report owner}/{report name}?Worker!WID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
or
https://wd2-impl-services1.workday.com/ccx/service/customreport2/{tenant}/{report owner}/{report name}?Worker!Employee_ID=x

How to make a shopify API request inside webhook callback script

I am writing my first Shopify app that will unpublish a product once its inventory level goes below threshold.
For that I register a webhook with callback URL http://example.com/script.php that will be called by Shopify once product update event occurs.
In script.php how do I obtain Shopify API token to make PUT request to products/update to unpublish it?
Here is my script.php so far (I know I am missing hmac validation but that is not the point):
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
session_start();
require 'shopify.php';
$api_key = 'api_key';
$secret = 'secret';
$sc = new ShopifyClient($_SERVER['HTTP_X_SHOPIFY_SHOP_DOMAIN'], $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'], $api_key, $secret);
$inventory = $_POST['inventory_quantity'];
$old_inventory = $_POST['old_inventory_quantity'];
if($inventory <= 0){
$args = array("product" => array("id" => $_SERVER['HTTP_X_SHOPIFY_PRODUCT_ID'], "published" => false));
$sc->call("PUT","/admin/products/".$_SERVER['HTTP_X_SHOPIFY_PRODUCT_ID'].".json",$args);
}
}
I am trying to use $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'] but obviously that is wrong.
Shopify sends you the name of the shop in the header of every webhook. So your webhook can now authenticate the incoming call, and with the shop name, you simply query your persistence layer for the matching shop credentials. If you find the shop, you can open up an API session very easily, since you have the two things you need:
shopify domain name of the store
shopify access token
Note that a better way to hide products is to consider listening to the orders webhooks, which provide orders and products, and then query the inventory level of the product sold. Working off of product/update webhooks could be super obnoxious in terms of the number of calls you might have to process in comparison to orders.

Getting transactions in Yodlee sandbox environment

I'm trying to fetch all user transaction using executeUserSearchRequest in sandbox, but getting {"errorOccurred":"true","exceptionType":"Exception Occurred","referenceCode":"_5e6f0985-ea74-49bc-8436-e0b015657246"}
Could it be done in sandbox environment?
My request is:
transactionSearchRequest.ignoreUserInput=true
transactionSearchRequest.searchFilter=
userSessionToken=08062013_0:a924114f74e7ddedefc5a004422a020ca3fc7080930307578559302de9bf3c8c627aaf02e99491eed69ea75570c4ea67e82b2c5523dc7f91544a4cc49a0be67b
transactionSearchRequest.resultRange.endNumber=500
transactionSearchRequest.containerType=bank
cobSessionToken=08062013_0:737f4e96deca907d7554ca5f77ff482bf1bde89963bd7f74c06df67d33dea6dcce458bf399f40742c8a3f7dc8815b2775bf3291c1556489b1a195ae6dfa2467b
transactionSearchRequest.resultRange.startNumber=1
It seams like transactionSearchRequest.searchFilter.currencyCode should be specified and transactionSearchRequest.searchFilter.transactionSplitType should be full (ALL_TRANSACTION).

twitter stream API track all tweet posted by user who registered in twitter application

I am creating the application which need to track all tweets from user who registered to my application, i tried to track those with streaming API , there are public API, user API , and site API,
in those API it just have an option to follow the user ID by add the comma separated user ID
https://dev.twitter.com/streaming/overview/request-parameters#follow
but i think it is not flexible, if there are a new user registered , i need to rebuild the HTTP request , and also if there are so many users try to listen this stream and query will be so long,
it will be
https://stream.twitter.com/1.1/statuses/filter.json?follow=[user1],[user2],[user3]........[userN],
i afraid the query wont fit, i just need a parameter to filter all user who registered in my application such as, for example.
https://stream.twitter.com/1.1/statuses/filter.json?application=[applicationID]
but i think twitter dev does not provide it
so, is there any way to filter stream by application ID?
I didn't see anything like tracking by application id. If your query become too complex (too many follows/keywords), public streaming api will reject it,
and you can't open more than 2 connections with user stream. So, last solution is using Site Stream, -> you can open as many user connections as you have users registered to your app.
BUT the docs says :
"Site Streams is currently in a closed beta. Applications are no
longer being accepted."
Contact twitter to be sure
Arstechnica has a very interesting article about it. Take a look at this code and the link in the end of this post
If you are using python pycurl will do the job. Its provides a way to execute a function for every little piece of data received.
import pycurl, json
STREAM_URL = "http://chirpstream.twitter.com/2b/user.json"
USER = "YOUR_USERNAME"
PASS = "XXXXXXXXX"
userlist = ['user1',...,'userN']
def on_receive(self, data):
self.buffer += data
if data.endswith("rn") and self.buffer.strip():
content = json.loads(self.buffer)
self.buffer = ""
if "text" in content and content['user'] in userlist:
#do stuff
conn = pycurl.Curl()
conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS))
conn.setopt(pycurl.URL, STREAM_URL)
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
conn.perform()
You can find more information here Real time twitter stream api

Google Checkout API - Connect order with notification?

Using the Google Checkout XML API, is it possible to connect an order you send to Google Checkout to an order Google Checkout notifies you about?
Right now, I can send an order to Google Checkout, and I can get notifications from Google that an order went through. But I don't see how to connect the two. I need this to connect orders to user accounts.
Send over an explicit order number with your data to Google. This is some test code I wrote that does just this
CheckoutShoppingCartRequest Req = checkoutButton.CreateRequest();
Req.AddItem(product.Name, product.ShortDescription, OrderID, product.Price, 1);
GCheckoutResponse Resp = Req.Send();
if (Resp.IsGood)
{
}
else
{
}
Generally, you can use the merchant-private-data field to pass any custom data about your order.
When you get back the notification, read the custom info from the merchant-private-data field.
See this answer for a solution to a similar issue.