From 1482898efdc2a0ed88b0841e83f4a0ad2cd3394a Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Fri, 6 Jul 2018 16:03:42 +0200 Subject: [PATCH 1/2] Add event --- lib/hubspot-ruby.rb | 1 + lib/hubspot/connection.rb | 7 +++++ lib/hubspot/event.rb | 21 +++++++++++++ spec/lib/hubspot/connection_spec.rb | 25 ++++++++++++++++ spec/lib/hubspot/event_spec.rb | 46 +++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 lib/hubspot/event.rb create mode 100644 spec/lib/hubspot/event_spec.rb diff --git a/lib/hubspot-ruby.rb b/lib/hubspot-ruby.rb index ebae0ad6..cbfcde4f 100644 --- a/lib/hubspot-ruby.rb +++ b/lib/hubspot-ruby.rb @@ -10,6 +10,7 @@ require 'hubspot/contact' require 'hubspot/contact_properties' require 'hubspot/contact_list' +require 'hubspot/event' require 'hubspot/form' require 'hubspot/blog' require 'hubspot/topic' diff --git a/lib/hubspot/connection.rb b/lib/hubspot/connection.rb index 7c87e2dc..d93d4fa3 100644 --- a/lib/hubspot/connection.rb +++ b/lib/hubspot/connection.rb @@ -100,4 +100,11 @@ def self.submit(path, opts) post(url, body: opts[:body], headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }) end end + + class EventConnection < Connection + def self.complete(path, opts) + url = generate_url(path, opts[:params], { base_url: 'https://track.hubspot.com', hapikey: false }) + get(url, body: opts[:body], headers: opts[:headers]) + end + end end diff --git a/lib/hubspot/event.rb b/lib/hubspot/event.rb new file mode 100644 index 00000000..04ec9091 --- /dev/null +++ b/lib/hubspot/event.rb @@ -0,0 +1,21 @@ +require 'hubspot/utils' + +module Hubspot + # + # HubSpot Events HTTP API + # + # {https://developers.hubspot.com/docs/methods/enterprise_events/http_api} + # + class Event + POST_EVENT_PATH = '/v1/event' + + class << self + def complete(event_id, email, options = {}) + default_params = { _n: event_id, _a: Hubspot::Config.portal_id, email: email } + options[:params] = default_params.merge(options[:params] || {}) + + Hubspot::EventConnection.complete(POST_EVENT_PATH, options).success? + end + end + end +end diff --git a/spec/lib/hubspot/connection_spec.rb b/spec/lib/hubspot/connection_spec.rb index a360c7ef..3d854825 100644 --- a/spec/lib/hubspot/connection_spec.rb +++ b/spec/lib/hubspot/connection_spec.rb @@ -122,3 +122,28 @@ end end end + +describe Hubspot::EventConnection do + describe '.complete' do + let(:path) { '/path' } + let(:options) { { params: {} } } + + subject { described_class.complete(path, options) } + before { Hubspot.configure(hapikey: 'demo', portal_id: '62515') } + + it 'calls get with a custom url' do + mock(described_class).get('https://track.hubspot.com/path', body: nil, headers: nil) { true } + subject + end + + context 'with more options' do + let(:headers) { { 'User-Agent' => 'something' } } + let(:options) { { params: {}, headers: headers } } + + it 'supports headers' do + mock(described_class).get('https://track.hubspot.com/path', body: nil, headers: headers) { true } + subject + end + end + end +end diff --git a/spec/lib/hubspot/event_spec.rb b/spec/lib/hubspot/event_spec.rb new file mode 100644 index 00000000..da8f66bc --- /dev/null +++ b/spec/lib/hubspot/event_spec.rb @@ -0,0 +1,46 @@ +describe Hubspot::Event do + let(:portal_id) { '62515' } + let(:sent_portal_id) { portal_id } + before { Hubspot.configure(hapikey: 'demo', portal_id: portal_id) } + + describe '.complete' do + let(:event_id) { '000000001625' } + let(:email) { 'testingapis@hubspot.com' } + let(:options) { {} } + let(:base_url) { 'https://track.hubspot.com' } + let(:url) { "#{base_url}/v1/event?_n=#{event_id}&_a=#{sent_portal_id}&email=#{CGI.escape email}" } + let(:http_response) do + mocked_response = mock('http_response') + mocked_response.success? { true } + mocked_response + end + subject { described_class.complete(event_id, email, options) } + + it 'sends a request to complete the event' do + mock(Hubspot::EventConnection).get(url, body: nil, headers: nil) { http_response } + expect(subject).to be true + end + + context 'with more options' do + context 'with headers' do + let(:headers) { { 'User-Agent' => 'something' } } + let(:options) { { headers: headers } } + + it 'sends headers' do + mock(Hubspot::EventConnection).get(url, body: nil, headers: headers) { http_response } + expect(subject).to be true + end + end + + context 'when overriding portal_id' do + let(:sent_portal_id) { '123' } + let(:options) { { params: { _a: sent_portal_id } } } + + it 'sends a request to the portal_id in the options' do + mock(Hubspot::EventConnection).get(url, body: nil, headers: nil) { http_response } + expect(subject).to be true + end + end + end + end +end From ad26f646dec019df18755e84ae8de1a9ca10730b Mon Sep 17 00:00:00 2001 From: Yannick Fonjallaz Date: Fri, 6 Jul 2018 16:04:06 +0200 Subject: [PATCH 2/2] Update contact create_or_update cassettes --- .../contact_create_or_update.yml | 190 +++++++++++++++++- .../contact_create_or_update_with_params.yml | 190 +++++++++++++++++- 2 files changed, 378 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/vcr_cassettes/contact_create_or_update.yml b/spec/fixtures/vcr_cassettes/contact_create_or_update.yml index 6882b9eb..d684ffe1 100644 --- a/spec/fixtures/vcr_cassettes/contact_create_or_update.yml +++ b/spec/fixtures/vcr_cassettes/contact_create_or_update.yml @@ -1180,4 +1180,192 @@ http_interactions: string: '{"vid":2984674,"canonical-vid":2984674,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMBepPnDiVhE6gTX7CstNXjSOzzbWb7xstkJ9t2MmL_jfmUSlfZXVzYah7L_3ODS_af99z6B7C0tcHpSHQmfVVPKG7N0Q80qp-yesx4ct73rMMqpyvDaSALVEkgugxr_DiF-GPk","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMBepPnDiVhE6gTX7CstNXjSOzzbWb7xstkJ9t2MmL_jfmUSlfZXVzYah7L_3ODS_af99z6B7C0tcHpSHQmfVVPKG7N0Q80qp-yesx4ct73rMMqpyvDaSALVEkgugxr_DiF-GPk/","properties":{"lastmodifieddate":{"value":"1476969096660","versions":[{"value":"1476969096660","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1476969096660,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"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":"1476969096431","versions":[{"value":"1476969096431","source-type":"API","source-id":"contact-upsert","source-label":null,"timestamp":1476969096431,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1476969096431","versions":[{"value":"1476969096431","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969096431,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969096431,"selected":false}]},"email":{"value":"newcontact1476969096@hsgem.com","versions":[{"value":"newcontact1476969096@hsgem.com","source-type":"API","source-id":"contact-upsert","source-label":null,"timestamp":1476969096431,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":2984674,"saved-at-timestamp":1476969096441,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact1476969096@hsgem.com","timestamp":1476969096431},{"type":"LEAD_GUID","value":"9637dd72-db9c-4614-9482-41e00469422d","timestamp":1476969096438}]}],"merge-audits":[]}' http_version: recorded_at: Thu, 20 Oct 2016 13:11:36 GMT -recorded_with: VCR 2.4.0 +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/newcontact1530885587@hsgem.com?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 06 Jul 2018 13:59:47 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d2c4d17ee522446baa1aeb8c470ccf7241530885587; expires=Sat, 06-Jul-19 + 13:59:47 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B520B0815CBABA30E220A693A095C61842C55B0C3000000000000000000 + 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: + - 43629809088ebd6f-CDG + body: + encoding: UTF-8 + string: '{"vid":7801874,"isNew":true}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:47 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/7801874/profile?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: + Date: + - Fri, 06 Jul 2018 13:59:47 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '692' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d91698e799edd528c5e2c0c80515cab5e1530885587; expires=Sat, 06-Jul-19 + 13:59:47 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B2ACB4B210DD369F156ABC9CEC1EEC9538835D79C000000000000000000 + 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: + - 4362980c08efa87b-CDG + body: + encoding: ASCII-8BIT + string: '{"vid":7801874,"canonical-vid":7801874,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPkCTH2YRtC_PupAofbB64CwyoppO70dDvoa_h4JYFz9CLgm-RQGW6UZeKVdpDXB0FbvA9VJ1vKGf0yYXCmWb6X9brAdYfhc8sUE2Auf3Z03sHNKq5M0IPu0d-X7N_GzKq1y8Ep","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPkCTH2YRtC_PupAofbB64CwyoppO70dDvoa_h4JYFz9CLgm-RQGW6UZeKVdpDXB0FbvA9VJ1vKGf0yYXCmWb6X9brAdYfhc8sUE2Auf3Z03sHNKq5M0IPu0d-X7N_GzKq1y8Ep/","properties":{"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"lastmodifieddate":{"value":"1530885587527","versions":[{"value":"1530885587527","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1530885587527,"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_email_domain":{"value":"hsgem.com","versions":[{"value":"hsgem.com","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"createdate":{"value":"1530885587469","versions":[{"value":"1530885587469","source-type":"API","source-id":"","source-label":null,"timestamp":1530885587469,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1530885587469","versions":[{"value":"1530885587469","source-type":"API","source-id":"","source-label":null,"timestamp":1530885587469,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":"","source-label":null,"timestamp":1530885587469,"selected":false}]},"email":{"value":"newcontact1530885587@hsgem.com","versions":[{"value":"newcontact1530885587@hsgem.com","source-type":"API","source-id":"","source-label":null,"timestamp":1530885587469,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":7801874,"saved-at-timestamp":1530885587475,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact1530885587@hsgem.com","timestamp":1530885587469,"is-primary":true},{"type":"LEAD_GUID","value":"a72de5dd-f76b-4bb0-a6b6-7a61f7801e18","timestamp":1530885587473}]}],"merge-audits":[]}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:47 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/newcontact1530885588@hsgem.com?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 06 Jul 2018 13:59:48 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d74bc8134087dc75c9f963c97ed70cf041530885588; expires=Sat, 06-Jul-19 + 13:59:48 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B302DE47FF5C60B036A12A16A84E5B5197D2B6B5C000000000000000000 + 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: + - 4362980e1bfdbd74-CDG + body: + encoding: UTF-8 + string: '{"vid":7801924,"isNew":true}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:48 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/7801924/profile?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: + Date: + - Fri, 06 Jul 2018 13:59:49 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '696' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d59b9629105b921fb26268e898c5123de1530885588; expires=Sat, 06-Jul-19 + 13:59:48 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2BC5DFD793DF2C2248299EB008650E7D825AF7323B000000000000000000 + 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: + - 43629810dec9bd74-CDG + body: + encoding: ASCII-8BIT + string: '{"vid":7801924,"canonical-vid":7801924,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mObTEZ98QN72i6aK00WPcEktl5xVI7L85TO6SqdLQDPRnC79w3RNdBylM5HmTzQNEDulux4D3VCO_bUojIGoX_9BGd7Z7XvahBpwg1P-VqPECrpZjp-VJQgAQMwKaikljWMKFO4","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mObTEZ98QN72i6aK00WPcEktl5xVI7L85TO6SqdLQDPRnC79w3RNdBylM5HmTzQNEDulux4D3VCO_bUojIGoX_9BGd7Z7XvahBpwg1P-VqPECrpZjp-VJQgAQMwKaikljWMKFO4/","properties":{"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"lastmodifieddate":{"value":"1530885588314","versions":[{"value":"1530885588314","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1530885588314,"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_email_domain":{"value":"hsgem.com","versions":[{"value":"hsgem.com","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"createdate":{"value":"1530885588251","versions":[{"value":"1530885588251","source-type":"API","source-id":"","source-label":null,"timestamp":1530885588251,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1530885588251","versions":[{"value":"1530885588251","source-type":"API","source-id":"","source-label":null,"timestamp":1530885588251,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":"","source-label":null,"timestamp":1530885588251,"selected":false}]},"email":{"value":"newcontact1530885588@hsgem.com","versions":[{"value":"newcontact1530885588@hsgem.com","source-type":"API","source-id":"","source-label":null,"timestamp":1530885588251,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":7801924,"saved-at-timestamp":1530885588267,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact1530885588@hsgem.com","timestamp":1530885588251,"is-primary":true},{"type":"LEAD_GUID","value":"c73b15d5-d722-4967-848c-f04a69056754","timestamp":1530885588259}]}],"merge-audits":[]}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:49 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/contact_create_or_update_with_params.yml b/spec/fixtures/vcr_cassettes/contact_create_or_update_with_params.yml index c32a180f..8a825990 100644 --- a/spec/fixtures/vcr_cassettes/contact_create_or_update_with_params.yml +++ b/spec/fixtures/vcr_cassettes/contact_create_or_update_with_params.yml @@ -1180,4 +1180,192 @@ http_interactions: string: '{"vid":2984625,"canonical-vid":2984625,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOuKc4GqPM1VcpxiQzoCquZKooKXLGzVMvSq60HgGhnc_JSCmI2fxXDjOZyI7AQ1PVBBZ_gQizd7heRQjvSW45gfXSsM0Lc4kBD6hRbfz0CkH0UbLejhLjD6Uj_73QANWv3AvxE","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOuKc4GqPM1VcpxiQzoCquZKooKXLGzVMvSq60HgGhnc_JSCmI2fxXDjOZyI7AQ1PVBBZ_gQizd7heRQjvSW45gfXSsM0Lc4kBD6hRbfz0CkH0UbLejhLjD6Uj_73QANWv3AvxE/","properties":{"firstname":{"value":"Hugh","versions":[{"value":"Hugh","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969098003,"selected":false}]},"lastmodifieddate":{"value":"1476969098234","versions":[{"value":"1476969098234","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1476969098234,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"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":"1476969098007","versions":[{"value":"1476969098007","source-type":"API","source-id":"contact-upsert","source-label":null,"timestamp":1476969098007,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1476969098007","versions":[{"value":"1476969098007","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969098007,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969098007,"selected":false}]},"email":{"value":"newcontact_x_1476969097@hsgem.com","versions":[{"value":"newcontact_x_1476969097@hsgem.com","source-type":"API","source-id":"contact-upsert","source-label":null,"timestamp":1476969098007,"selected":false}]},"lastname":{"value":"Jackman","versions":[{"value":"Jackman","source-type":"API","source-id":null,"source-label":null,"timestamp":1476969098003,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":2984625,"saved-at-timestamp":1476969098012,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact_x_1476969097@hsgem.com","timestamp":1476969098007},{"type":"LEAD_GUID","value":"6dcabca7-dafc-42f4-815f-5824bb11fe48","timestamp":1476969098011}]}],"merge-audits":[]}' http_version: recorded_at: Thu, 20 Oct 2016 13:11:38 GMT -recorded_with: VCR 2.4.0 +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/newcontact_x_1530885589@hsgem.com?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Hugh"},{"property":"lastname","value":"Jackman"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 06 Jul 2018 13:59:49 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d9201709d16c08cea681eb3b27f94627b1530885589; expires=Sat, 06-Jul-19 + 13:59:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B001CB726780E8D25E00D1F3D11E00B42D107C10C000000000000000000 + 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: + - 436298147fe0bd60-CDG + body: + encoding: UTF-8 + string: '{"vid":7801974,"isNew":true}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:49 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/7801974/profile?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: + Date: + - Fri, 06 Jul 2018 13:59:49 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '736' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=da4fab81309b911dba059674536c7dcfd1530885589; expires=Sat, 06-Jul-19 + 13:59:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B86D1F2DAEB2B73991389A700980715971BE6A244000000000000000000 + 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: + - 436298182ab5b77d-CDG + body: + encoding: ASCII-8BIT + string: '{"vid":7801974,"canonical-vid":7801974,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOWGQu-dF44hOQJSavHB-FyTpKWrxqwtexl-9ftRny_UNazs5K6KpmNiOYskFObcGalZFVPxET535rlUmdQcsGyUCO1j1uKuJouOfenaxosrE25hAynJwECaBHGffzifIFEHDgy","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOWGQu-dF44hOQJSavHB-FyTpKWrxqwtexl-9ftRny_UNazs5K6KpmNiOYskFObcGalZFVPxET535rlUmdQcsGyUCO1j1uKuJouOfenaxosrE25hAynJwECaBHGffzifIFEHDgy/","properties":{"firstname":{"value":"Hugh","versions":[{"value":"Hugh","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589272,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"lastmodifieddate":{"value":"1530885589356","versions":[{"value":"1530885589356","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1530885589356,"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_email_domain":{"value":"hsgem.com","versions":[{"value":"hsgem.com","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"createdate":{"value":"1530885589276","versions":[{"value":"1530885589276","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589276,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1530885589276","versions":[{"value":"1530885589276","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589276,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589276,"selected":false}]},"email":{"value":"newcontact_x_1530885589@hsgem.com","versions":[{"value":"newcontact_x_1530885589@hsgem.com","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589276,"selected":false}]},"lastname":{"value":"Jackman","versions":[{"value":"Jackman","source-type":"API","source-id":"","source-label":null,"timestamp":1530885589272,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":7801974,"saved-at-timestamp":1530885589288,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact_x_1530885589@hsgem.com","timestamp":1530885589276,"is-primary":true},{"type":"LEAD_GUID","value":"0229b3e3-4626-418e-84c8-b701cccf9292","timestamp":1530885589285}]}],"merge-audits":[]}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:49 GMT +- request: + method: post + uri: https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/newcontact_x_1530885590@hsgem.com?hapikey=demo + body: + encoding: UTF-8 + string: '{"properties":[{"property":"firstname","value":"Hugh"},{"property":"lastname","value":"Jackman"}]}' + headers: + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 06 Jul 2018 13:59:50 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=daa43cd4a33a35b83c6a9d5acd4654ed41530885590; expires=Sat, 06-Jul-19 + 13:59:50 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2BA9C0BB4AAB58E66109E3621B5E6508F624C34A22000000000000000000 + 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: + - 4362981a591bb7d7-CDG + body: + encoding: UTF-8 + string: '{"vid":7802024,"isNew":true}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:50 GMT +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/contact/vid/7802024/profile?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: + Date: + - Fri, 06 Jul 2018 13:59:50 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '735' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=dbca34f679f35f5c9eaafc81f5276808a1530885590; expires=Sat, 06-Jul-19 + 13:59:50 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B5E5D0C2A9A12B9A86ED25B99C26CEA3D6BE42DE2000000000000000000 + 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: + - 4362981dcb2ba87b-CDG + body: + encoding: ASCII-8BIT + string: '{"vid":7802024,"canonical-vid":7802024,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPqnew1r6L5mzzvh5uDv85wcDsKuYGORSCXYnG7VrXHC4QpbzazBZyTccDTAA7Ztl0IDSiZl5z11Rjn7kBCw8M2eQFZLCW0zbe1YlarC_Cw6KkuYId7u5ERQe_3sY-qzmiTY8ib","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPqnew1r6L5mzzvh5uDv85wcDsKuYGORSCXYnG7VrXHC4QpbzazBZyTccDTAA7Ztl0IDSiZl5z11Rjn7kBCw8M2eQFZLCW0zbe1YlarC_Cw6KkuYId7u5ERQe_3sY-qzmiTY8ib/","properties":{"firstname":{"value":"Hugh","versions":[{"value":"Hugh","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590204,"selected":false}]},"num_conversion_events":{"value":"0","versions":[{"value":"0","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"lastmodifieddate":{"value":"1530885590298","versions":[{"value":"1530885590298","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":1530885590298,"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_email_domain":{"value":"hsgem.com","versions":[{"value":"hsgem.com","source-type":"CALCULATED","source-id":null,"source-label":null,"timestamp":0,"selected":false}]},"createdate":{"value":"1530885590209","versions":[{"value":"1530885590209","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590209,"selected":false}]},"hs_lifecyclestage_subscriber_date":{"value":"1530885590209","versions":[{"value":"1530885590209","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590209,"selected":false}]},"lifecyclestage":{"value":"subscriber","versions":[{"value":"subscriber","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590209,"selected":false}]},"email":{"value":"newcontact_x_1530885590@hsgem.com","versions":[{"value":"newcontact_x_1530885590@hsgem.com","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590209,"selected":false}]},"lastname":{"value":"Jackman","versions":[{"value":"Jackman","source-type":"API","source-id":"","source-label":null,"timestamp":1530885590204,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":7802024,"saved-at-timestamp":1530885590219,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"newcontact_x_1530885590@hsgem.com","timestamp":1530885590209,"is-primary":true},{"type":"LEAD_GUID","value":"75f09ef6-3841-4fcd-8f1c-6d071195e3fa","timestamp":1530885590215}]}],"merge-audits":[]}' + http_version: + recorded_at: Fri, 06 Jul 2018 13:59:50 GMT +recorded_with: VCR 4.0.0