Get HubSpot Contact From Deal - hubspot

I'm triggering a Zap from HubSport when a Deal moves to a specific stage. This is so that Zapier can hit a WebHook on my backend, and I can get the contact info (email, name, other properties).
It's not clear to me that I can get the contact info from the Deal.
Here is the Deal API: https://developers.hubspot.com/docs/methods/deals/deals_overview
Here is the Deal structure I'm getting passed to the Webhook:
{
'closedate': '1575154955284',
'createdate': '1573686155284',
'days_to_close': '17',
'dealId': 'xxxxxxx',
'dealname': 'Jeff Chandler - New Deal',
'dealstage': 'decisionmakerboughtin',
'hs_all_owner_ids': 'xxxxxx',
'hs_analytics_source': 'DIRECT_TRAFFIC',
'hs_analytics_source_data_1': 'xxxxxxxx',
'hs_closed_amount': '0',
'hs_closed_amount_in_home_currency': '0',
'hs_created_by_user_id': 'xxxxxxxx',
'hs_createdate': '1573686157136',
'hs_deal_stage_probability': '0.8000000000000000444089209850062616169452667236328125',
'hs_is_closed': 'false',
'hs_lastmodifieddate': '1581127561944',
'hs_object_id': 'xxxxxxxxxx',
'hs_sales_email_last_replied': '1577566247000',
'hs_updated_by_user_id': 'xxxxxx',
'hubspot_owner_assigneddate': 'xxxxxxx',
'hubspot_owner_id': 'xxxxxx',
'id': 'xxxxxx-decisionmakerboughtin-xxxxxxx',
'isDeleted': 'False',
'notes_last_contacted': '1577565662000',
'notes_last_updated': '1577566247000',
'num_associated_contacts': '1',
'num_contacted_notes': '12',
'num_notes': '16',
'pipeline': '',
'portalId': ''
}

Ok, think I found the answer.
Associations API: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview
Calling associations API on my dealId with association type 3 (Contacts), gives me the contact id. Boom!
API for for association types: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

Related

Getting ExpectationError: Unexpected call: get('URL_here') when trying to mock Axios API in Sinon

I am trying to mock the third-party API calls in mocha-chai testing. But getting this error when mock API is being called. Couldn't find any relatable and helpful answers on google yet. Any help will be much appreciated. I have been stuck on this for 2 full days!
'ExpectationError: Unexpected call: get('https://BASE_URL/api/invoiceDetails.php', {\n params: { dealerGCD: 'XXXXXX', monthUploaded: '5', yearUploaded: '2022' }\n})\n Expected get('https://BASE_URL/api/invoiceDetails.php', {\n params: { dealerGCD: 'XXXXXX', monthUploaded: 5, yearUploaded: 2022 }\n}) once (never called)\n Expected get('https://BASE_URL/api/invoiceDetails.php', {\n params: { dealerGCD: 'XXXXXX', monthUploaded: '2', yearUploaded: '2022' }\n}) once …icDataService.getInvoiceDetail (/media/disk1/IFM/Micro Services/REPO_NAME/src/core/services/BasicDataService.ts:53:16)\n at BasicDataFlow.<anonymous> (/media/disk1/IFM/Micro Services/REPO_NAME/src/core/flows/BasicDataFlow.ts:54:60)\n at Generator.next (<anonymous>)\n at fulfilled (/media/disk1/IFM/Micro Services/REPO_NAME/src/core/flows/BasicDataFlow.ts:5:58)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)'

Google sRich Snippets. Redirect from https://schema.org to http://schema.org

I tried to add data to google rich spinner to my application. I add this code structure
return {
'#context': 'https://schema.org',
'#type': 'Product',
'sku': this.currentProduct.sku,
'category': this.productCategory,
'name': this.productName,
'description': this.productDescription,
'offers': {
'#type': 'Offer',
'price': this.bestPrice,
'priceCurrency': 'USD',
'availability': this.currentProduct.stock?.is_in_stock ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock'
},
'image': this.thumbnail
}
But if I look to result on search.google.com/test/rich-results I will see that the availability field has been assigned a https://schema.org/InStock value (not https). why is this happening? Is it important for the project?
It's not an issue. Schema.org are transitioning to use https, but for a long time it was http, and http will with for a long time to come.

React Native Paypal Payment Gateway using react-native-paypal-lib

