From 0eaa795ca218629a22ee9e1f97c3bbed72f86c93 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 15:16:34 +0100 Subject: [PATCH 01/10] Add assocation object --- lib/hubspot/association.rb | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/hubspot/association.rb diff --git a/lib/hubspot/association.rb b/lib/hubspot/association.rb new file mode 100644 index 00000000..0a05ba2d --- /dev/null +++ b/lib/hubspot/association.rb @@ -0,0 +1,39 @@ +class Hubspot::Association + COMPANY_TO_CONTACT = 2 + DEAL_TO_CONTACT = 3 + DEAL_TO_COMPANY = 5 + + BATCH_CREATE_PATH = '/crm-associations/v1/associations/create-batch' + BATCH_DELETE_PATH = '/crm-associations/v1/associations/delete-batch' + + class << self + def create(from_id, to_id, definition_id) + batch_create([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) + end + + def batch_create(associations) + request = associations.map { |assocation| build_association_body(assocation) } + Hubspot::Connection.put_json(BATCH_CREATE_PATH, body: request).success? + end + + def delete(from_id, to_id, definition_id) + batch_create([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) + end + + def batch_delete(associations) + request = associations.map { |assocation| build_association_body(assocation) } + Hubspot::Connection.put_json(BATCH_CREATE_PATH, body: request).success? + end + + private + + def build_association_body(assocation) + { + fromObjectId: assocation[:from_id], + toObjectId: assocation[:to_id], + category: 'HUBSPOT_DEFINED', + definitionId: assocation[:definition_id] + } + end + end +end From d22c108d0c54dd260cfd11d23720be4a579da638 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 15:43:16 +0100 Subject: [PATCH 02/10] Add create specs --- lib/hubspot-ruby.rb | 1 + lib/hubspot/association.rb | 4 +- ...th_a_valid_ID_associates_the_resources.yml | 240 ++++++++++++++++++ ...ate_with_an_invalid_ID_raises_an_error.yml | 126 +++++++++ spec/lib/hubspot/association_spec.rb | 28 ++ 5 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_a_valid_ID_associates_the_resources.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_an_invalid_ID_raises_an_error.yml create mode 100644 spec/lib/hubspot/association_spec.rb diff --git a/lib/hubspot-ruby.rb b/lib/hubspot-ruby.rb index ad2a4fd6..fe6adf83 100644 --- a/lib/hubspot-ruby.rb +++ b/lib/hubspot-ruby.rb @@ -6,6 +6,7 @@ require 'hubspot/collection' require 'hubspot/paged_collection' require 'hubspot/properties' +require 'hubspot/association' require 'hubspot/company' require 'hubspot/company_properties' require 'hubspot/config' diff --git a/lib/hubspot/association.rb b/lib/hubspot/association.rb index 0a05ba2d..d1392c4b 100644 --- a/lib/hubspot/association.rb +++ b/lib/hubspot/association.rb @@ -13,7 +13,7 @@ def create(from_id, to_id, definition_id) def batch_create(associations) request = associations.map { |assocation| build_association_body(assocation) } - Hubspot::Connection.put_json(BATCH_CREATE_PATH, body: request).success? + Hubspot::Connection.put_json(BATCH_CREATE_PATH, params: { no_parse: true }, body: request).success? end def delete(from_id, to_id, definition_id) @@ -22,7 +22,7 @@ def delete(from_id, to_id, definition_id) def batch_delete(associations) request = associations.map { |assocation| build_association_body(assocation) } - Hubspot::Connection.put_json(BATCH_CREATE_PATH, body: request).success? + Hubspot::Connection.put_json(BATCH_CREATE_PATH, params: { no_parse: true }, body: request).success? end private diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_a_valid_ID_associates_the_resources.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_a_valid_ID_associates_the_resources.yml new file mode 100644 index 00000000..46628697 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_a_valid_ID_associates_the_resources.yml @@ -0,0 +1,240 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Boyer and Sons"},{"name":"domain","value":"klein.name"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 14:40:33 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:33 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249945' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e00ea6fee3b-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2605959490,"isDeleted":false,"properties":{"website":{"value":"klein.name","timestamp":1574260833540,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"klein.name","timestamp":1574260833540,"source":"CALCULATED","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]},"hs_lastmodifieddate":{"value":"1574260833540","timestamp":1574260833540,"source":"CALCULATED","sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","versions":[{"name":"hs_lastmodifieddate","value":"1574260833540","timestamp":1574260833540,"sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","source":"CALCULATED","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]},"domain":{"value":"klein.name","timestamp":1574260833540,"source":"API","sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","versions":[{"name":"domain","value":"klein.name","timestamp":1574260833540,"sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","source":"API","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]},"hs_object_id":{"value":"2605959490","timestamp":1574260833540,"source":"API","sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","versions":[{"name":"hs_object_id","value":"2605959490","timestamp":1574260833540,"sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","source":"API","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]},"name":{"value":"Boyer + and Sons","timestamp":1574260833540,"source":"API","sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","versions":[{"name":"name","value":"Boyer + and Sons","timestamp":1574260833540,"sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","source":"API","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]},"createdate":{"value":"1574260833540","timestamp":1574260833540,"source":"API","sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","versions":[{"name":"createdate","value":"1574260833540","timestamp":1574260833540,"sourceId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569","source":"API","sourceVid":[],"requestId":"4dc15a71-7619-4991-aaa0-7e19cd7ef569"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:33 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Shirley"},{"property":"lastname","value":"Pfannerstill"},{"property":"email","value":"karrie.moen@example.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 14:40:34 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:33 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249944' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e037d5b3baf-CDG + body: + encoding: UTF-8 + string: '{"vid":71451,"canonical-vid":71451,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPOxXLQaJJFVW_n_ShcVR0GVV7ED9MDjn1d2wh6-yjTiQAMrxrjqGmOYVNuVseUkyhxpsRDbAN4mdunkmuwLY5Gta-8KGVi4K4qNjOpkGVploWkrktILpSLGoHWH9xDs36UwUDv","profile-url":"https://app.hubspot.com/contacts/62515/contact/71451","properties":{"firstname":{"value":"Shirley","versions":[{"value":"Shirley","source-type":"API","source-id":null,"source-label":null,"timestamp":1574260833914,"selected":false}]},"email":{"value":"karrie.moen@example.net","versions":[{"value":"karrie.moen@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574260833914,"selected":false}]},"lastname":{"value":"Pfannerstill","versions":[{"value":"Pfannerstill","source-type":"API","source-id":null,"source-label":null,"timestamp":1574260833914,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":71451,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"karrie.moen@example.net","timestamp":1574260833923,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"962e7dda-8157-48d5-abb9-a77bafb38583","timestamp":1574260833945,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:34 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2605959490,"toObjectId":71451,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 14:40:34 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:34 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249943' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e069e1aedf7-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:34 GMT +- request: + method: get + uri: https://api.hubapi.com/companies/v2/companies/2605959490/vids?count=25&hapikey=demo&vidOffset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 14:40:35 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '50' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:34 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249942' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e0a0e60cddb-CDG + body: + encoding: UTF-8 + string: '{"vids":[71451],"vidOffset":71451,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:35 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_an_invalid_ID_raises_an_error.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_an_invalid_ID_raises_an_error.yml new file mode 100644 index 00000000..484138f6 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_create_with_an_invalid_ID_raises_an_error.yml @@ -0,0 +1,126 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Wintheiser and Sons"},{"name":"domain","value":"bernhard.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 14:40:35 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:35 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249941' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e0c1bb0ee60-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2605973259,"isDeleted":false,"properties":{"website":{"value":"bernhard.net","timestamp":1574260835285,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"bernhard.net","timestamp":1574260835285,"source":"CALCULATED","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]},"hs_lastmodifieddate":{"value":"1574260835285","timestamp":1574260835285,"source":"CALCULATED","sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","versions":[{"name":"hs_lastmodifieddate","value":"1574260835285","timestamp":1574260835285,"sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","source":"CALCULATED","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]},"domain":{"value":"bernhard.net","timestamp":1574260835285,"source":"API","sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","versions":[{"name":"domain","value":"bernhard.net","timestamp":1574260835285,"sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","source":"API","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]},"hs_object_id":{"value":"2605973259","timestamp":1574260835285,"source":"API","sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","versions":[{"name":"hs_object_id","value":"2605973259","timestamp":1574260835285,"sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","source":"API","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]},"name":{"value":"Wintheiser + and Sons","timestamp":1574260835285,"source":"API","sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","versions":[{"name":"name","value":"Wintheiser + and Sons","timestamp":1574260835285,"sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","source":"API","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]},"createdate":{"value":"1574260835285","timestamp":1574260835285,"source":"API","sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","versions":[{"name":"createdate","value":"1574260835285","timestamp":1574260835285,"sourceId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8","source":"API","sourceVid":[],"requestId":"ecefdf8f-ad41-4b3b-816b-cc94634a15e8"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:35 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2605973259,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Date: + - Wed, 20 Nov 2019 14:40:35 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '212' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 14:40:35 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249940' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b2e0d897fcd7b-CDG + body: + encoding: UTF-8 + string: '{"status":"error","message":"One or more associations are invalid","correlationId":"1c4bbe72-cfbe-4a7d-8388-6de4be7a9a26","errors":["CONTACT=1234 + is not valid"],"requestId":"725053b4-f7cd-4e4a-8746-b34f925ce9b2"}' + http_version: + recorded_at: Wed, 20 Nov 2019 14:40:35 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/association_spec.rb b/spec/lib/hubspot/association_spec.rb new file mode 100644 index 00000000..8b1de6f8 --- /dev/null +++ b/spec/lib/hubspot/association_spec.rb @@ -0,0 +1,28 @@ +RSpec.describe Hubspot::Association do + before { Hubspot.configure(hapikey: 'demo') } + + describe '.create' do + context 'with a valid ID' do + cassette + let(:company) { create :company } + let(:contact) { create :contact } + + subject { described_class.create(company.id, contact.id, described_class::COMPANY_TO_CONTACT) } + + it 'associates the resources' do + expect(subject).to be true + expect(company.contact_ids.resources).to eq [contact.id] + end + end + + context 'with an invalid ID' do + cassette + let(:company) { create :company } + subject { described_class.create(company.id, 1234, described_class::COMPANY_TO_CONTACT) } + + it 'raises an error' do + expect { subject }.to raise_error(Hubspot::RequestError, /One or more associations are invalid/) + end + end + end +end From 25f26ea41d0a4d12e4bda76ae54df1a4f829c0bb Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 16:10:07 +0100 Subject: [PATCH 03/10] Add batch_create specs --- ...valid_request_associates_the_resources.yml | 298 ++++++++++++++++++ ...ate_with_an_invalid_ID_raises_an_error.yml | 244 ++++++++++++++ spec/lib/hubspot/association_spec.rb | 50 ++- 3 files changed, 588 insertions(+), 4 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_a_valid_request_associates_the_resources.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_an_invalid_ID_raises_an_error.yml diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_a_valid_request_associates_the_resources.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_a_valid_request_associates_the_resources.yml new file mode 100644 index 00000000..6fbf617a --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_a_valid_request_associates_the_resources.yml @@ -0,0 +1,298 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:01 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:00 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249915' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4ee61f5f68d6-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188583018,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574262180883","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574262180883","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574262180883","timestamp":1574262180883,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574262180883","timestamp":1574262180883,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188583018","timestamp":1574262180883,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188583018","timestamp":1574262180883,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574262180883","timestamp":1574262180883,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574262180883","timestamp":1574262180883,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:01 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Virgilio"},{"property":"lastname","value":"Roberts"},{"property":"email","value":"paulita.kunze@example.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:02 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:02 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249914' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4eeecd88690c-CDG + body: + encoding: UTF-8 + string: '{"vid":71551,"canonical-vid":71551,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPKyCXhv9RH3W-MBLO-KI5deuf_JuWa3uaRcDQk-u94R_IujEbGSsgxt0zS7JlHa02kP42hg0to8e3h-AXE0OCTQs6DOu8rxatZtIPBDGfGRROuDsWk_KDKJbqgZAMpfcrDMOAz","profile-url":"https://app.hubspot.com/contacts/62515/contact/71551","properties":{"firstname":{"value":"Virgilio","versions":[{"value":"Virgilio","source-type":"API","source-id":null,"source-label":null,"timestamp":1574262182296,"selected":false}]},"email":{"value":"paulita.kunze@example.net","versions":[{"value":"paulita.kunze@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574262182296,"selected":false}]},"lastname":{"value":"Roberts","versions":[{"value":"Roberts","source-type":"API","source-id":null,"source-label":null,"timestamp":1574262182296,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":71551,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"paulita.kunze@example.net","timestamp":1574262182304,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"e3382b43-1605-4475-b6f7-067281909aa6","timestamp":1574262182353,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:02 GMT +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Kuhic and Sons"},{"name":"domain","value":"brown.io"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:03 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:02 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249913' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4ef2cfc4edeb-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2605993835,"isDeleted":false,"properties":{"website":{"value":"brown.io","timestamp":1574262182918,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"brown.io","timestamp":1574262182918,"source":"CALCULATED","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]},"hs_lastmodifieddate":{"value":"1574262182918","timestamp":1574262182918,"source":"CALCULATED","sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","versions":[{"name":"hs_lastmodifieddate","value":"1574262182918","timestamp":1574262182918,"sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","source":"CALCULATED","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]},"domain":{"value":"brown.io","timestamp":1574262182918,"source":"API","sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","versions":[{"name":"domain","value":"brown.io","timestamp":1574262182918,"sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","source":"API","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]},"hs_object_id":{"value":"2605993835","timestamp":1574262182918,"source":"API","sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","versions":[{"name":"hs_object_id","value":"2605993835","timestamp":1574262182918,"sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","source":"API","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]},"name":{"value":"Kuhic + and Sons","timestamp":1574262182918,"source":"API","sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","versions":[{"name":"name","value":"Kuhic + and Sons","timestamp":1574262182918,"sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","source":"API","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]},"createdate":{"value":"1574262182918","timestamp":1574262182918,"source":"API","sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","versions":[{"name":"createdate","value":"1574262182918","timestamp":1574262182918,"sourceId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783","source":"API","sourceVid":[],"requestId":"a35cdc31-491a-4b9d-ad32-5cb825dfe783"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:03 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1188583018,"toObjectId":71551,"category":"HUBSPOT_DEFINED","definitionId":3},{"fromObjectId":1188583018,"toObjectId":2605993835,"category":"HUBSPOT_DEFINED","definitionId":5}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 15:03:03 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:03 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249912' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4ef56fa3b763-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:03 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1188583018?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:03 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:03 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249911' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4ef81cce3c33-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188583018,"isDeleted":false,"associations":{"associatedVids":[71551],"associatedCompanyIds":[2605993835],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574262181540","timestamp":1574262181540,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574262181540","timestamp":1574262181540,"source":"CALCULATED","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":1574262181333,"source":"CALCULATED","sourceId":"RollupProperties","versions":[{"name":"num_associated_contacts","value":"0","timestamp":1574262181333,"sourceId":"RollupProperties","source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574262180883","timestamp":1574262180883,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574262180883","timestamp":1574262180883,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188583018","timestamp":1574262180883,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188583018","timestamp":1574262180883,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574262180883","timestamp":1574262180883,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574262180883","timestamp":1574262180883,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574262180883,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:04 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_an_invalid_ID_raises_an_error.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_an_invalid_ID_raises_an_error.yml new file mode 100644 index 00000000..1a785e3f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_create_with_an_invalid_ID_raises_an_error.yml @@ -0,0 +1,244 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:04 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:04 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249910' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4efb4b70edbb-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188574831,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574262184279","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574262184279","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574262184279","timestamp":1574262184279,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574262184279","timestamp":1574262184279,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188574831","timestamp":1574262184279,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188574831","timestamp":1574262184279,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574262184279","timestamp":1574262184279,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574262184279","timestamp":1574262184279,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:04 GMT +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Corkery, Zieme and O''Connell"},{"name":"domain","value":"hand.name"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:04 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:04 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249909' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '93' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4efd1c65cd87-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2606018581,"isDeleted":false,"properties":{"website":{"value":"hand.name","timestamp":1574262184566,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"hand.name","timestamp":1574262184566,"source":"CALCULATED","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]},"hs_lastmodifieddate":{"value":"1574262184566","timestamp":1574262184566,"source":"CALCULATED","sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","versions":[{"name":"hs_lastmodifieddate","value":"1574262184566","timestamp":1574262184566,"sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","source":"CALCULATED","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]},"domain":{"value":"hand.name","timestamp":1574262184566,"source":"API","sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","versions":[{"name":"domain","value":"hand.name","timestamp":1574262184566,"sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","source":"API","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]},"hs_object_id":{"value":"2606018581","timestamp":1574262184566,"source":"API","sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","versions":[{"name":"hs_object_id","value":"2606018581","timestamp":1574262184566,"sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","source":"API","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]},"name":{"value":"Corkery, + Zieme and O''Connell","timestamp":1574262184566,"source":"API","sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","versions":[{"name":"name","value":"Corkery, + Zieme and O''Connell","timestamp":1574262184566,"sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","source":"API","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]},"createdate":{"value":"1574262184566","timestamp":1574262184566,"source":"API","sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","versions":[{"name":"createdate","value":"1574262184566","timestamp":1574262184566,"sourceId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e","source":"API","sourceVid":[],"requestId":"1eb28a18-9ef4-4613-801a-db6ba7eb2b9e"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:04 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1188574831,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":3},{"fromObjectId":1188574831,"toObjectId":2606018581,"category":"HUBSPOT_DEFINED","definitionId":5}]' + headers: + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Date: + - Wed, 20 Nov 2019 15:03:05 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '212' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:04 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249908' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '92' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4f00293acdcb-CDG + body: + encoding: UTF-8 + string: '{"status":"error","message":"One or more associations are invalid","correlationId":"3b38cb7b-9fcb-42df-bf19-bb997c0281f7","errors":["CONTACT=1234 + is not valid"],"requestId":"ca19df46-23b7-4561-bbc0-fb06b314892f"}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:05 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1188574831?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 15:03:05 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 15:03:05 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249907' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '91' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538b4f01c94fee13-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188574831,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574262185087","timestamp":1574262185087,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574262185087","timestamp":1574262185087,"source":"CALCULATED","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":1574262184899,"source":"CALCULATED","sourceId":"RollupProperties","versions":[{"name":"num_associated_contacts","value":"0","timestamp":1574262184899,"sourceId":"RollupProperties","source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574262184279","timestamp":1574262184279,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574262184279","timestamp":1574262184279,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188574831","timestamp":1574262184279,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188574831","timestamp":1574262184279,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574262184279","timestamp":1574262184279,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574262184279","timestamp":1574262184279,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574262184279,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 15:03:05 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/association_spec.rb b/spec/lib/hubspot/association_spec.rb index 8b1de6f8..c1ddb9e4 100644 --- a/spec/lib/hubspot/association_spec.rb +++ b/spec/lib/hubspot/association_spec.rb @@ -2,11 +2,11 @@ before { Hubspot.configure(hapikey: 'demo') } describe '.create' do + let(:company) { create :company } + let(:contact) { create :contact } + context 'with a valid ID' do cassette - let(:company) { create :company } - let(:contact) { create :contact } - subject { described_class.create(company.id, contact.id, described_class::COMPANY_TO_CONTACT) } it 'associates the resources' do @@ -17,7 +17,6 @@ context 'with an invalid ID' do cassette - let(:company) { create :company } subject { described_class.create(company.id, 1234, described_class::COMPANY_TO_CONTACT) } it 'raises an error' do @@ -25,4 +24,47 @@ end end end + + describe '.batch_create' do + let(:portal_id) { 62515 } + let(:company) { create :company } + let(:contact) { create :contact } + let(:deal) { Hubspot::Deal.create!(portal_id, [], [], {}) } + + subject { described_class.batch_create(associations) } + + context 'with a valid request' do + cassette + let(:associations) do + [ + { from_id: deal.deal_id, to_id: contact.id, definition_id: described_class::DEAL_TO_CONTACT }, + { from_id: deal.deal_id, to_id: company.id, definition_id: described_class::DEAL_TO_COMPANY } + ] + end + + it 'associates the resources' do + expect(subject).to be true + find_deal = Hubspot::Deal.find(deal.deal_id) + expect(find_deal.vids).to eq [contact.id] + expect(find_deal.company_ids).to eq [company.id] + end + end + + context 'with an invalid ID' do + cassette + let(:associations) do + [ + { from_id: deal.deal_id, to_id: 1234, definition_id: described_class::DEAL_TO_CONTACT }, + { from_id: deal.deal_id, to_id: company.id, definition_id: described_class::DEAL_TO_COMPANY } + ] + end + + it 'raises an error' do + expect { subject }.to raise_error(Hubspot::RequestError, /One or more associations are invalid/) + find_deal = Hubspot::Deal.find(deal.deal_id) + expect(find_deal.vids).to eq [] + expect(find_deal.company_ids).to eq [] + end + end + end end From d5f20d223105776a18026f9121a40478cc075d8a Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 17:51:32 +0100 Subject: [PATCH 04/10] Add association.delete specs --- lib/hubspot/association.rb | 4 +- ...alid_request_dissociates_the_resources.yml | 298 ++++++++++++++++++ ...n_error_removes_the_valid_associations.yml | 298 ++++++++++++++++++ ...h_a_valid_ID_dissociates_the_resources.yml | 294 +++++++++++++++++ ..._an_invalid_ID_does_not_raise_an_error.yml | 294 +++++++++++++++++ spec/lib/hubspot/association_spec.rb | 75 ++++- 6 files changed, 1255 insertions(+), 8 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_a_valid_request_dissociates_the_resources.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_an_invalid_ID_does_not_raise_an_error_removes_the_valid_associations.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_a_valid_ID_dissociates_the_resources.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_an_invalid_ID_does_not_raise_an_error.yml diff --git a/lib/hubspot/association.rb b/lib/hubspot/association.rb index d1392c4b..5cbb8950 100644 --- a/lib/hubspot/association.rb +++ b/lib/hubspot/association.rb @@ -17,12 +17,12 @@ def batch_create(associations) end def delete(from_id, to_id, definition_id) - batch_create([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) + batch_delete([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) end def batch_delete(associations) request = associations.map { |assocation| build_association_body(assocation) } - Hubspot::Connection.put_json(BATCH_CREATE_PATH, params: { no_parse: true }, body: request).success? + Hubspot::Connection.put_json(BATCH_DELETE_PATH, params: { no_parse: true }, body: request).success? end private diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_a_valid_request_dissociates_the_resources.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_a_valid_request_dissociates_the_resources.yml new file mode 100644 index 00000000..292b87e7 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_a_valid_request_dissociates_the_resources.yml @@ -0,0 +1,298 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Kling, Steuber and Ruecker"},{"name":"domain","value":"reichert.info"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:45 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:45 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249699' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '89' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc9beb90cdaf-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2606296440,"isDeleted":false,"properties":{"website":{"value":"reichert.info","timestamp":1574267985337,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"reichert.info","timestamp":1574267985337,"source":"CALCULATED","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]},"hs_lastmodifieddate":{"value":"1574267985337","timestamp":1574267985337,"source":"CALCULATED","sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","versions":[{"name":"hs_lastmodifieddate","value":"1574267985337","timestamp":1574267985337,"sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","source":"CALCULATED","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]},"domain":{"value":"reichert.info","timestamp":1574267985337,"source":"API","sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","versions":[{"name":"domain","value":"reichert.info","timestamp":1574267985337,"sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","source":"API","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]},"hs_object_id":{"value":"2606296440","timestamp":1574267985337,"source":"API","sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","versions":[{"name":"hs_object_id","value":"2606296440","timestamp":1574267985337,"sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","source":"API","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]},"name":{"value":"Kling, + Steuber and Ruecker","timestamp":1574267985337,"source":"API","sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","versions":[{"name":"name","value":"Kling, + Steuber and Ruecker","timestamp":1574267985337,"sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","source":"API","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]},"createdate":{"value":"1574267985337","timestamp":1574267985337,"source":"API","sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","versions":[{"name":"createdate","value":"1574267985337","timestamp":1574267985337,"sourceId":"baebfb5b-8884-4485-8708-9e69f4bb1416","source":"API","sourceVid":[],"requestId":"baebfb5b-8884-4485-8708-9e69f4bb1416"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:45 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Jordan"},{"property":"lastname","value":"Gislason"},{"property":"email","value":"luke@example.org"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:46 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:45 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249698' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '88' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc9faa69edd7-CDG + body: + encoding: UTF-8 + string: '{"vid":73301,"canonical-vid":73301,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mM27UsZLz60iqVxQtqWvIqIz5L4hc5OfFfNqAelL4hfko5c0Il5qYsVO9A5LNMTUDxNKznGmpdB2XBdN040mT0g3GYAQO12jU1mejCgXGCIp_eeLsD3fRJLKvy4fIEP1hIYbt52","profile-url":"https://app.hubspot.com/contacts/62515/contact/73301","properties":{"firstname":{"value":"Jordan","versions":[{"value":"Jordan","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267985965,"selected":false}]},"email":{"value":"luke@example.org","versions":[{"value":"luke@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267985965,"selected":false}]},"lastname":{"value":"Gislason","versions":[{"value":"Gislason","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267985965,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73301,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"luke@example.org","timestamp":1574267985975,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"4ca18567-e332-4045-a3a3-c000db0c9a86","timestamp":1574267985995,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:46 GMT +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[2606296440],"associatedVids":[73301]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:46 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:46 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249697' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '87' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdca298bdee89-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188816841,"isDeleted":false,"associations":{"associatedVids":[73301],"associatedCompanyIds":[2606296440],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574267986411","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574267986411","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574267986411","timestamp":1574267986411,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574267986411","timestamp":1574267986411,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188816841","timestamp":1574267986411,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188816841","timestamp":1574267986411,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574267986411","timestamp":1574267986411,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574267986411","timestamp":1574267986411,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:46 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1188816841,"toObjectId":73301,"category":"HUBSPOT_DEFINED","definitionId":3},{"fromObjectId":1188816841,"toObjectId":2606296440,"category":"HUBSPOT_DEFINED","definitionId":5}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:46 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:46 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249696' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '86' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdca4fa62ee6d-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:46 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1188816841?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:47 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:46 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249695' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '85' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdca66be1a8a9-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188816841,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574267986411","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574267986411","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574267986411","timestamp":1574267986411,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574267986411","timestamp":1574267986411,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188816841","timestamp":1574267986411,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188816841","timestamp":1574267986411,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574267986411","timestamp":1574267986411,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574267986411","timestamp":1574267986411,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574267986411,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:47 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_an_invalid_ID_does_not_raise_an_error_removes_the_valid_associations.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_an_invalid_ID_does_not_raise_an_error_removes_the_valid_associations.yml new file mode 100644 index 00000000..7ca6869c --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_batch_delete_with_an_invalid_ID_does_not_raise_an_error_removes_the_valid_associations.yml @@ -0,0 +1,298 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Swift, Kirlin and Schoen"},{"name":"domain","value":"hammes.org"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:47 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:47 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249694' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '84' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdca7a935b7ab-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2606282040,"isDeleted":false,"properties":{"website":{"value":"hammes.org","timestamp":1574267987219,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"hammes.org","timestamp":1574267987219,"source":"CALCULATED","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]},"hs_lastmodifieddate":{"value":"1574267987219","timestamp":1574267987219,"source":"CALCULATED","sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","versions":[{"name":"hs_lastmodifieddate","value":"1574267987219","timestamp":1574267987219,"sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","source":"CALCULATED","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]},"domain":{"value":"hammes.org","timestamp":1574267987219,"source":"API","sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","versions":[{"name":"domain","value":"hammes.org","timestamp":1574267987219,"sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","source":"API","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]},"hs_object_id":{"value":"2606282040","timestamp":1574267987219,"source":"API","sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","versions":[{"name":"hs_object_id","value":"2606282040","timestamp":1574267987219,"sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","source":"API","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]},"name":{"value":"Swift, + Kirlin and Schoen","timestamp":1574267987219,"source":"API","sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","versions":[{"name":"name","value":"Swift, + Kirlin and Schoen","timestamp":1574267987219,"sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","source":"API","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]},"createdate":{"value":"1574267987219","timestamp":1574267987219,"source":"API","sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","versions":[{"name":"createdate","value":"1574267987219","timestamp":1574267987219,"sourceId":"c6ea7765-01f7-4f90-946e-861f19840f76","source":"API","sourceVid":[],"requestId":"c6ea7765-01f7-4f90-946e-861f19840f76"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:47 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Buck"},{"property":"lastname","value":"Haley"},{"property":"email","value":"cole@example.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:47 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:47 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249693' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '83' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdcaa0be3cde3-CDG + body: + encoding: UTF-8 + string: '{"vid":73351,"canonical-vid":73351,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mNX7E6s7Hhk74vtYbEO5_hVexUvMIOu0JA3aekLC4Koti0rvSRBwq4lwPBuXfp1IrgHh9v8tRh2i6Ykx5sucMXc4Z83OaLScJSxMsDSTU2hMNhnyOI52ZPoetnpS_BkkEAIDGRT","profile-url":"https://app.hubspot.com/contacts/62515/contact/73351","properties":{"firstname":{"value":"Buck","versions":[{"value":"Buck","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267987639,"selected":false}]},"email":{"value":"cole@example.net","versions":[{"value":"cole@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267987639,"selected":false}]},"lastname":{"value":"Haley","versions":[{"value":"Haley","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267987639,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73351,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"cole@example.net","timestamp":1574267987646,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"80ea1486-2c9b-4dcf-b711-0bc51fd81f95","timestamp":1574267987660,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:48 GMT +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[2606282040],"associatedVids":[73351]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:48 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:48 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249692' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '82' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdcae1bbe3bd9-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188816845,"isDeleted":false,"associations":{"associatedVids":[73351],"associatedCompanyIds":[2606282040],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574267988266","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574267988266","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574267988266","timestamp":1574267988266,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574267988266","timestamp":1574267988266,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188816845","timestamp":1574267988266,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188816845","timestamp":1574267988266,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574267988266","timestamp":1574267988266,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574267988266","timestamp":1574267988266,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:48 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1188816845,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":3},{"fromObjectId":1188816845,"toObjectId":2606282040,"category":"HUBSPOT_DEFINED","definitionId":5}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:48 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:48 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249691' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '81' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdcb0dd49b7cf-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:48 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1188816845?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:48 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:48 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249690' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '80' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdcb25ea23bd9-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1188816845,"isDeleted":false,"associations":{"associatedVids":[73351],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574267988266","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574267988266","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574267988266","timestamp":1574267988266,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574267988266","timestamp":1574267988266,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1188816845","timestamp":1574267988266,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1188816845","timestamp":1574267988266,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574267988266","timestamp":1574267988266,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574267988266","timestamp":1574267988266,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574267988266,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:48 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_a_valid_ID_dissociates_the_resources.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_a_valid_ID_dissociates_the_resources.yml new file mode 100644 index 00000000..b856c9f3 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_a_valid_ID_dissociates_the_resources.yml @@ -0,0 +1,294 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Wiza and Sons"},{"name":"domain","value":"leffler.biz"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:42 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:42 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249709' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc87c955ee6d-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2606285845,"isDeleted":false,"properties":{"website":{"value":"leffler.biz","timestamp":1574267982114,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"leffler.biz","timestamp":1574267982114,"source":"CALCULATED","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]},"hs_lastmodifieddate":{"value":"1574267982114","timestamp":1574267982114,"source":"CALCULATED","sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","versions":[{"name":"hs_lastmodifieddate","value":"1574267982114","timestamp":1574267982114,"sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","source":"CALCULATED","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]},"domain":{"value":"leffler.biz","timestamp":1574267982114,"source":"API","sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","versions":[{"name":"domain","value":"leffler.biz","timestamp":1574267982114,"sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","source":"API","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]},"hs_object_id":{"value":"2606285845","timestamp":1574267982114,"source":"API","sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","versions":[{"name":"hs_object_id","value":"2606285845","timestamp":1574267982114,"sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","source":"API","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]},"name":{"value":"Wiza + and Sons","timestamp":1574267982114,"source":"API","sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","versions":[{"name":"name","value":"Wiza + and Sons","timestamp":1574267982114,"sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","source":"API","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]},"createdate":{"value":"1574267982114","timestamp":1574267982114,"source":"API","sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","versions":[{"name":"createdate","value":"1574267982114","timestamp":1574267982114,"sourceId":"6258d60f-b384-42c0-a552-4c52267d28b2","source":"API","sourceVid":[],"requestId":"6258d60f-b384-42c0-a552-4c52267d28b2"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:42 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Cyril"},{"property":"lastname","value":"Medhurst"},{"property":"email","value":"edmundo@example.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:42 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:42 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249708' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc8a3f9ab763-CDG + body: + encoding: UTF-8 + string: '{"vid":73201,"canonical-vid":73201,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMCeHwtVFeiNoigFoGMKH3Z4Wxnpj4gRj_-fuvz8LnTwQKABgWXbcBVSfB_xetMydtGDS0pnqzkY41-IFg8rJerYOD8mHitdhfZh3_SOos9KrLmqF01n_KG5s3KuSAjFFqJY9P2","profile-url":"https://app.hubspot.com/contacts/62515/contact/73201","properties":{"firstname":{"value":"Cyril","versions":[{"value":"Cyril","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267982510,"selected":false}]},"email":{"value":"edmundo@example.net","versions":[{"value":"edmundo@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267982510,"selected":false}]},"lastname":{"value":"Medhurst","versions":[{"value":"Medhurst","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267982510,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73201,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"edmundo@example.net","timestamp":1574267982517,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"9ea42094-3a41-4c10-8fd0-cee84b9005a9","timestamp":1574267982546,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:42 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2606285845,"toObjectId":73201,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:43 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:42 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249707' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc8cbdfeee0f-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:43 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2606285845,"toObjectId":73201,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:43 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:43 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249706' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc8e2a31ee89-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:43 GMT +- request: + method: get + uri: https://api.hubapi.com/companies/v2/companies/2606285845/vids?count=25&hapikey=demo&vidOffset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:43 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '41' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:43 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249705' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc905f81ede3-CDG + body: + encoding: UTF-8 + string: '{"vids":[],"vidOffset":0,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:43 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_an_invalid_ID_does_not_raise_an_error.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_an_invalid_ID_does_not_raise_an_error.yml new file mode 100644 index 00000000..fbf227d4 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_delete_with_an_invalid_ID_does_not_raise_an_error.yml @@ -0,0 +1,294 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Bernier, Bosco and Rutherford"},{"name":"domain","value":"mullercremin.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:43 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:43 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249704' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc91adc4ee0f-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2606292810,"isDeleted":false,"properties":{"website":{"value":"mullercremin.com","timestamp":1574267983699,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"mullercremin.com","timestamp":1574267983699,"source":"CALCULATED","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]},"hs_lastmodifieddate":{"value":"1574267983699","timestamp":1574267983699,"source":"CALCULATED","sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","versions":[{"name":"hs_lastmodifieddate","value":"1574267983699","timestamp":1574267983699,"sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","source":"CALCULATED","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]},"domain":{"value":"mullercremin.com","timestamp":1574267983699,"source":"API","sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","versions":[{"name":"domain","value":"mullercremin.com","timestamp":1574267983699,"sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","source":"API","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]},"hs_object_id":{"value":"2606292810","timestamp":1574267983699,"source":"API","sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","versions":[{"name":"hs_object_id","value":"2606292810","timestamp":1574267983699,"sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","source":"API","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]},"name":{"value":"Bernier, + Bosco and Rutherford","timestamp":1574267983699,"source":"API","sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","versions":[{"name":"name","value":"Bernier, + Bosco and Rutherford","timestamp":1574267983699,"sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","source":"API","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]},"createdate":{"value":"1574267983699","timestamp":1574267983699,"source":"API","sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","versions":[{"name":"createdate","value":"1574267983699","timestamp":1574267983699,"sourceId":"9e474cae-66fa-4991-bebb-c22463caeeb8","source":"API","sourceVid":[],"requestId":"9e474cae-66fa-4991-bebb-c22463caeeb8"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:43 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Debbra"},{"property":"lastname","value":"Bruen"},{"property":"email","value":"romeo_kshlerin@example.net"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:44 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:43 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249703' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '93' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc93cdd6cd9b-CDG + body: + encoding: UTF-8 + string: '{"vid":73251,"canonical-vid":73251,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPGJ5W2_Vc17OjwGWP5IthuuoW-WbIQ-4bMOWmFHUjvdjwULnVP3behZ9-ZDVdqVMbszeiulS_NbuZeY0gXCqSuY5--a-_ARb7DoBKmTnJNKUyz8LzJXsBmZcAGkwFG5AomvKF-","profile-url":"https://app.hubspot.com/contacts/62515/contact/73251","properties":{"firstname":{"value":"Debbra","versions":[{"value":"Debbra","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267984036,"selected":false}]},"email":{"value":"romeo_kshlerin@example.net","versions":[{"value":"romeo_kshlerin@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267984036,"selected":false}]},"lastname":{"value":"Bruen","versions":[{"value":"Bruen","source-type":"API","source-id":null,"source-label":null,"timestamp":1574267984036,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73251,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"romeo_kshlerin@example.net","timestamp":1574267984045,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"bf4b965d-6f4d-4989-825a-fa0ae24b86c9","timestamp":1574267984068,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:44 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2606292810,"toObjectId":73251,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:44 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:44 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249702' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '92' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc967da3edd7-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:44 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2606292810,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 16:39:45 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:44 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249701' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '91' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc995a8cee13-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:45 GMT +- request: + method: get + uri: https://api.hubapi.com/companies/v2/companies/2606292810/vids?count=25&hapikey=demo&vidOffset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 16:39:45 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '50' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 16:39:45 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249700' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '90' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538bdc9a7b48ee6d-CDG + body: + encoding: UTF-8 + string: '{"vids":[73251],"vidOffset":73251,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 16:39:45 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/association_spec.rb b/spec/lib/hubspot/association_spec.rb index c1ddb9e4..5d17d5de 100644 --- a/spec/lib/hubspot/association_spec.rb +++ b/spec/lib/hubspot/association_spec.rb @@ -1,10 +1,11 @@ RSpec.describe Hubspot::Association do before { Hubspot.configure(hapikey: 'demo') } - describe '.create' do - let(:company) { create :company } - let(:contact) { create :contact } + let(:portal_id) { 62515 } + let(:company) { create :company } + let(:contact) { create :contact } + describe '.create' do context 'with a valid ID' do cassette subject { described_class.create(company.id, contact.id, described_class::COMPANY_TO_CONTACT) } @@ -26,9 +27,6 @@ end describe '.batch_create' do - let(:portal_id) { 62515 } - let(:company) { create :company } - let(:contact) { create :contact } let(:deal) { Hubspot::Deal.create!(portal_id, [], [], {}) } subject { described_class.batch_create(associations) } @@ -67,4 +65,69 @@ end end end + + describe '.delete' do + subject { described_class.delete(company.id, contact_id_to_dissociate, described_class::COMPANY_TO_CONTACT) } + before { described_class.create(company.id, contact.id, described_class::COMPANY_TO_CONTACT) } + + context 'with a valid ID' do + cassette + let(:contact_id_to_dissociate) { contact.id } + + it 'dissociates the resources' do + expect(subject).to be true + expect(company.contact_ids.resources).to eq [] + end + end + + context 'with an invalid ID' do + cassette + let(:contact_id_to_dissociate) { 1234 } + + it 'does not raise an error' do + expect(subject).to be true + expect(company.contact_ids.resources).to eq [contact.id] + end + end + end + + describe '.batch_delete' do + let(:deal) { Hubspot::Deal.create!(portal_id, [company.id], [contact.id], {}) } + + subject { described_class.batch_delete(associations) } + + context 'with a valid request' do + cassette + let(:associations) do + [ + { from_id: deal.deal_id, to_id: contact.id, definition_id: described_class::DEAL_TO_CONTACT }, + { from_id: deal.deal_id, to_id: company.id, definition_id: described_class::DEAL_TO_COMPANY } + ] + end + + it 'dissociates the resources' do + expect(subject).to be true + find_deal = Hubspot::Deal.find(deal.deal_id) + expect(find_deal.vids).to eq [] + expect(find_deal.company_ids).to eq [] + end + end + + context 'with an invalid ID' do + cassette + let(:associations) do + [ + { from_id: deal.deal_id, to_id: 1234, definition_id: described_class::DEAL_TO_CONTACT }, + { from_id: deal.deal_id, to_id: company.id, definition_id: described_class::DEAL_TO_COMPANY } + ] + end + + it 'does not raise an error, removes the valid associations' do + expect(subject).to be true + find_deal = Hubspot::Deal.find(deal.deal_id) + expect(find_deal.vids).to eq [contact.id] + expect(find_deal.company_ids).to eq [] + end + end + end end From dc9998d897eea739c08fb2135dd99bca059e038c Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 18:27:47 +0100 Subject: [PATCH 05/10] Company uses Association to associate Contact --- lib/hubspot/company.rb | 15 +- ...act_ID_adds_the_contact_to_the_company.yml | 208 +++++----- ...pany_ID_and_contact_ID_returns_success.yml | 124 +++--- ...and_invalid_contact_ID_raises_an_error.yml | 92 +++-- ..._an_invalid_company_ID_raises_an_error.yml | 50 +-- ...D_removes_the_contact_from_the_company.yml | 354 ++++++++++++++++++ ...pany_ID_and_contact_ID_returns_success.yml | 174 ++++++--- spec/lib/hubspot/company_spec.rb | 49 +-- 8 files changed, 777 insertions(+), 289 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_removes_the_contact_from_the_company.yml diff --git a/lib/hubspot/company.rb b/lib/hubspot/company.rb index 8f6e2d77..2fa14392 100644 --- a/lib/hubspot/company.rb +++ b/lib/hubspot/company.rb @@ -2,7 +2,6 @@ class Hubspot::Company < Hubspot::Resource self.id_field = "companyId" self.property_name_field = "name" - ADD_CONTACT_PATH = '/companies/v2/companies/:id/contacts/:contact_id' ALL_PATH = '/companies/v2/companies/paged' BATCH_UPDATE_PATH = '/companies/v1/batch-async/update' CONTACTS_PATH = '/companies/v2/companies/:id/contacts' @@ -12,7 +11,6 @@ class Hubspot::Company < Hubspot::Resource FIND_PATH = '/companies/v2/companies/:id' RECENTLY_CREATED_PATH = '/companies/v2/companies/recent/created' RECENTLY_MODIFIED_PATH = '/companies/v2/companies/recent/modified' - REMOVE_CONTACT_PATH = '/companies/v2/companies/:id/contacts/:contact_id' SEARCH_DOMAIN_PATH = '/companies/v2/domains/:domain/companies' UPDATE_PATH = '/companies/v2/companies/:id' @@ -80,20 +78,11 @@ def recently_modified(opts = {}) end def add_contact(id, contact_id) - Hubspot::Connection.put_json( - ADD_CONTACT_PATH, - params: { id: id, contact_id: contact_id } - ) - true + Hubspot::Association.create(id, contact_id, Hubspot::Association::COMPANY_TO_CONTACT) end def remove_contact(id, contact_id) - Hubspot::Connection.delete_json( - REMOVE_CONTACT_PATH, - { id: id, contact_id: contact_id } - ) - - true + Hubspot::Association.delete(id, contact_id, Hubspot::Association::COMPANY_TO_CONTACT) end def batch_update(companies, opts = {}) diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_adds_the_contact_to_the_company.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_adds_the_contact_to_the_company.yml index 9f2db89f..4164fa28 100644 --- a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_adds_the_contact_to_the_company.yml +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_adds_the_contact_to_the_company.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.hubapi.com/contacts/v1/contact?hapikey= + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"property":"firstname","value":"Korey"},{"property":"lastname","value":"Hauck"},{"property":"email","value":"81058wmml@example.org"}]}' + string: '{"properties":[{"property":"firstname","value":"Angele"},{"property":"lastname","value":"McClure"},{"property":"email","value":"kermit@example.com"}]}' headers: Content-Type: - application/json @@ -15,7 +15,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:18 GMT + - Wed, 20 Nov 2019 17:05:10 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -23,23 +23,31 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d9f76a8faa23da54fbc2e1dee0445a3ba1556981058; expires=Sun, 03-May-20 - 14:44:18 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:10 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B61EB4DDB3C5887D91ABB6AAD9B47FC5F8139B25B000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979510' + - '249635' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '58' + - '9' Vary: - Accept-Encoding - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -47,18 +55,18 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b4080db79c1bb-IAD + - 538c01d75c196954-CDG body: encoding: UTF-8 - string: '{"vid":12052874,"canonical-vid":12052874,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPoH_CoMSQdN7dCSKUkZE-BZW6FuLPPBCFrmVGGZJK1D1wg1bzlnWbMsJxZq0axaMnwDSqeTiGLJFc4OTeofl5TQt82YWnQptSXKx2n_yiOVTiimWrrhib45phlEzMaFDChWGY3","profile-url":"https://app.hubspot.com/contacts/62515/contact/12052874","properties":{"firstname":{"value":"Korey","versions":[{"value":"Korey","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981058742,"selected":false}]},"email":{"value":"81058wmml@example.org","versions":[{"value":"81058wmml@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981058742,"selected":false}]},"lastname":{"value":"Hauck","versions":[{"value":"Hauck","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981058742,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":12052874,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"81058wmml@example.org","timestamp":1556981058748,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"96e47943-bcdc-457a-927e-df70da8b7993","timestamp":1556981058759,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:19 GMT + string: '{"vid":73651,"canonical-vid":73651,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mM4DNo6ukkMDq03UVBhud8q2MpD9nlsmI3LTvfaopZvOVkGKZ1tlJpQ5FECIquMWlcBRoJita2R56T8CJUomsIGKQTd4buy8_ovV-b9HqDFpdVdCeIfC35OyzcZerDtu7h4i_xP","profile-url":"https://app.hubspot.com/contacts/62515/contact/73651","properties":{"firstname":{"value":"Angele","versions":[{"value":"Angele","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269510363,"selected":false}]},"email":{"value":"kermit@example.com","versions":[{"value":"kermit@example.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269510363,"selected":false}]},"lastname":{"value":"McClure","versions":[{"value":"McClure","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269510363,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73651,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"kermit@example.com","timestamp":1574269510372,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"38878ef1-df92-4c8c-9fe4-8fe7d7a28fe1","timestamp":1574269510397,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:10 GMT - request: method: post - uri: https://api.hubapi.com/companies/v2/companies/?hapikey= + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"name":"name","value":"Dietrich, Hackett and Metz"},{"name":"domain","value":"krajcik.info"}]}' + string: '{"properties":[{"name":"name","value":"Kub and Sons"},{"name":"domain","value":"marvinstark.io"}]}' headers: Content-Type: - application/json @@ -68,7 +76,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:19 GMT + - Wed, 20 Nov 2019 17:05:10 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -76,20 +84,30 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d22178fdbdc6415dcc78c7b5b5fb5a2a41556981059; expires=Sun, 03-May-20 - 14:44:19 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:10 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B846EAC873021072E679859F4A0B23298C04D65F1000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979509' + - '249634' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '59' + - '9' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -97,17 +115,17 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b4083fba7956c-IAD + - 538c01d9eeb1bd5e-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1897447169,"isDeleted":false,"properties":{"website":{"value":"krajcik.info","timestamp":1556981059222,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"krajcik.info","timestamp":1556981059222,"source":"CALCULATED","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"hs_lastmodifieddate":{"value":"1556981059222","timestamp":1556981059222,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981059222","timestamp":1556981059222,"source":"CALCULATED","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"domain":{"value":"krajcik.info","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"krajcik.info","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"name":{"value":"Dietrich, - Hackett and Metz","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Dietrich, - Hackett and Metz","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"createdate":{"value":"1556981059222","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981059222","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"},{"name":"createdate","value":"1556981059222","timestamp":1556981059222,"sourceId":"API","source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:19 GMT + string: '{"portalId":62515,"companyId":2606350537,"isDeleted":false,"properties":{"website":{"value":"marvinstark.io","timestamp":1574269510780,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"marvinstark.io","timestamp":1574269510780,"source":"CALCULATED","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]},"hs_lastmodifieddate":{"value":"1574269510780","timestamp":1574269510780,"source":"CALCULATED","sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","versions":[{"name":"hs_lastmodifieddate","value":"1574269510780","timestamp":1574269510780,"sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","source":"CALCULATED","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]},"domain":{"value":"marvinstark.io","timestamp":1574269510780,"source":"API","sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","versions":[{"name":"domain","value":"marvinstark.io","timestamp":1574269510780,"sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","source":"API","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]},"hs_object_id":{"value":"2606350537","timestamp":1574269510780,"source":"API","sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","versions":[{"name":"hs_object_id","value":"2606350537","timestamp":1574269510780,"sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","source":"API","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]},"name":{"value":"Kub + and Sons","timestamp":1574269510780,"source":"API","sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","versions":[{"name":"name","value":"Kub + and Sons","timestamp":1574269510780,"sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","source":"API","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]},"createdate":{"value":"1574269510780","timestamp":1574269510780,"source":"API","sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","versions":[{"name":"createdate","value":"1574269510780","timestamp":1574269510780,"sourceId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b","source":"API","sourceVid":[],"requestId":"6cbef193-69b0-4643-a00d-8a1c0dff9b5b"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:10 GMT - request: method: get - uri: https://api.hubapi.com/companies/v2/companies/1897447169/vids?count=25&hapikey=&vidOffset= + uri: https://api.hubapi.com/companies/v2/companies/2606350537/vids?count=25&hapikey=demo&vidOffset= body: encoding: US-ASCII string: '' @@ -118,30 +136,40 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:19 GMT + - Wed, 20 Nov 2019 17:05:11 GMT Content-Type: - application/json;charset=utf-8 - Transfer-Encoding: - - chunked + Content-Length: + - '41' Connection: - keep-alive Set-Cookie: - - __cfduid=d305087d9fc8fd0860587eb9b3bbcd2a31556981059; expires=Sun, 03-May-20 - 14:44:19 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:11 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B0496D14143A666F85D074C17921DBC98D64B9998000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979508' + - '249633' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '58' + - '9' Vary: - - Accept-Encoding, User-Agent + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -149,49 +177,53 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b40856fd2cf5c-IAD + - 538c01dc2d46cd7b-CDG body: encoding: UTF-8 string: '{"vids":[],"vidOffset":0,"hasMore":false}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:20 GMT + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:11 GMT - request: method: put - uri: https://api.hubapi.com/companies/v2/companies/1897447169/contacts/12052874?hapikey= + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo body: encoding: UTF-8 - string: 'null' + string: '[{"fromObjectId":2606350537,"toObjectId":73651,"category":"HUBSPOT_DEFINED","definitionId":2}]' headers: Content-Type: - application/json response: status: - code: 200 - message: OK + code: 204 + message: No Content headers: Date: - - Sat, 04 May 2019 14:44:20 GMT - Content-Type: - - application/json;charset=utf-8 - Transfer-Encoding: - - chunked + - Wed, 20 Nov 2019 17:05:11 GMT Connection: - keep-alive Set-Cookie: - - __cfduid=d834cf0b2f9ae148479fff78cb59f1a311556981060; expires=Sun, 03-May-20 - 14:44:20 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:11 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B4253E135FEA260CC808FFFE0E5D51092239637FF000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979507' + - '249632' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '93' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '59' + - '9' Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -199,17 +231,15 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b408a1be0cf4c-IAD + - 538c01dd6de0b7c3-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1897447169,"isDeleted":false,"properties":{"website":{"value":"krajcik.info","timestamp":1556981059222,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"krajcik.info","timestamp":1556981059222,"source":"CALCULATED","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"hs_lastmodifieddate":{"value":"1556981059222","timestamp":1556981059222,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981059222","timestamp":1556981059222,"source":"CALCULATED","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"domain":{"value":"krajcik.info","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"krajcik.info","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"name":{"value":"Dietrich, - Hackett and Metz","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Dietrich, - Hackett and Metz","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]},"createdate":{"value":"1556981059222","timestamp":1556981059222,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981059222","timestamp":1556981059222,"source":"API","sourceVid":[],"requestId":"e7fe7c6d-f370-47f5-a995-ad735c8111a9"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:20 GMT + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:11 GMT - request: method: get - uri: https://api.hubapi.com/companies/v2/companies/1897447169/vids?count=25&hapikey=&vidOffset= + uri: https://api.hubapi.com/companies/v2/companies/2606350537/vids?count=25&hapikey=demo&vidOffset= body: encoding: US-ASCII string: '' @@ -220,30 +250,40 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:20 GMT + - Wed, 20 Nov 2019 17:05:11 GMT Content-Type: - application/json;charset=utf-8 - Transfer-Encoding: - - chunked + Content-Length: + - '50' Connection: - keep-alive Set-Cookie: - - __cfduid=dbbfec84576da4fafb3a3b440441c5a461556981060; expires=Sun, 03-May-20 - 14:44:20 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:11 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B3E13C64F71CCCBBEF6D3C2655F9E1A8A9371D3E1000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979505' + - '249631' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '92' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '57' + - '9' Vary: - - Accept-Encoding, User-Agent + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -251,10 +291,10 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b408b9bb6cee0-IAD + - 538c01dfecd5ee60-CDG body: encoding: UTF-8 - string: '{"vids":[12052874],"vidOffset":12052874,"hasMore":false}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:20 GMT -recorded_with: VCR 4.0.0 + string: '{"vids":[73651],"vidOffset":73651,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:11 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml index 6b11af00..8f3eaf2f 100644 --- a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.hubapi.com/companies/v2/companies/?hapikey= + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"name":"name","value":"Conroy, Kiehn and Gleason"},{"name":"domain","value":"yostbartell.net"}]}' + string: '{"properties":[{"name":"name","value":"Buckridge-Steuber"},{"name":"domain","value":"barrows.info"}]}' headers: Content-Type: - application/json @@ -15,7 +15,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:17 GMT + - Wed, 20 Nov 2019 17:05:09 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -23,20 +23,30 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=da5ff40409e7e4ef824d9bee575c5df131556981057; expires=Sun, 03-May-20 - 14:44:17 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:09 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B653FAA0D7F299502807C51ABABCA5708A32B9CBD000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979513' + - '249638' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '58' + - '9' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -44,20 +54,18 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b40799a59cec0-IAD + - 538c01cf58abee13-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1897515216,"isDeleted":false,"properties":{"website":{"value":"yostbartell.net","timestamp":1556981057563,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"yostbartell.net","timestamp":1556981057563,"source":"CALCULATED","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"hs_lastmodifieddate":{"value":"1556981057563","timestamp":1556981057563,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981057563","timestamp":1556981057563,"source":"CALCULATED","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"domain":{"value":"yostbartell.net","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"yostbartell.net","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"name":{"value":"Conroy, - Kiehn and Gleason","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Conroy, - Kiehn and Gleason","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"createdate":{"value":"1556981057563","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981057563","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"},{"name":"createdate","value":"1556981057563","timestamp":1556981057563,"sourceId":"API","source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:17 GMT + string: '{"portalId":62515,"companyId":2606347890,"isDeleted":false,"properties":{"website":{"value":"barrows.info","timestamp":1574269509097,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"barrows.info","timestamp":1574269509097,"source":"CALCULATED","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]},"hs_lastmodifieddate":{"value":"1574269509097","timestamp":1574269509097,"source":"CALCULATED","sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","versions":[{"name":"hs_lastmodifieddate","value":"1574269509097","timestamp":1574269509097,"sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","source":"CALCULATED","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]},"domain":{"value":"barrows.info","timestamp":1574269509097,"source":"API","sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","versions":[{"name":"domain","value":"barrows.info","timestamp":1574269509097,"sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","source":"API","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]},"hs_object_id":{"value":"2606347890","timestamp":1574269509097,"source":"API","sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","versions":[{"name":"hs_object_id","value":"2606347890","timestamp":1574269509097,"sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","source":"API","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]},"name":{"value":"Buckridge-Steuber","timestamp":1574269509097,"source":"API","sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","versions":[{"name":"name","value":"Buckridge-Steuber","timestamp":1574269509097,"sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","source":"API","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]},"createdate":{"value":"1574269509097","timestamp":1574269509097,"source":"API","sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","versions":[{"name":"createdate","value":"1574269509097","timestamp":1574269509097,"sourceId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f","source":"API","sourceVid":[],"requestId":"f0a55eb7-0238-4299-b3ed-246cffe3b54f"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:09 GMT - request: method: post - uri: https://api.hubapi.com/contacts/v1/contact?hapikey= + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"property":"firstname","value":"Jeffery"},{"property":"lastname","value":"Hermiston"},{"property":"email","value":"81057rjyj@example.org"}]}' + string: '{"properties":[{"property":"firstname","value":"Edyth"},{"property":"lastname","value":"Heathcote"},{"property":"email","value":"fidelia@example.net"}]}' headers: Content-Type: - application/json @@ -67,7 +75,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:18 GMT + - Wed, 20 Nov 2019 17:05:09 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -75,23 +83,31 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d9027c19ae982b4343668c6c50edaa2601556981057; expires=Sun, 03-May-20 - 14:44:17 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:09 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B3044E8F0761161F3C3B15FA0CB8BBA643C04F985000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979512' + - '249637' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '57' + - '9' Vary: - Accept-Encoding - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -99,49 +115,53 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b407b49b2cf68-IAD + - 538c01d1cc33b7b7-CDG body: encoding: UTF-8 - string: '{"vid":12052824,"canonical-vid":12052824,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOqBB77gqiLE-3taj4nCeKoi6YCNfouVA9lG2pjtOt-jntul1By1OLaguwBK2Yt5CSaia3ofZ_2Ei0aopjat1YxRqbe1vwQK1Om9vgI8uJvF9pHi0TH7PLZQruclsYwzdiBB3Pa","profile-url":"https://app.hubspot.com/contacts/62515/contact/12052824","properties":{"firstname":{"value":"Jeffery","versions":[{"value":"Jeffery","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981057836,"selected":false}]},"email":{"value":"81057rjyj@example.org","versions":[{"value":"81057rjyj@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981057836,"selected":false}]},"lastname":{"value":"Hermiston","versions":[{"value":"Hermiston","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981057836,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":12052824,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"81057rjyj@example.org","timestamp":1556981057842,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"1d136dd8-a648-4ee6-a85c-84421dffab72","timestamp":1556981057855,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:18 GMT + string: '{"vid":73601,"canonical-vid":73601,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMvZ-Uf-cMK66IZxi2_IF6LlrbLDqBkMn012Px4DGrHBIPrtzwB4vC0Bjo0xdeXDV3Sgg9m6uFvgc3jmSoP7ueBYfv4ZYXA6ThOFByJ0HebbZNy_5gmZOzaA8ii0ux2AcUYlPOe","profile-url":"https://app.hubspot.com/contacts/62515/contact/73601","properties":{"firstname":{"value":"Edyth","versions":[{"value":"Edyth","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269509493,"selected":false}]},"email":{"value":"fidelia@example.net","versions":[{"value":"fidelia@example.net","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269509493,"selected":false}]},"lastname":{"value":"Heathcote","versions":[{"value":"Heathcote","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269509493,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73601,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"fidelia@example.net","timestamp":1574269509503,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"da36905a-af74-46b3-9406-ddfa872d5c9e","timestamp":1574269509530,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:09 GMT - request: method: put - uri: https://api.hubapi.com/companies/v2/companies/1897515216/contacts/12052824?hapikey= + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo body: encoding: UTF-8 - string: 'null' + string: '[{"fromObjectId":2606347890,"toObjectId":73601,"category":"HUBSPOT_DEFINED","definitionId":2}]' headers: Content-Type: - application/json response: status: - code: 200 - message: OK + code: 204 + message: No Content headers: Date: - - Sat, 04 May 2019 14:44:18 GMT - Content-Type: - - application/json;charset=utf-8 - Transfer-Encoding: - - chunked + - Wed, 20 Nov 2019 17:05:10 GMT Connection: - keep-alive Set-Cookie: - - __cfduid=d9eb79258840bef46611806a461fefa551556981058; expires=Sun, 03-May-20 - 14:44:18 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:10 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B87E5C2AF23C9FD8C5FE53D92F3F26EEE1B99511B000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979511' + - '249636' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '59' + - '9' Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -149,12 +169,10 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b407ebcafcf60-IAD + - 538c01d5995ccddb-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1897515216,"isDeleted":false,"properties":{"website":{"value":"yostbartell.net","timestamp":1556981057563,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"yostbartell.net","timestamp":1556981057563,"source":"CALCULATED","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"hs_lastmodifieddate":{"value":"1556981057563","timestamp":1556981057563,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981057563","timestamp":1556981057563,"source":"CALCULATED","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"domain":{"value":"yostbartell.net","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"yostbartell.net","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"name":{"value":"Conroy, - Kiehn and Gleason","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Conroy, - Kiehn and Gleason","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]},"createdate":{"value":"1556981057563","timestamp":1556981057563,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981057563","timestamp":1556981057563,"source":"API","sourceVid":[],"requestId":"ed726e97-d7d6-41f5-bffe-590b5d3f5f51"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:18 GMT -recorded_with: VCR 4.0.0 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:10 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_invalid_contact_ID_raises_an_error.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_invalid_contact_ID_raises_an_error.yml index 42824f4a..74b9c133 100644 --- a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_invalid_contact_ID_raises_an_error.yml +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_a_valid_company_ID_and_invalid_contact_ID_raises_an_error.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.hubapi.com/companies/v2/companies/?hapikey= + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"name":"name","value":"Grant LLC"},{"name":"domain","value":"botsford.net"}]}' + string: '{"properties":[{"name":"name","value":"Wolff Inc"},{"name":"domain","value":"gleichner.io"}]}' headers: Content-Type: - application/json @@ -15,7 +15,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:20 GMT + - Wed, 20 Nov 2019 17:05:12 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -23,20 +23,30 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d65fcfe478266039da7604e372615a0341556981060; expires=Sun, 03-May-20 - 14:44:20 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:11 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B5C0095B230847F2293FE4BAF6F10E24D55264125000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979503' + - '249630' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '91' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '55' + - '9' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -44,53 +54,61 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b408cff259f4c-IAD + - 538c01e12faba843-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1896332005,"isDeleted":false,"properties":{"website":{"value":"botsford.net","timestamp":1556981060664,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"botsford.net","timestamp":1556981060664,"source":"CALCULATED","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"}]},"hs_lastmodifieddate":{"value":"1556981060664","timestamp":1556981060664,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981060664","timestamp":1556981060664,"source":"CALCULATED","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"}]},"domain":{"value":"botsford.net","timestamp":1556981060664,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"botsford.net","timestamp":1556981060664,"source":"API","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"}]},"name":{"value":"Grant - LLC","timestamp":1556981060664,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Grant - LLC","timestamp":1556981060664,"source":"API","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"}]},"createdate":{"value":"1556981060664","timestamp":1556981060664,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981060664","timestamp":1556981060664,"source":"API","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"},{"name":"createdate","value":"1556981060664","timestamp":1556981060664,"sourceId":"API","source":"API","sourceVid":[],"requestId":"910dcd56-c09d-428b-a43a-8fcdbc9e95d4"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:20 GMT + string: '{"portalId":62515,"companyId":2606347900,"isDeleted":false,"properties":{"website":{"value":"gleichner.io","timestamp":1574269511942,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"gleichner.io","timestamp":1574269511942,"source":"CALCULATED","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]},"hs_lastmodifieddate":{"value":"1574269511942","timestamp":1574269511942,"source":"CALCULATED","sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","versions":[{"name":"hs_lastmodifieddate","value":"1574269511942","timestamp":1574269511942,"sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","source":"CALCULATED","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]},"domain":{"value":"gleichner.io","timestamp":1574269511942,"source":"API","sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","versions":[{"name":"domain","value":"gleichner.io","timestamp":1574269511942,"sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","source":"API","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]},"hs_object_id":{"value":"2606347900","timestamp":1574269511942,"source":"API","sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","versions":[{"name":"hs_object_id","value":"2606347900","timestamp":1574269511942,"sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","source":"API","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]},"name":{"value":"Wolff + Inc","timestamp":1574269511942,"source":"API","sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","versions":[{"name":"name","value":"Wolff + Inc","timestamp":1574269511942,"sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","source":"API","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]},"createdate":{"value":"1574269511942","timestamp":1574269511942,"source":"API","sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","versions":[{"name":"createdate","value":"1574269511942","timestamp":1574269511942,"sourceId":"167f3469-fcce-4d53-a142-7e9e041e5ccf","source":"API","sourceVid":[],"requestId":"167f3469-fcce-4d53-a142-7e9e041e5ccf"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:12 GMT - request: method: put - uri: https://api.hubapi.com/companies/v2/companies/1896332005/contacts/1?hapikey= + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo body: encoding: UTF-8 - string: 'null' + string: '[{"fromObjectId":2606347900,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":2}]' headers: Content-Type: - application/json response: status: - code: 404 - message: Not Found + code: 400 + message: Bad Request headers: Date: - - Sat, 04 May 2019 14:44:20 GMT + - Wed, 20 Nov 2019 17:05:12 GMT Content-Type: - application/json;charset=utf-8 Content-Length: - - '191' + - '212' Connection: - keep-alive Set-Cookie: - - __cfduid=dbd9e2f7f6bb0964317195fd1ce615e9f1556981060; expires=Sun, 03-May-20 - 14:44:20 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:12 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2BA5F060FD65F11C95427FE88738A7916FDEE1E05A000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979502' + - '249629' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '90' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '54' - X-Hubspot-Notfound: - - 'true' + - '9' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -98,11 +116,11 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b408e7e9dcef8-IAD + - 538c01e37891a849-CDG body: encoding: UTF-8 - string: '{"status":"error","message":"Couldn''t find a Contact with the vid - ''1'' in portal ''62515''","correlationId":"da291558-5d66-4175-8dbe-fc5e22840a8b","requestId":"491c402396a3b91ead6a4729b8d1de51"}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:20 GMT -recorded_with: VCR 4.0.0 + string: '{"status":"error","message":"One or more associations are invalid","correlationId":"922d64b6-eb37-4584-b971-4115dc8bb512","errors":["CONTACT=1234 + is not valid"],"requestId":"b5918100-1395-4f83-ab8b-ec0299ed6826"}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:12 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_an_invalid_company_ID_raises_an_error.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_an_invalid_company_ID_raises_an_error.yml index 32dbfc3c..f052e2b8 100644 --- a/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_an_invalid_company_ID_raises_an_error.yml +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_add_contact_with_an_invalid_company_ID_raises_an_error.yml @@ -2,43 +2,51 @@ http_interactions: - request: method: put - uri: https://api.hubapi.com/companies/v2/companies/1/contacts/1?hapikey= + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo body: encoding: UTF-8 - string: 'null' + string: '[{"fromObjectId":1,"toObjectId":1,"category":"HUBSPOT_DEFINED","definitionId":2}]' headers: Content-Type: - application/json response: status: - code: 404 - message: Not Found + code: 400 + message: Bad Request headers: Date: - - Sat, 04 May 2019 14:44:21 GMT + - Wed, 20 Nov 2019 17:05:12 GMT Content-Type: - application/json;charset=utf-8 Content-Length: - - '190' + - '209' Connection: - keep-alive Set-Cookie: - - __cfduid=d6990ee98a136ceae0728e218e93a53eb1556981061; expires=Sun, 03-May-20 - 14:44:21 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:12 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2BFE94E1F0F5FB0729826BCF1CFD012E79B2069A65000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979501' + - '249628' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '89' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '59' - X-Hubspot-Notfound: - - 'true' + - '8' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -46,11 +54,11 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b408fc84157c3-IAD + - 538c01e52928cdab-CDG body: encoding: UTF-8 - string: '{"status":"error","message":"Couldn''t find a company with the ID ''1'' - in portal ''62515''","correlationId":"e2fbd77d-011a-448e-b716-127c26146599","requestId":"e5f62eb2bf0bcfd004e6371b23c3130c"}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:21 GMT -recorded_with: VCR 4.0.0 + string: '{"status":"error","message":"One or more associations are invalid","correlationId":"47a734e3-78b1-44f8-916d-6f3f1116cfab","errors":["COMPANY=1 + is not valid"],"requestId":"e50ae34b-8dfe-4948-a74e-1c1e92685ede"}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:12 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_removes_the_contact_from_the_company.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_removes_the_contact_from_the_company.yml new file mode 100644 index 00000000..15d77efd --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_removes_the_contact_from_the_company.yml @@ -0,0 +1,354 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"McDermott, Hand and Kuhn"},{"name":"domain","value":"pollich.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 17:05:14 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:14 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249623' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '84' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01f24f40a879-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2605425326,"isDeleted":false,"properties":{"website":{"value":"pollich.com","timestamp":1574269514680,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"pollich.com","timestamp":1574269514680,"source":"CALCULATED","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]},"hs_lastmodifieddate":{"value":"1574269514680","timestamp":1574269514680,"source":"CALCULATED","sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","versions":[{"name":"hs_lastmodifieddate","value":"1574269514680","timestamp":1574269514680,"sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","source":"CALCULATED","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]},"domain":{"value":"pollich.com","timestamp":1574269514680,"source":"API","sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","versions":[{"name":"domain","value":"pollich.com","timestamp":1574269514680,"sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","source":"API","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]},"hs_object_id":{"value":"2605425326","timestamp":1574269514680,"source":"API","sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","versions":[{"name":"hs_object_id","value":"2605425326","timestamp":1574269514680,"sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","source":"API","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]},"name":{"value":"McDermott, + Hand and Kuhn","timestamp":1574269514680,"source":"API","sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","versions":[{"name":"name","value":"McDermott, + Hand and Kuhn","timestamp":1574269514680,"sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","source":"API","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]},"createdate":{"value":"1574269514680","timestamp":1574269514680,"source":"API","sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","versions":[{"name":"createdate","value":"1574269514680","timestamp":1574269514680,"sourceId":"f7a97965-dd1d-4395-a39e-daad09534754","source":"API","sourceVid":[],"requestId":"f7a97965-dd1d-4395-a39e-daad09534754"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:14 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Florencio"},{"property":"lastname","value":"Beatty"},{"property":"email","value":"luigi_johnston@example.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 17:05:15 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:14 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249622' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '83' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01f409faee50-CDG + body: + encoding: UTF-8 + string: '{"vid":73751,"canonical-vid":73751,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mO3RUNa_zh6VDps-lNLEymNXdb82MQ_UitazNIMKqFl2U4FOd3p5gMoCO90ib2oC8ZTVkjvVSSCOLERYyWabTCyCT5ClaAOVO4obRbsZF0RGhfOHUVrS1wh7h6-cLJsTMR6p4h6","profile-url":"https://app.hubspot.com/contacts/62515/contact/73751","properties":{"firstname":{"value":"Florencio","versions":[{"value":"Florencio","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269514965,"selected":false}]},"email":{"value":"luigi_johnston@example.com","versions":[{"value":"luigi_johnston@example.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269514965,"selected":false}]},"lastname":{"value":"Beatty","versions":[{"value":"Beatty","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269514965,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73751,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"luigi_johnston@example.com","timestamp":1574269514973,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"52e19bfd-db6b-4862-a147-18499d9b4625","timestamp":1574269514987,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:15 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2605425326,"toObjectId":73751,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 17:05:15 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:15 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249621' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '82' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01f6fa1dedaf-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:15 GMT +- request: + method: get + uri: https://api.hubapi.com/companies/v2/companies/2605425326/vids?count=25&hapikey=demo&vidOffset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 17:05:15 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '50' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:15 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249620' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '81' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01f97facee44-CDG + body: + encoding: UTF-8 + string: '{"vids":[73751],"vidOffset":73751,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:15 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2605425326,"toObjectId":73751,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 17:05:16 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:15 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249619' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '80' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01faa84bee60-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:16 GMT +- request: + method: get + uri: https://api.hubapi.com/companies/v2/companies/2605425326/vids?count=25&hapikey=demo&vidOffset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 20 Nov 2019 17:05:16 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '41' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:16 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249618' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '79' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '7' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01fd7c8bcd93-CDG + body: + encoding: UTF-8 + string: '{"vids":[],"vidOffset":0,"hasMore":false}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:16 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml b/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml index 22744cf9..501458c7 100644 --- a/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml +++ b/spec/fixtures/vcr_cassettes/Hubspot_Company_remove_contact_with_a_valid_company_ID_and_contact_ID_returns_success.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.hubapi.com/companies/v2/companies/?hapikey= + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"name":"name","value":"Homenick, Zulauf and Orn"},{"name":"domain","value":"cartwright.io"}]}' + string: '{"properties":[{"name":"name","value":"Dicki-McKenzie"},{"name":"domain","value":"walker.org"}]}' headers: Content-Type: - application/json @@ -15,7 +15,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:21 GMT + - Wed, 20 Nov 2019 17:05:13 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -23,20 +23,30 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d28da2105eccb987bc7146f9117446a0a1556981061; expires=Sun, 03-May-20 - 14:44:21 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:12 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B68656FBE73E150C06FEA52F53E9665B60507FA60000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979500' + - '249627' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '88' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '58' + - '8' + Vary: + - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -44,20 +54,18 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b4090faabc16b-IAD + - 538c01e7da42ede7-CDG body: encoding: UTF-8 - string: '{"portalId":62515,"companyId":1897447170,"isDeleted":false,"properties":{"website":{"value":"cartwright.io","timestamp":1556981061313,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"cartwright.io","timestamp":1556981061313,"source":"CALCULATED","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"}]},"hs_lastmodifieddate":{"value":"1556981061313","timestamp":1556981061313,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1556981061313","timestamp":1556981061313,"source":"CALCULATED","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"}]},"domain":{"value":"cartwright.io","timestamp":1556981061313,"source":"API","sourceId":null,"versions":[{"name":"domain","value":"cartwright.io","timestamp":1556981061313,"source":"API","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"}]},"name":{"value":"Homenick, - Zulauf and Orn","timestamp":1556981061313,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Homenick, - Zulauf and Orn","timestamp":1556981061313,"source":"API","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"}]},"createdate":{"value":"1556981061313","timestamp":1556981061313,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1556981061313","timestamp":1556981061313,"source":"API","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"},{"name":"createdate","value":"1556981061313","timestamp":1556981061313,"sourceId":"API","source":"API","sourceVid":[],"requestId":"196ea9b0-4f0a-4a3b-945e-38b23497eebf"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:21 GMT + string: '{"portalId":62515,"companyId":2606372793,"isDeleted":false,"properties":{"website":{"value":"walker.org","timestamp":1574269513014,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"walker.org","timestamp":1574269513014,"source":"CALCULATED","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]},"hs_lastmodifieddate":{"value":"1574269513014","timestamp":1574269513014,"source":"CALCULATED","sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","versions":[{"name":"hs_lastmodifieddate","value":"1574269513014","timestamp":1574269513014,"sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","source":"CALCULATED","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]},"domain":{"value":"walker.org","timestamp":1574269513014,"source":"API","sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","versions":[{"name":"domain","value":"walker.org","timestamp":1574269513014,"sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","source":"API","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]},"hs_object_id":{"value":"2606372793","timestamp":1574269513014,"source":"API","sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","versions":[{"name":"hs_object_id","value":"2606372793","timestamp":1574269513014,"sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","source":"API","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]},"name":{"value":"Dicki-McKenzie","timestamp":1574269513014,"source":"API","sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","versions":[{"name":"name","value":"Dicki-McKenzie","timestamp":1574269513014,"sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","source":"API","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]},"createdate":{"value":"1574269513014","timestamp":1574269513014,"source":"API","sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","versions":[{"name":"createdate","value":"1574269513014","timestamp":1574269513014,"sourceId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc","source":"API","sourceVid":[],"requestId":"171f3825-3eb3-47a3-b37d-b9bc22b2f3fc"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:13 GMT - request: method: post - uri: https://api.hubapi.com/contacts/v1/contact?hapikey= + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo body: encoding: UTF-8 - string: '{"properties":[{"property":"firstname","value":"Markita"},{"property":"lastname","value":"Beier"},{"property":"email","value":"81061ttgd@example.com"},{"property":"associatedCompanyId","value":1897447170}]}' + string: '{"properties":[{"property":"firstname","value":"Valeria"},{"property":"lastname","value":"Altenwerth"},{"property":"email","value":"kazuko.macejkovic@example.org"}]}' headers: Content-Type: - application/json @@ -67,7 +75,7 @@ http_interactions: message: OK headers: Date: - - Sat, 04 May 2019 14:44:21 GMT + - Wed, 20 Nov 2019 17:05:13 GMT Content-Type: - application/json;charset=utf-8 Transfer-Encoding: @@ -75,23 +83,31 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=d0a0b64d3235cbe6407fbde6f354d3f521556981061; expires=Sun, 03-May-20 - 14:44:21 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:13 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B04801128B07907AFB7565EE4DB2B8B225DD61C13000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979499' + - '249626' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '87' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '57' + - '8' Vary: - Accept-Encoding - Accept-Encoding Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -99,45 +115,107 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b4092b9bb5793-IAD + - 538c01e96980b7d5-CDG body: encoding: UTF-8 - string: '{"vid":12052924,"canonical-vid":12052924,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMuiZHPj5OGAJ9cvSCcsIvJqB1yDUIjdUo_d-W2U8YdIKnGIBE1SURplobgt4KBrWRY2SB3o58C7cGXaw3HEciq0mbZVdBGqStph1nCsWDWTHq0yF8bNYIpx9rc6jsVGuqEyfB_","profile-url":"https://app.hubspot.com/contacts/62515/contact/12052924","properties":{"firstname":{"value":"Markita","versions":[{"value":"Markita","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981061579,"selected":false}]},"associatedcompanyid":{"value":"1897447170","versions":[{"value":"1897447170","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981061579,"selected":false}]},"email":{"value":"81061ttgd@example.com","versions":[{"value":"81061ttgd@example.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981061579,"selected":false}]},"lastname":{"value":"Beier","versions":[{"value":"Beier","source-type":"API","source-id":null,"source-label":null,"timestamp":1556981061579,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":12052924,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"81061ttgd@example.com","timestamp":1556981061590,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"126bdbe6-369b-4207-b663-d6dc0298b7bb","timestamp":1556981061607,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' - http_version: - recorded_at: Sat, 04 May 2019 14:44:21 GMT + string: '{"vid":73701,"canonical-vid":73701,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mP88QTYSc_GcredKWGeh2j1omAm_afeh6qtY-Jni0B33j0vCxSGRsepVIwzBg0QDgovaM-FGxvM-LwX4nvhnj-XoZYxYdT41INhswANnvafmORnSICeKkaPUC9ZXOJKnT5RZmqR","profile-url":"https://app.hubspot.com/contacts/62515/contact/73701","properties":{"firstname":{"value":"Valeria","versions":[{"value":"Valeria","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269513266,"selected":false}]},"email":{"value":"kazuko.macejkovic@example.org","versions":[{"value":"kazuko.macejkovic@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269513266,"selected":false}]},"lastname":{"value":"Altenwerth","versions":[{"value":"Altenwerth","source-type":"API","source-id":null,"source-label":null,"timestamp":1574269513266,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73701,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"kazuko.macejkovic@example.org","timestamp":1574269513273,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"ba9c731a-58e2-4328-8e77-0aba2dc38d83","timestamp":1574269513296,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:13 GMT - request: - method: delete - uri: https://api.hubapi.com/companies/v2/companies/1897447170/contacts/12052924?hapikey= + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo body: - encoding: US-ASCII - string: '' - headers: {} + encoding: UTF-8 + string: '[{"fromObjectId":2606372793,"toObjectId":73701,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: + Content-Type: + - application/json response: status: code: 204 message: No Content headers: Date: - - Sat, 04 May 2019 14:44:22 GMT + - Wed, 20 Nov 2019 17:05:14 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:13 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249625' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '86' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '8' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 538c01ebdcf06936-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:14 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/delete-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":2606372793,"toObjectId":73701,"category":"HUBSPOT_DEFINED","definitionId":2}]' + headers: Content-Type: - - application/json;charset=utf-8 + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Wed, 20 Nov 2019 17:05:14 GMT Connection: - keep-alive Set-Cookie: - - __cfduid=d831ad88658368ca3c37d7f2e66dc3bac1556981062; expires=Sun, 03-May-20 - 14:44:22 GMT; path=/; domain=.hubapi.com; HttpOnly + - __cfduid=redacted; expires=Fri, 20-Dec-19 + 17:05:14 GMT; path=/; domain=.hubapi.com; HttpOnly X-Trace: - - 2B6004F7611E6C34D6D6DF736AE2646740EA29E9ED000000000000000000 + - redacted X-Hubspot-Ratelimit-Daily: - - '1000000' + - '250000' X-Hubspot-Ratelimit-Daily-Remaining: - - '979498' + - '249624' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '85' + X-Hubspot-Ratelimit-Max: + - '100' X-Hubspot-Ratelimit-Secondly: - - '60' + - '10' X-Hubspot-Ratelimit-Secondly-Remaining: - - '59' + - '8' Access-Control-Allow-Credentials: - 'false' + Cf-Cache-Status: + - DYNAMIC Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload Expect-Ct: @@ -145,10 +223,10 @@ http_interactions: Server: - cloudflare Cf-Ray: - - 4d1b4095e80d9fe2-IAD + - 538c01f0ac1ecd7b-CDG body: encoding: UTF-8 string: '' - http_version: - recorded_at: Sat, 04 May 2019 14:44:22 GMT -recorded_with: VCR 4.0.0 + http_version: + recorded_at: Wed, 20 Nov 2019 17:05:14 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/company_spec.rb b/spec/lib/hubspot/company_spec.rb index e1cf0f1f..1d1e7743 100644 --- a/spec/lib/hubspot/company_spec.rb +++ b/spec/lib/hubspot/company_spec.rb @@ -1,16 +1,5 @@ RSpec.describe Hubspot::Company do - # let(:example_company_hash) do - # VCR.use_cassette("company_example") do - # HTTParty.get("https://api.hubapi.com/companies/v2/companies/21827084?hapikey=demo").parsed_response - # end - # end - # let(:company_with_contacts_hash) do - # VCR.use_cassette("company_with_contacts") do - # HTTParty.get("https://api.hubapi.com/companies/v2/companies/115200636?hapikey=demo").parsed_response - # end - # end - - before{ Hubspot.configure(hapikey: "demo") } + before { Hubspot.configure(hapikey: 'demo') } it_behaves_like "a saveable resource", :company do def set_property(company) @@ -279,13 +268,11 @@ def set_property(company) subject { described_class.add_contact company.id, contact.id } it 'returns success' do - expect(subject).to be_truthy + expect(subject).to be true end it 'adds the contact to the company' do - expect { - subject - }.to change { company.contact_ids }.by([contact.id]) + expect { subject }.to change { company.contact_ids }.by([contact.id]) end end @@ -294,12 +281,10 @@ def set_property(company) let(:company) { create :company } - subject { described_class.add_contact company.id, 1 } + subject { described_class.add_contact company.id, 1234 } it 'raises an error' do - expect { - subject - }.to raise_error(Hubspot::RequestError, /Contact with the vid/) + expect { subject }.to raise_error(Hubspot::RequestError, /CONTACT=1234 is not valid/) end end @@ -309,32 +294,30 @@ def set_property(company) subject { described_class.add_contact 1, 1 } it 'raises an error' do - expect { - subject - }.to raise_error(Hubspot::RequestError, /company with the ID/) + expect { subject }.to raise_error(Hubspot::RequestError, /COMPANY=1 is not valid/) end end end describe '.remove_contact' do context 'with a valid company ID and contact ID' do - cassette allow_playback_repeats: true + cassette - let!(:company) { create :company } - let!(:contact) { create :contact, associatedCompanyId: company.id } + let(:company) { create :company } + let(:contact) { create :contact } + before { described_class.add_contact(company.id, contact.id) } subject { described_class.remove_contact company.id, contact.id } it 'returns success' do - expect(subject).to be_truthy + expect(subject).to be true end - # Testing this turns out to be hard since using associatedCompanyId doesn't immediately add - # the contact to the company but triggers some background job to perform the update. Since - # we're testing the gem interface and not the API (that's Hubspot's job) this should be OK to - # leave out. - # - # it 'removes the contact from the company' + it 'removes the contact from the company' do + expect(company.contact_ids.resources).to eq [contact.id] + subject + expect(company.contact_ids.resources).to eq [] + end end end end From 77d156c0e9030d94e5e46712a235ccff536c5999 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 18:46:18 +0100 Subject: [PATCH 06/10] Add documentation --- lib/hubspot/association.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hubspot/association.rb b/lib/hubspot/association.rb index 5cbb8950..c4322212 100644 --- a/lib/hubspot/association.rb +++ b/lib/hubspot/association.rb @@ -8,9 +8,13 @@ class Hubspot::Association class << self def create(from_id, to_id, definition_id) - batch_create([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) + batch_create([{ from_id: from_id, to_id: to_id, definition_id: definition_id }]) end + # Make multiple associations in a single API call + # {https://developers.hubspot.com/docs/methods/crm-associations/batch-associate-objects} + # usage: + # Hubspot::Association.batch_create([{ from_id: 1, to_id: 2, definition_id: Hubspot::Association::COMPANY_TO_CONTACT }]) def batch_create(associations) request = associations.map { |assocation| build_association_body(assocation) } Hubspot::Connection.put_json(BATCH_CREATE_PATH, params: { no_parse: true }, body: request).success? @@ -20,6 +24,10 @@ def delete(from_id, to_id, definition_id) batch_delete([{from_id: from_id, to_id: to_id, definition_id: definition_id}]) end + # Remove multiple associations in a single API call + # {https://developers.hubspot.com/docs/methods/crm-associations/batch-delete-associations} + # usage: + # Hubspot::Association.batch_delete([{ from_id: 1, to_id: 2, definition_id: Hubspot::Association::COMPANY_TO_CONTACT }]) def batch_delete(associations) request = associations.map { |assocation| build_association_body(assocation) } Hubspot::Connection.put_json(BATCH_DELETE_PATH, params: { no_parse: true }, body: request).success? From 3f137a2b5feef7f82918e2db0d37896e556bb29c Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Wed, 20 Nov 2019 18:47:42 +0100 Subject: [PATCH 07/10] Deal.associate use Association --- lib/hubspot/deal.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/hubspot/deal.rb b/lib/hubspot/deal.rb index 445b2f70..0e9d6aec 100644 --- a/lib/hubspot/deal.rb +++ b/lib/hubspot/deal.rb @@ -12,7 +12,6 @@ class Deal DEAL_PATH = "/deals/v1/deal/:deal_id" RECENT_UPDATED_PATH = "/deals/v1/deal/recent/modified" UPDATE_DEAL_PATH = '/deals/v1/deal/:deal_id' - ASSOCIATE_DEAL_PATH = '/deals/v1/deal/:deal_id/associations/:OBJECTTYPE?id=:objectId' ASSOCIATED_DEAL_PATH = "/deals/v1/deal/associated/:objectType/:objectId" attr_reader :properties @@ -39,16 +38,19 @@ def create!(portal_id, company_ids, vids, params={}) new(response) end - # Associate a deal with a contact or company - # {http://developers.hubspot.com/docs/methods/deals/associate_deal} - # Usage - # Hubspot::Deal.associate!(45146940, [], [52]) - def associate!(deal_id, company_ids=[], vids=[]) - objecttype = company_ids.any? ? 'COMPANY' : 'CONTACT' - object_ids = (company_ids.any? ? company_ids : vids).join('&id=') - Hubspot::Connection.put_json(ASSOCIATE_DEAL_PATH, params: { deal_id: deal_id, OBJECTTYPE: objecttype, objectId: object_ids}, body: {}) - end - + # Associate a deal with a contact or company + # {http://developers.hubspot.com/docs/methods/deals/associate_deal} + # Usage + # Hubspot::Deal.associate!(45146940, [32], [52]) + def associate!(deal_id, company_ids=[], vids=[]) + associations = company_ids.map do |id| + { from_id: deal_id, to_id: id, definition_id: Hubspot::Association::DEAL_TO_COMPANY } + end + associations += vids.map do |id| + { from_id: deal_id, to_id: id, definition_id: Hubspot::Association::DEAL_TO_CONTACT } + end + Hubspot::Association.batch_create(associations) + end def find(deal_id) response = Hubspot::Connection.get_json(DEAL_PATH, { deal_id: deal_id }) From b2c47e72ab2034e112cd42c0eb9bf382037d6124 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Thu, 21 Nov 2019 11:05:29 +0100 Subject: [PATCH 08/10] Deal.associate uses Association --- ...he_deal_to_the_contact_and_the_company.yml | 298 ++++++++++++++++++ ..._error_and_do_not_changes_associations.yml | 244 ++++++++++++++ spec/lib/hubspot/deal_spec.rb | 30 +- 3 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_associates_the_deal_to_the_contact_and_the_company.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_when_an_id_is_invalid_raises_an_error_and_do_not_changes_associations.yml diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_associates_the_deal_to_the_contact_and_the_company.yml b/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_associates_the_deal_to_the_contact_and_the_company.yml new file mode 100644 index 00000000..bab98667 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_associates_the_deal_to_the_contact_and_the_company.yml @@ -0,0 +1,298 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:18 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:18 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249986' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc753af9ee4c-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191044689,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574330238358","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574330238358","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574330238358","timestamp":1574330238358,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574330238358","timestamp":1574330238358,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191044689","timestamp":1574330238358,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191044689","timestamp":1574330238358,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574330238358","timestamp":1574330238358,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574330238358","timestamp":1574330238358,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:18 GMT +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Nikolaus, Zulauf and Rice"},{"name":"domain","value":"mraz.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:19 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:19 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249985' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc7ceccba8bb-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2613047129,"isDeleted":false,"properties":{"website":{"value":"mraz.com","timestamp":1574330239579,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"mraz.com","timestamp":1574330239579,"source":"CALCULATED","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]},"hs_lastmodifieddate":{"value":"1574330239579","timestamp":1574330239579,"source":"CALCULATED","sourceId":"f8a21907-c88e-4678-8878-845af55376cc","versions":[{"name":"hs_lastmodifieddate","value":"1574330239579","timestamp":1574330239579,"sourceId":"f8a21907-c88e-4678-8878-845af55376cc","source":"CALCULATED","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]},"domain":{"value":"mraz.com","timestamp":1574330239579,"source":"API","sourceId":"f8a21907-c88e-4678-8878-845af55376cc","versions":[{"name":"domain","value":"mraz.com","timestamp":1574330239579,"sourceId":"f8a21907-c88e-4678-8878-845af55376cc","source":"API","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]},"hs_object_id":{"value":"2613047129","timestamp":1574330239579,"source":"API","sourceId":"f8a21907-c88e-4678-8878-845af55376cc","versions":[{"name":"hs_object_id","value":"2613047129","timestamp":1574330239579,"sourceId":"f8a21907-c88e-4678-8878-845af55376cc","source":"API","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]},"name":{"value":"Nikolaus, + Zulauf and Rice","timestamp":1574330239579,"source":"API","sourceId":"f8a21907-c88e-4678-8878-845af55376cc","versions":[{"name":"name","value":"Nikolaus, + Zulauf and Rice","timestamp":1574330239579,"sourceId":"f8a21907-c88e-4678-8878-845af55376cc","source":"API","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]},"createdate":{"value":"1574330239579","timestamp":1574330239579,"source":"API","sourceId":"f8a21907-c88e-4678-8878-845af55376cc","versions":[{"name":"createdate","value":"1574330239579","timestamp":1574330239579,"sourceId":"f8a21907-c88e-4678-8878-845af55376cc","source":"API","sourceVid":[],"requestId":"f8a21907-c88e-4678-8878-845af55376cc"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:19 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Lita"},{"property":"lastname","value":"Moen"},{"property":"email","value":"olevia@example.org"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:20 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:19 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249984' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc7eefaecd83-CDG + body: + encoding: UTF-8 + string: '{"vid":73851,"canonical-vid":73851,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mP_l8mnTGe9kV4aRpx6Q1jkJcTmEnKWAQr8_b-16diSl1HO1ELKJeDItbyqWBWm3fWKWpOcpWQVbogNq1Cvq564GhTch1Cy7CBc_RT5yPtB0aAME-Msvfj0fzS4OEG2xcX58seX","profile-url":"https://app.hubspot.com/contacts/62515/contact/73851","properties":{"firstname":{"value":"Lita","versions":[{"value":"Lita","source-type":"API","source-id":null,"source-label":null,"timestamp":1574330239921,"selected":false}]},"email":{"value":"olevia@example.org","versions":[{"value":"olevia@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574330239921,"selected":false}]},"lastname":{"value":"Moen","versions":[{"value":"Moen","source-type":"API","source-id":null,"source-label":null,"timestamp":1574330239921,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":73851,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"olevia@example.org","timestamp":1574330239927,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"b1d2b53f-0213-4a46-8926-73a6e834fbf3","timestamp":1574330239952,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:20 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1191044689,"toObjectId":2613047129,"category":"HUBSPOT_DEFINED","definitionId":5},{"fromObjectId":1191044689,"toObjectId":73851,"category":"HUBSPOT_DEFINED","definitionId":3}]' + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 21 Nov 2019 09:57:20 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:20 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249983' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc81cd06edf7-CDG + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:20 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1191044689?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:20 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:20 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249982' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc83894ecdc3-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191044689,"isDeleted":false,"associations":{"associatedVids":[73851],"associatedCompanyIds":[2613047129],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574330238995","timestamp":1574330238995,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574330238995","timestamp":1574330238995,"source":"CALCULATED","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":1574330238850,"source":"CALCULATED","sourceId":"RollupProperties","versions":[{"name":"num_associated_contacts","value":"0","timestamp":1574330238850,"sourceId":"RollupProperties","source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574330238358","timestamp":1574330238358,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574330238358","timestamp":1574330238358,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191044689","timestamp":1574330238358,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191044689","timestamp":1574330238358,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574330238358","timestamp":1574330238358,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574330238358","timestamp":1574330238358,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574330238358,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:20 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_when_an_id_is_invalid_raises_an_error_and_do_not_changes_associations.yml b/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_when_an_id_is_invalid_raises_an_error_and_do_not_changes_associations.yml new file mode 100644 index 00000000..804476ac --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Deal_associate_when_an_id_is_invalid_raises_an_error_and_do_not_changes_associations.yml @@ -0,0 +1,244 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:21 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:20 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249981' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc855fbfcd77-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191058474,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574330240924","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574330240924","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574330240924","timestamp":1574330240924,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574330240924","timestamp":1574330240924,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191058474","timestamp":1574330240924,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191058474","timestamp":1574330240924,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574330240924","timestamp":1574330240924,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574330240924","timestamp":1574330240924,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:21 GMT +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Williamson, Little and Haag"},{"name":"domain","value":"sanfordbosco.info"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:21 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:21 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249980' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '93' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc87dd2cee23-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2611058436,"isDeleted":false,"properties":{"website":{"value":"sanfordbosco.info","timestamp":1574330241795,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"sanfordbosco.info","timestamp":1574330241795,"source":"CALCULATED","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]},"hs_lastmodifieddate":{"value":"1574330241795","timestamp":1574330241795,"source":"CALCULATED","sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","versions":[{"name":"hs_lastmodifieddate","value":"1574330241795","timestamp":1574330241795,"sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","source":"CALCULATED","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]},"domain":{"value":"sanfordbosco.info","timestamp":1574330241795,"source":"API","sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","versions":[{"name":"domain","value":"sanfordbosco.info","timestamp":1574330241795,"sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","source":"API","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]},"hs_object_id":{"value":"2611058436","timestamp":1574330241795,"source":"API","sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","versions":[{"name":"hs_object_id","value":"2611058436","timestamp":1574330241795,"sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","source":"API","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]},"name":{"value":"Williamson, + Little and Haag","timestamp":1574330241795,"source":"API","sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","versions":[{"name":"name","value":"Williamson, + Little and Haag","timestamp":1574330241795,"sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","source":"API","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]},"createdate":{"value":"1574330241795","timestamp":1574330241795,"source":"API","sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","versions":[{"name":"createdate","value":"1574330241795","timestamp":1574330241795,"sourceId":"e3dc6167-4b77-4d97-ac35-a24b614b399c","source":"API","sourceVid":[],"requestId":"e3dc6167-4b77-4d97-ac35-a24b614b399c"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:21 GMT +- request: + method: put + uri: https://api.hubapi.com/crm-associations/v1/associations/create-batch?hapikey=demo + body: + encoding: UTF-8 + string: '[{"fromObjectId":1191058474,"toObjectId":2611058436,"category":"HUBSPOT_DEFINED","definitionId":5},{"fromObjectId":1191058474,"toObjectId":1234,"category":"HUBSPOT_DEFINED","definitionId":3}]' + headers: + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Date: + - Thu, 21 Nov 2019 09:57:22 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '212' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:22 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249979' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '92' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc8c8838b7bd-CDG + body: + encoding: UTF-8 + string: '{"status":"error","message":"One or more associations are invalid","correlationId":"6790472e-3934-4990-b2ca-3fcdc16ef024","errors":["CONTACT=1234 + is not valid"],"requestId":"660186a5-f15d-48d5-b549-b50688c94c64"}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:22 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1191058474?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 09:57:22 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 09:57:22 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249978' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '91' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5391cc8f3887b7cf-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191058474,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574330241487","timestamp":1574330241487,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574330241487","timestamp":1574330241487,"source":"CALCULATED","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":1574330241363,"source":"CALCULATED","sourceId":"RollupProperties","versions":[{"name":"num_associated_contacts","value":"0","timestamp":1574330241363,"sourceId":"RollupProperties","source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574330240924","timestamp":1574330240924,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574330240924","timestamp":1574330240924,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191058474","timestamp":1574330240924,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191058474","timestamp":1574330240924,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574330240924","timestamp":1574330240924,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574330240924","timestamp":1574330240924,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574330240924,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 09:57:22 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/deal_spec.rb b/spec/lib/hubspot/deal_spec.rb index eb0ff86a..b6cb325b 100644 --- a/spec/lib/hubspot/deal_spec.rb +++ b/spec/lib/hubspot/deal_spec.rb @@ -10,7 +10,7 @@ end end - before{ Hubspot.configure(hapikey: "demo") } + before { Hubspot.configure(hapikey: 'demo') } describe "#initialize" do subject{ Hubspot::Deal.new(example_deal_hash) } @@ -28,6 +28,34 @@ its(:vids) { should eql [vid]} end + describe '.associate' do + cassette + let(:deal) { Hubspot::Deal.create!(portal_id, [], [], {}) } + let(:company) { create :company } + let(:contact) { create :contact } + let(:contact_id) { contact.id } + + subject { Hubspot::Deal.associate!(deal.deal_id, [company.id], [contact_id]) } + + it 'associates the deal to the contact and the company' do + subject + find_deal = Hubspot::Deal.find(deal.deal_id) + find_deal.company_ids.should eql [company.id] + find_deal.vids.should eql [contact.id] + end + + context 'when an id is invalid' do + let(:contact_id) { 1234 } + + it 'raises an error and do not changes associations' do + expect { subject }.to raise_error(Hubspot::RequestError) + find_deal = Hubspot::Deal.find(deal.deal_id) + find_deal.company_ids.should eql [] + find_deal.vids.should eql [] + end + end + end + describe ".find" do cassette "deal_find" let(:deal) {Hubspot::Deal.create!(portal_id, [company_id], [vid], { amount: amount})} From 84540cb51abb86c935794a63f0b392e997404f91 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Thu, 21 Nov 2019 13:29:04 +0100 Subject: [PATCH 09/10] Add Association.all --- lib/hubspot-ruby.rb | 2 +- lib/hubspot/association.rb | 33 ++ ..._with_valid_params_finds_the_resources.yml | 363 ++++++++++++++++++ spec/lib/hubspot/association_spec.rb | 27 ++ 4 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Association_all_with_valid_params_finds_the_resources.yml diff --git a/lib/hubspot-ruby.rb b/lib/hubspot-ruby.rb index fe6adf83..6e308066 100644 --- a/lib/hubspot-ruby.rb +++ b/lib/hubspot-ruby.rb @@ -6,7 +6,6 @@ require 'hubspot/collection' require 'hubspot/paged_collection' require 'hubspot/properties' -require 'hubspot/association' require 'hubspot/company' require 'hubspot/company_properties' require 'hubspot/config' @@ -20,6 +19,7 @@ require 'hubspot/deal' require 'hubspot/deal_pipeline' require 'hubspot/deal_properties' +require 'hubspot/association' require 'hubspot/deprecator' require 'hubspot/owner' require 'hubspot/engagement' diff --git a/lib/hubspot/association.rb b/lib/hubspot/association.rb index c4322212..98fece3c 100644 --- a/lib/hubspot/association.rb +++ b/lib/hubspot/association.rb @@ -1,10 +1,20 @@ class Hubspot::Association COMPANY_TO_CONTACT = 2 DEAL_TO_CONTACT = 3 + CONTACT_TO_DEAL = 4 DEAL_TO_COMPANY = 5 + COMPANY_TO_DEAL = 6 + DEFINITION_TARGET_TO_CLASS = { + 2 => Hubspot::Contact, + 3 => Hubspot::Contact, + 4 => Hubspot::Deal, + 5 => Hubspot::Company, + 6 => Hubspot::Deal + }.freeze BATCH_CREATE_PATH = '/crm-associations/v1/associations/create-batch' BATCH_DELETE_PATH = '/crm-associations/v1/associations/delete-batch' + ASSOCIATIONS_PATH = '/crm-associations/v1/associations/:resource_id/HUBSPOT_DEFINED/:definition_id' class << self def create(from_id, to_id, definition_id) @@ -33,6 +43,29 @@ def batch_delete(associations) Hubspot::Connection.put_json(BATCH_DELETE_PATH, params: { no_parse: true }, body: request).success? end + # Retrieve all associated resources given a source (resource_id) and a kind (definition_id) + # Example: if resource_id is a deal, using DEAL_TO_CONTACT will find every contact associated with the deal + # {https://developers.hubspot.com/docs/methods/crm-associations/get-associations} + # Warning: it will make N+M queries, where + # N is the number of PagedCollection requests necessary to get all ids, + # and M is the number of results, each resulting in a find + # usage: + # Hubspot::Association.all(42, Hubspot::Association::DEAL_TO_CONTACT) + def all(resource_id, definition_id) + opts = { resource_id: resource_id, definition_id: definition_id } + klass = DEFINITION_TARGET_TO_CLASS[definition_id] + raise(Hubspot::InvalidParams, 'Definition not supported') unless klass.present? + + collection = Hubspot::PagedCollection.new(opts) do |options, offset, limit| + params = options.merge(offset: offset, limit: limit) + response = Hubspot::Connection.get_json(ASSOCIATIONS_PATH, params) + + resources = response['results'].map { |result| klass.find(result) } + [resources, response['offset'], response['has-more']] + end + collection.resources + end + private def build_association_body(assocation) diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Association_all_with_valid_params_finds_the_resources.yml b/spec/fixtures/vcr_cassettes/Hubspot_Association_all_with_valid_params_finds_the_resources.yml new file mode 100644 index 00000000..2748e2a0 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Association_all_with_valid_params_finds_the_resources.yml @@ -0,0 +1,363 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Genoveva"},{"property":"lastname","value":"Hackett"},{"property":"email","value":"will@example.org"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:18 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:17 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249819' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0d8999dee1f-CDG + body: + encoding: UTF-8 + string: '{"vid":74501,"canonical-vid":74501,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mP-9guir_T0ydntvQfDvZl3zR_lLbeaaAEnmod7T1gB65uqg7NteOfq5gWsRLMzoGtuV3uM0YZ4YM4IFS35lZ0xc0DJJMQl95aQTf5pxwKu797JSJW2cyU9FNHcNjTBLmP-7ZD3","profile-url":"https://app.hubspot.com/contacts/62515/contact/74501","properties":{"firstname":{"value":"Genoveva","versions":[{"value":"Genoveva","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938221,"selected":false}]},"email":{"value":"will@example.org","versions":[{"value":"will@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938221,"selected":false}]},"lastname":{"value":"Hackett","versions":[{"value":"Hackett","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938221,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":74501,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"will@example.org","timestamp":1574338938228,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"7fc4cc63-e80d-4bdb-acf3-68d09ecf950d","timestamp":1574338938275,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:18 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Chu"},{"property":"lastname","value":"Moen"},{"property":"email","value":"daren@example.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:19 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:18 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249818' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0deff8b3c75-CDG + body: + encoding: UTF-8 + string: '{"vid":74551,"canonical-vid":74551,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMd5QjyBBZO0uMbUReahlfRErPZVKrO3brqw08M0XqvxlbPrCjM-3ZEBbgUajQ9iaQZR9l-wHVABF0myRP_HmDlNLRJxgUB5pOR2ZzvhqchlETpVo6TMtdYKzJinH66_FuqrQko","profile-url":"https://app.hubspot.com/contacts/62515/contact/74551","properties":{"firstname":{"value":"Chu","versions":[{"value":"Chu","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938789,"selected":false}]},"email":{"value":"daren@example.com","versions":[{"value":"daren@example.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938789,"selected":false}]},"lastname":{"value":"Moen","versions":[{"value":"Moen","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938789,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":74551,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"daren@example.com","timestamp":1574338938796,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"8484bd8e-2895-4918-a2fd-5990603812c5","timestamp":1574338938843,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:19 GMT +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[74501,74551]},"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:19 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:19 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249817' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0e1cbf2ee2b-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191495850,"isDeleted":false,"associations":{"associatedVids":[74501,74551],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574338939242","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574338939242","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574338939242","timestamp":1574338939242,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574338939242","timestamp":1574338939242,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191495850","timestamp":1574338939242,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191495850","timestamp":1574338939242,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574338939242","timestamp":1574338939242,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574338939242","timestamp":1574338939242,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574338939242,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:19 GMT +- request: + method: get + uri: https://api.hubapi.com/crm-associations/v1/associations/1191495850/HUBSPOT_DEFINED/3?hapikey=demo&limit=25&offset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:19 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '56' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:19 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249816' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0e3cd38a8d9-CDG + body: + encoding: UTF-8 + string: '{"results":[74501,74551],"hasMore":false,"offset":74551}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:20 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/74501/profile?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:20 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:20 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249815' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0e768aa3c33-CDG + body: + encoding: UTF-8 + string: '{"vid":74501,"canonical-vid":74501,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOml_R7lkdJ35zC_z_YVh8BU8A6v6VpnKBoDVyKzlgReupgoSC9N1-hGg28wJBy43uxLPZlh4SidBYsOn9HQ8BcEvF_fmqSZt3VO5qy8PeRWLrql2oAhIIHPYwTuQu2pmDSC9q4","profile-url":"https://app.hubspot.com/contacts/62515/contact/74501","properties":{"firstname":{"value":"Genoveva","versions":[{"value":"Genoveva","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938221,"selected":false}]},"hs_is_contact":{"value":"true","versions":[{"value":"true","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"lastmodifieddate":{"value":"1574338938344","versions":[{"value":"1574338938344","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938344,"selected":false}]},"num_unique_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"hs_object_id":{"value":"74501","versions":[{"value":"74501","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"hs_email_domain":{"value":"example.org","versions":[{"value":"example.org","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"createdate":{"value":"1574338938228","versions":[{"value":"1574338938228","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1574338938228","versions":[{"value":"1574338938228","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"email":{"value":"will@example.org","versions":[{"value":"will@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938228,"selected":false}]},"lastname":{"value":"Hackett","versions":[{"value":"Hackett","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938221,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":74501,"saved-at-timestamp":1574338938280,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"will@example.org","timestamp":1574338938228,"is-primary":true},{"type":"LEAD_GUID","value":"7fc4cc63-e80d-4bdb-acf3-68d09ecf950d","timestamp":1574338938275}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:20 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/74551/profile?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:22:20 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:22:20 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249814' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392a0e99ad3edf7-CDG + body: + encoding: UTF-8 + string: '{"vid":74551,"canonical-vid":74551,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOc3paSfUMM3cU6QUNrdi4_fWY3EPhQA7xtZ66ThC_VgzZp3nYEK7-qMegz73paMXdieDP9B5zcuFfxPVwoeOp5GdaDEFrMYEFb1qal212SGDybKYqz7oIw_akJ_d2JbqPfSAJG","profile-url":"https://app.hubspot.com/contacts/62515/contact/74551","properties":{"firstname":{"value":"Chu","versions":[{"value":"Chu","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938789,"selected":false}]},"recent_deal_close_date":{"value":"","versions":[{"value":"","source-type":"DEALS","source-id":"DealRollupProperties","source-label":null,"timestamp":1574338939564,"selected":false}]},"lastmodifieddate":{"value":"1574338940098","versions":[{"value":"1574338940098","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338940098,"selected":false}]},"num_unique_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"createdate":{"value":"1574338938796","versions":[{"value":"1574338938796","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1574338938796","versions":[{"value":"1574338938796","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"hs_lifecyclestage_opportunity_date":{"value":"1574338939789","versions":[{"value":"1574338939789","source-type":"DEALS","source-id":null,"source-label":null,"timestamp":1574338939789,"selected":false}]},"lastname":{"value":"Moen","versions":[{"value":"Moen","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938789,"selected":false}]},"recent_deal_amount":{"value":"","versions":[{"value":"","source-type":"DEALS","source-id":"DealRollupProperties","source-label":null,"timestamp":1574338939564,"selected":false}]},"first_deal_created_date":{"value":"1574338939242","versions":[{"value":"1574338939242","source-type":"DEALS","source-id":"DealRollupProperties","source-label":null,"timestamp":1574338939564,"selected":false}]},"hs_is_contact":{"value":"true","versions":[{"value":"true","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"total_revenue":{"value":"","versions":[{"value":"","source-type":"DEALS","source-id":"DealRollupProperties","source-label":null,"timestamp":1574338939564,"selected":false}]},"hs_object_id":{"value":"74551","versions":[{"value":"74551","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"num_associated_deals":{"value":"1","versions":[{"value":"1","source-type":"DEALS","source-id":"DealRollupProperties","source-label":null,"timestamp":1574338939564,"selected":false}]},"hs_email_domain":{"value":"example.com","versions":[{"value":"example.com","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"lifecyclestage":{"value":"opportunity","versions":[{"value":"opportunity","source-type":"DEALS","source-id":null,"source-label":null,"timestamp":1574338939789,"selected":false},{"value":"subscriber","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]},"email":{"value":"daren@example.com","versions":[{"value":"daren@example.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1574338938796,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":74551,"saved-at-timestamp":1574338938848,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"daren@example.com","timestamp":1574338938796,"is-primary":true},{"type":"LEAD_GUID","value":"8484bd8e-2895-4918-a2fd-5990603812c5","timestamp":1574338938843}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:22:20 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/lib/hubspot/association_spec.rb b/spec/lib/hubspot/association_spec.rb index 5d17d5de..66812561 100644 --- a/spec/lib/hubspot/association_spec.rb +++ b/spec/lib/hubspot/association_spec.rb @@ -130,4 +130,31 @@ end end end + + describe '.all' do + subject { described_class.all(resource_id, definition_id) } + + context 'with valid params' do + cassette + + let(:resource_id) { deal.deal_id } + let(:definition_id) { described_class::DEAL_TO_CONTACT } + let(:deal) { Hubspot::Deal.create!(portal_id, [], contact_ids, {}) } + let(:contact_ids) { [contact.id, second_contact.id] } + let(:second_contact) { create :contact } + + it 'finds the resources' do + expect(subject.map(&:id)).to contain_exactly(*contact_ids) + end + end + + context 'with unsupported definition' do + let(:resource_id) { 1234 } + let(:definition_id) { -1 } + + it 'raises an error' do + expect { subject }.to raise_error(Hubspot::InvalidParams, 'Definition not supported') + end + end + end end From 9f29322dfe59f7532331263712f56b4b8560bb93 Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Thu, 21 Nov 2019 14:01:47 +0100 Subject: [PATCH 10/10] Deal.find_by_association uses Association --- lib/hubspot/deal.rb | 18 +- ..._find_by_company_returns_company_deals.yml | 239 +++++++++++++++++ ..._find_by_contact_returns_contact_deals.yml | 242 ++++++++++++++++++ .../vcr_cassettes/deal_find_by_company.yml | 136 ---------- spec/lib/hubspot/deal_spec.rb | 18 +- 5 files changed, 502 insertions(+), 151 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_company_returns_company_deals.yml create mode 100644 spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_contact_returns_contact_deals.yml delete mode 100644 spec/fixtures/vcr_cassettes/deal_find_by_company.yml diff --git a/lib/hubspot/deal.rb b/lib/hubspot/deal.rb index 0e9d6aec..d1bd763c 100644 --- a/lib/hubspot/deal.rb +++ b/lib/hubspot/deal.rb @@ -12,7 +12,6 @@ class Deal DEAL_PATH = "/deals/v1/deal/:deal_id" RECENT_UPDATED_PATH = "/deals/v1/deal/recent/modified" UPDATE_DEAL_PATH = '/deals/v1/deal/:deal_id' - ASSOCIATED_DEAL_PATH = "/deals/v1/deal/associated/:objectType/:objectId" attr_reader :properties attr_reader :portal_id @@ -96,20 +95,15 @@ def find_by_contact(contact) end # Find all deals associated to a contact or company - # {http://developers.hubspot.com/docs/methods/deals/get-associated-deals} # @param object [Hubspot::Contact || Hubspot::Company] a contact or company # @return [Array] Array of Hubspot::Deal records def find_by_association(object) - path = ASSOCIATED_DEAL_PATH - objectType = case object - when Hubspot::Company then :company - when Hubspot::Contact then :contact - else raise(Hubspot::InvalidParams, "Instance type not supported") - end - - params = { objectType: objectType, objectId: object.id } - response = Hubspot::Connection.get_json(path, params) - response["results"].map { |deal_id| find(deal_id) } + definition = case object + when Hubspot::Company then Hubspot::Association::COMPANY_TO_DEAL + when Hubspot::Contact then Hubspot::Association::CONTACT_TO_DEAL + else raise(Hubspot::InvalidParams, 'Instance type not supported') + end + Hubspot::Association.all(object.id, definition) end end diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_company_returns_company_deals.yml b/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_company_returns_company_deals.yml new file mode 100644 index 00000000..10a96c4f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_company_returns_company_deals.yml @@ -0,0 +1,239 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"name":"name","value":"Wunsch-Keebler"},{"name":"domain","value":"pouroscasper.com"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:55 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:54 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249795' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '99' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d5059bc8edc7-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"companyId":2613286304,"isDeleted":false,"properties":{"website":{"value":"pouroscasper.com","timestamp":1574341074897,"source":"CALCULATED","sourceId":null,"versions":[{"name":"website","value":"pouroscasper.com","timestamp":1574341074897,"source":"CALCULATED","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]},"hs_lastmodifieddate":{"value":"1574341074897","timestamp":1574341074897,"source":"CALCULATED","sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","versions":[{"name":"hs_lastmodifieddate","value":"1574341074897","timestamp":1574341074897,"sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","source":"CALCULATED","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]},"domain":{"value":"pouroscasper.com","timestamp":1574341074897,"source":"API","sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","versions":[{"name":"domain","value":"pouroscasper.com","timestamp":1574341074897,"sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","source":"API","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]},"hs_object_id":{"value":"2613286304","timestamp":1574341074897,"source":"API","sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","versions":[{"name":"hs_object_id","value":"2613286304","timestamp":1574341074897,"sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","source":"API","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]},"name":{"value":"Wunsch-Keebler","timestamp":1574341074897,"source":"API","sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","versions":[{"name":"name","value":"Wunsch-Keebler","timestamp":1574341074897,"sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","source":"API","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]},"createdate":{"value":"1574341074897","timestamp":1574341074897,"source":"API","sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","versions":[{"name":"createdate","value":"1574341074897","timestamp":1574341074897,"sourceId":"d0cd4893-cca7-41c2-a29a-5ad819287f92","source":"API","sourceVid":[],"requestId":"d0cd4893-cca7-41c2-a29a-5ad819287f92"}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:55 GMT +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[2613286304],"associatedVids":[]},"properties":[{"name":"amount","value":"30"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:55 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:55 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249794' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '98' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d5085d8c3bcd-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191512073,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[2613286304],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount":{"value":"30","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"hs_closed_amount":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574341075347","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574341075347","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574341075347","timestamp":1574341075347,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574341075347","timestamp":1574341075347,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191512073","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191512073","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574341075347","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574341075347","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount_in_home_currency":{"value":"30","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"amount_in_home_currency","value":"30","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:55 GMT +- request: + method: get + uri: https://api.hubapi.com/crm-associations/v1/associations/2613286304/HUBSPOT_DEFINED/6?hapikey=demo&limit=25&offset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:55 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:55 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249793' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '97' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d50a9e74ee3b-CDG + body: + encoding: UTF-8 + string: '{"results":[1191512073],"hasMore":false,"offset":1191512073}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:55 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1191512073?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:56 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:55 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249792' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '96' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d50cafd2a879-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191512073,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[2613286304],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount":{"value":"30","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":1574341075849,"source":"CALCULATED","sourceId":"RollupProperties","versions":[{"name":"num_associated_contacts","value":"0","timestamp":1574341075849,"sourceId":"RollupProperties","source":"CALCULATED","sourceVid":[]}]},"createdate":{"value":"1574341075347","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574341075347","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"amount_in_home_currency":{"value":"30","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"amount_in_home_currency","value":"30","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_closed_amount":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574341075880","timestamp":1574341075880,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574341075880","timestamp":1574341075880,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574341075347","timestamp":1574341075347,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574341075347","timestamp":1574341075347,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191512073","timestamp":1574341075347,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191512073","timestamp":1574341075347,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574341075347,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:56 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_contact_returns_contact_deals.yml b/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_contact_returns_contact_deals.yml new file mode 100644 index 00000000..8fd5e5a4 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Hubspot_Deal_find_by_contact_returns_contact_deals.yml @@ -0,0 +1,242 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Maris"},{"property":"lastname","value":"Littel"},{"property":"email","value":"chae@example.org"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:56 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:56 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249791' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '95' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d50e7ba93bc7-CDG + body: + encoding: UTF-8 + string: '{"vid":74701,"canonical-vid":74701,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPIsRE00kPhf6nVL_fVjlPJZk4_QnOQLBl_IOv7oJqSyOQ_uR_lIXxEOcxHT-mb2hbnoqdofwrfhMJibb6ZK97PGQP4w2BiQULtebDgaLrG1KZr7XmGNu2rJemUPaA8N_Bktze7","profile-url":"https://app.hubspot.com/contacts/62515/contact/74701","properties":{"firstname":{"value":"Maris","versions":[{"value":"Maris","source-type":"API","source-id":null,"source-label":null,"timestamp":1574341076306,"selected":false}]},"email":{"value":"chae@example.org","versions":[{"value":"chae@example.org","source-type":"API","source-id":null,"source-label":null,"timestamp":1574341076306,"selected":false}]},"lastname":{"value":"Littel","versions":[{"value":"Littel","source-type":"API","source-id":null,"source-label":null,"timestamp":1574341076306,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":74701,"is-deleted":false,"is-contact":false,"pointer-vid":0,"previous-vid":0,"linked-vids":[],"saved-at-timestamp":0,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"chae@example.org","timestamp":1574341076314,"is-primary":true,"source":"UNSPECIFIED"},{"type":"LEAD_GUID","value":"fcb9f4ec-a1be-4a3b-b933-e05f3cc1b31e","timestamp":1574341076334,"source":"UNSPECIFIED"}]}],"merge-audits":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:56 GMT +- request: + method: post + uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo + body: + encoding: UTF-8 + string: '{"portalId":62515,"associations":{"associatedCompanyIds":[],"associatedVids":[74701]},"properties":[{"name":"amount","value":"30"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:56 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:56 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249790' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '94' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d5119d2bb7a5-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191499667,"isDeleted":false,"associations":{"associatedVids":[74701],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount":{"value":"30","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"hs_closed_amount":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574341076810","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574341076810","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574341076810","timestamp":1574341076810,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574341076810","timestamp":1574341076810,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191499667","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191499667","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574341076810","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574341076810","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount_in_home_currency":{"value":"30","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"amount_in_home_currency","value":"30","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:56 GMT +- request: + method: get + uri: https://api.hubapi.com/crm-associations/v1/associations/74701/HUBSPOT_DEFINED/4?hapikey=demo&limit=25&offset= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:57 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:56 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249789' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '93' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Accept-Ranges: + - bytes + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d5131880edb3-CDG + body: + encoding: UTF-8 + string: '{"results":[1191499667],"hasMore":false,"offset":1191499667}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:57 GMT +- request: + method: get + uri: https://api.hubapi.com/deals/v1/deal/1191499667?hapikey=demo + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 Nov 2019 12:57:57 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=redacted; expires=Sat, 21-Dec-19 + 12:57:57 GMT; path=/; domain=.hubapi.com; HttpOnly + X-Trace: + - redacted + X-Hubspot-Ratelimit-Daily: + - '250000' + X-Hubspot-Ratelimit-Daily-Remaining: + - '249788' + X-Hubspot-Ratelimit-Interval-Milliseconds: + - '10000' + X-Hubspot-Ratelimit-Remaining: + - '92' + X-Hubspot-Ratelimit-Max: + - '100' + X-Hubspot-Ratelimit-Secondly: + - '10' + X-Hubspot-Ratelimit-Secondly-Remaining: + - '9' + Vary: + - Accept-Encoding + Access-Control-Allow-Credentials: + - 'false' + Cf-Cache-Status: + - DYNAMIC + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 5392d5147ee5bd72-CDG + body: + encoding: UTF-8 + string: '{"portalId":62515,"dealId":1191499667,"isDeleted":false,"associations":{"associatedVids":[74701],"associatedCompanyIds":[],"associatedDealIds":[],"associatedTicketIds":[]},"properties":{"hs_closed_amount_in_home_currency":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount_in_home_currency","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount":{"value":"30","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"hs_closed_amount":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_closed_amount","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_lastmodifieddate":{"value":"1574341076810","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1574341076810","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1574341076810","timestamp":1574341076810,"source":"API","sourceId":"","versions":[{"name":"hs_createdate","value":"1574341076810","timestamp":1574341076810,"sourceId":"","source":"API","sourceVid":[]}]},"hs_object_id":{"value":"1191499667","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"hs_object_id","value":"1191499667","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"createdate":{"value":"1574341076810","timestamp":1574341076810,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1574341076810","timestamp":1574341076810,"source":"API","sourceVid":[]}]},"hs_projected_amount":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"amount_in_home_currency":{"value":"30","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"amount_in_home_currency","value":"30","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_deal_stage_probability":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_deal_stage_probability","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"days_to_close":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"days_to_close","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]},"hs_projected_amount_in_home_currency":{"value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_projected_amount_in_home_currency","value":"0","timestamp":1574341076810,"source":"CALCULATED","sourceVid":[],"sourceMetadata":""}]}},"imports":[],"stateChanges":[]}' + http_version: + recorded_at: Thu, 21 Nov 2019 12:57:57 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/fixtures/vcr_cassettes/deal_find_by_company.yml b/spec/fixtures/vcr_cassettes/deal_find_by_company.yml deleted file mode 100644 index cf7d5808..00000000 --- a/spec/fixtures/vcr_cassettes/deal_find_by_company.yml +++ /dev/null @@ -1,136 +0,0 @@ ---- -http_interactions: -- request: - method: post - uri: https://api.hubapi.com/companies/v2/companies/?hapikey=demo - body: - encoding: UTF-8 - string: '{"properties":[{"name":"name","value":"Test Company"}]}' - headers: - Content-Type: - - application/json - response: - status: - code: 200 - message: OK - headers: - Access-Control-Allow-Credentials: - - 'false' - Content-Type: - - application/json; charset=UTF-8 - Content-Length: - - '800' - Date: - - Thu, 02 Nov 2017 00:39:01 GMT - Connection: - - keep-alive - body: - encoding: UTF-8 - string: '{"portalId":62515,"companyId":592416090,"isDeleted":false,"properties":{"hs_lastmodifieddate":{"value":"1509583141275","timestamp":1509583141275,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1509583141275","timestamp":1509583141275,"source":"CALCULATED","sourceVid":[]}]},"name":{"value":"Test - Company","timestamp":1509583141275,"source":"API","sourceId":null,"versions":[{"name":"name","value":"Test - Company","timestamp":1509583141275,"source":"API","sourceVid":[]}]},"createdate":{"value":"1509583141275","timestamp":1509583141275,"source":"API","sourceId":"API","versions":[{"name":"createdate","value":"1509583141275","timestamp":1509583141275,"sourceId":"API","source":"API","sourceVid":[]}]}},"additionalDomains":[],"stateChanges":[],"mergeAudits":[]}' - http_version: - recorded_at: Thu, 02 Nov 2017 00:39:01 GMT -- request: - method: post - uri: https://api.hubapi.com/deals/v1/deal?hapikey=demo - body: - encoding: UTF-8 - string: '{"portalId":62515,"associations":{"associatedCompanyIds":[592416090],"associatedVids":[27136]},"properties":[{"name":"amount","value":"30"}]}' - headers: - Content-Type: - - application/json - response: - status: - code: 200 - message: OK - headers: - Access-Control-Allow-Credentials: - - 'false' - Content-Type: - - application/json; charset=UTF-8 - Content-Length: - - '1328' - Date: - - Thu, 02 Nov 2017 00:39:01 GMT - Connection: - - keep-alive - body: - encoding: UTF-8 - string: '{"portalId":62515,"dealId":213404277,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[592416090],"associatedDealIds":[]},"associationCreateFailures":[{"association":{"fromObjectId":27136,"associationType":"CONTACT_TO_DEAL","toObjectId":213404277,"associationCategory":"HUBSPOT_DEFINED","associationTypeId":4,"timestamp":null},"failReason":"INVALID_OBJECT_IDS","message":"CONTACT=27136 - is not valid"}],"properties":{"amount":{"value":"30","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1509583141407,"source":"API","sourceVid":[]}]},"hs_lastmodifieddate":{"value":"1509583141407","timestamp":1509583141407,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1509583141407","timestamp":1509583141407,"source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1509583141407","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"hs_createdate","value":"1509583141407","timestamp":1509583141407,"source":"API","sourceVid":[]}]},"createdate":{"value":"1509583141407","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1509583141407","timestamp":1509583141407,"source":"API","sourceVid":[]}]}},"imports":[],"stateChanges":[]}' - http_version: - recorded_at: Thu, 02 Nov 2017 00:39:01 GMT -- request: - method: get - uri: https://api.hubapi.com/deals/v1/deal/associated/company/592416090?hapikey=demo - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Access-Control-Allow-Credentials: - - 'false' - Content-Type: - - application/json; charset=UTF-8 - Vary: - - Accept-Encoding - - user-agent - Date: - - Thu, 02 Nov 2017 00:39:01 GMT - Content-Length: - - '58' - Connection: - - keep-alive - body: - encoding: UTF-8 - string: '{"results":[213404277],"hasMore":false,"offset":213404277}' - http_version: - recorded_at: Thu, 02 Nov 2017 00:39:01 GMT -- request: - method: get - uri: https://api.hubapi.com/deals/v1/deal/213404277?hapikey=demo - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Access-Control-Allow-Credentials: - - 'false' - Content-Type: - - application/json; charset=UTF-8 - Vary: - - Accept-Encoding - - user-agent - Date: - - Thu, 02 Nov 2017 00:39:01 GMT - Content-Length: - - '1237' - Connection: - - keep-alive - body: - encoding: UTF-8 - string: '{"portalId":62515,"dealId":213404277,"isDeleted":false,"associations":{"associatedVids":[],"associatedCompanyIds":[592416090],"associatedDealIds":[]},"properties":{"amount":{"value":"30","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"amount","value":"30","timestamp":1509583141407,"source":"API","sourceVid":[]}]},"hs_lastmodifieddate":{"value":"1509583141407","timestamp":1509583141407,"source":"CALCULATED","sourceId":null,"versions":[{"name":"hs_lastmodifieddate","value":"1509583141407","timestamp":1509583141407,"source":"CALCULATED","sourceVid":[]}]},"num_associated_contacts":{"value":"0","timestamp":0,"source":"CALCULATED","sourceId":null,"versions":[{"name":"num_associated_contacts","value":"0","source":"CALCULATED","sourceVid":[]}]},"hs_createdate":{"value":"1509583141407","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"hs_createdate","value":"1509583141407","timestamp":1509583141407,"source":"API","sourceVid":[]}]},"createdate":{"value":"1509583141407","timestamp":1509583141407,"source":"API","sourceId":null,"versions":[{"name":"createdate","value":"1509583141407","timestamp":1509583141407,"source":"API","sourceVid":[]}]}},"imports":[],"stateChanges":[]}' - http_version: - recorded_at: Thu, 02 Nov 2017 00:39:01 GMT -recorded_with: VCR 3.0.3 diff --git a/spec/lib/hubspot/deal_spec.rb b/spec/lib/hubspot/deal_spec.rb index b6cb325b..444aa611 100644 --- a/spec/lib/hubspot/deal_spec.rb +++ b/spec/lib/hubspot/deal_spec.rb @@ -68,9 +68,9 @@ end describe '.find_by_company' do - cassette 'deal_find_by_company' - let(:company) { Hubspot::Company.create(name: 'Test Company') } - let(:deal) { Hubspot::Deal.create!(portal_id, [company.id], [vid], { amount: amount }) } + cassette + let(:company) { create :company } + let!(:deal) { Hubspot::Deal.create!(portal_id, [company.id], [], { amount: amount }) } it 'returns company deals' do deals = Hubspot::Deal.find_by_company(company) @@ -79,6 +79,18 @@ end end + describe '.find_by_contact' do + cassette + let(:contact) { create :contact } + let!(:deal) { Hubspot::Deal.create!(portal_id, [], [contact.id], { amount: amount }) } + + it 'returns contact deals' do + deals = Hubspot::Deal.find_by_contact(contact) + deals.first.deal_id.should eql deal.deal_id + deals.first.properties['amount'].should eql amount + end + end + describe '.recent' do cassette 'find_all_recent_updated_deals'