I have spent more then 6 hours in integrating paypal in React Native. I am using react-native-paypal-lib library.
Code:
RNPaypal.paymentRequest({
clientId: 'MY ID I KNOW',
environment: RNPaypal.ENVIRONMENT.SANDBOX,
intent: RNPaypal.INTENT.SALE,
price: 60,
currency: 'USD',
description: 'Android testing',
acceptCreditCards: true
}).then(response => {
console.log(response)
}).catch(err => {
console.log(err.message)
})
Response:
{response_type: "payment", response: {…}, client: {…}}
client:
environment: "mock"
paypal_sdk_version: "2.15.3"
platform: "Android"
product_name: "PayPal-Android-SDK"
response:
create_time: "2014-07-18T18:46:55Z"
id: "PAY-18X32451H0459092JKO7KFUI"
intent: "sale"
state: "approved"
response_type: "payment"
I am getting the response too. But, I cannot see the transactions in my sandbox account. Also, I am getting the same response id every time.
An approved v1/payment (or v2/order) does not create a transaction. The customer has merely passed through the PayPal.com portion of the process, to give their approval.
After your app is notified of this approval, by e.g. their return from PayPal.com to your app with the details, you must execute the v1/payment (or capture the v2/order), which will create a PayPal transaction. The transaction will have its own new unique ID, which is what you should store for accounting purposes.
(The ID used during the approval process, PAY-##### with v1/payments, or just 17 characters for v2/orders, is only worth keeping around about ~1 month for debug purposes. It has no business/accounting value.)

How to compare 2 JSON objects that contains array using Karate tool and feature files

Files for the scenario
All the files are on same directory.
title-update-request.json
{id: 12, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-response.json
{id: 12, name: 'New Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-error-request.json
{id: 00, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-error-response.json
{Error: 'not found', Message: 'The provided Book is not found.'}
book-record.feature
Feature: CRUD operation on the book records.
Background:
* def signIn = call read('classpath:login.feature')
* def accessToken = signIn.accessToken
* url baseUrl
Scenario: Change title of book in the single book-record.
* json ExpResObject = read('classpath:/book-records/title-update-response.json')
* json ReqObject = read('classpath:/book-records/title-update-request.json')
* call read('classpath:/book-records/update.feature') { Token: #(accessToken), ReqObj: #(ReqObject), ResObj: #(ExpResObject), StatusCode: 200 }
Scenario: Change title of book in the non-existing book-record.
* json ExpResObject = read('classpath:/book-records/title-update-error-request.json')
* json ReqObject = read('classpath:/book-records/title-update-error-response.json')
* call read('classpath:/book-records/update.feature') { Token: #(accessToken), ReqObj: #(ReqObject), ResObj: #(ExpResObject), StatusCode: 400 }
update.feature
Feature: Update the book record.
Scenario: Update single book-record.
Given path '/book-record'
And header Authorization = 'Bearer ' + __arg.Token
And header Content-Type = 'application/json'
And request __arg.ReqObj
When method put
Then status __arg.StatusCode
And response == __arg.ExpectedResponse
Actual API response for scenario: 1 is :
{name: 'New Hello', config:[{username: 'abc', password: 'xyz'},{username: 'qwe', password: 'tyu'}]}
Actual API response for scenario: 2 is :
{Error: 'not found', Message: 'The provided Book is not found.'}
Question: How should I validate the response in update.feature file since problem is if I make change s as using #^^config that will not works for scenario :2 and response == _arg.ExpectedResponse is not working for Scenario: 1?
This is classic over-engineering of tests. If someone has told you that "re-use" is needed for tests, please don't listen to that person.
You have two scenarios, one happy path and one negative path. I am providing how you should write the negative path here below, the rest is up to you.
Scenario: Change title of book in the non-existing book-record.
Given path 'book-record'
And header Authorization = 'Bearer ' + accessToken
And request {id: 00, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
When method put
Then status 400
And response == {Error: 'not found', Message: 'The provided Book is not found.'}
See how clean it is ? There is no need for "extreme" re-use in tests. If you still insist that you want a super-generic re-usable feature file that will handle ALL your edge cases, you are just causing trouble for yourself. See how un-readable your existing tests have become !!
EDIT: Since I refer the question to others often as an example of how NOT to write tests, I wanted to make my point more clear and add a couple of links for reference.
Sometimes it is okay to "repeat yourself" in tests. Tests don't have to be DRY. Karate is a DSL that enables you to make HTTP calls or JSON manipulation in one or two lines. When you start attempting "re-use" like this, it actually leads to more harm than good. For example, you now need to look at multiple files to understand what your test is doing.
If you don't believe me, maybe you will believe the team at Google: https://testing.googleblog.com/2019/12/testing-on-toilet-tests-too-dry-make.html

How to tag a block storage using softlayer api

I can't find any method about tag a block storage in following link:
https://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi
Also I checked the command of tag:
https://sldn.softlayer.com/reference/services/SoftLayer_Tag
This command seems like what I want, but I still met some problems:
For the parameter tagTypes, the supported types I get are:
{'keyName': 'HARDWARE', 'description': 'Hardware'},
{'keyName': 'GUEST', 'description': 'CCI'},
{'keyName': 'ACCOUNT_DOCUMENT', 'description': 'Account Document'},
{'keyName': 'TICKET', 'description': 'Ticket'},
{'keyName': 'NETWORK_VLAN_FIREWALL', 'description': 'Vlan Firewall'},
{'keyName': 'CONTRACT', 'description': 'Contract'},
{'keyName': 'IMAGE_TEMPLATE', 'description': 'Image Template'},
{'keyName': 'APPLICATION_DELIVERY_CONTROLLER', 'description': 'Application Delivery Controller'},
{'keyName': 'NETWORK_VLAN', 'description': 'Vlan'}
Not sure which one is proper for block storage.
I tried with tagType "HARDWARE" and tired to set the tag to block storage, the response shows "You do not have permissions to tag this object"
Anyone can help to give some advice, thanks in advance.
I am affraid that is not possbiel to tag the block storages, the object Network_Storage_Iscsi should have a property called tagReference but as you can see in documentation it does not have it:
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage_Iscsi
For example other objects that can be tagged have that property e.g. Tickets or image templates see:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Ticket
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device_Template_Group
Addiotionally the method: https://sldn.softlayer.com/reference/services/SoftLayer_Tag/getAllTagTypes
it should return Network_Storage as a valid type, but it does not.
Regards