diff --git a/lib/hubspot-ruby.rb b/lib/hubspot-ruby.rb index ebae0ad6..c2e3d8f1 100644 --- a/lib/hubspot-ruby.rb +++ b/lib/hubspot-ruby.rb @@ -19,6 +19,7 @@ require 'hubspot/owner' require 'hubspot/engagement' require 'hubspot/subscription' +require 'hubspot/workflow' module Hubspot def self.configure(config={}) diff --git a/lib/hubspot/contact.rb b/lib/hubspot/contact.rb index 465aaba5..26ac98a9 100644 --- a/lib/hubspot/contact.rb +++ b/lib/hubspot/contact.rb @@ -21,6 +21,7 @@ class Contact RECENTLY_CREATED_PATH = '/contacts/v1/lists/all/contacts/recent' CREATE_OR_UPDATE_PATH = '/contacts/v1/contact/createOrUpdate/email/:contact_email' QUERY_PATH = '/contacts/v1/search/query' + GET_ENROLLMENTS_PATH = '/automation/v2/workflows/enrollments/contacts/:vid' class << self # {https://developers.hubspot.com/docs/methods/contacts/create_contact} @@ -197,5 +198,11 @@ def destroy! def destroyed? !!@destroyed end + + def enrollments(opts={}) + Hubspot::Connection.get_json(GET_ENROLLMENTS_PATH, opts.merge({vid: @vid})) + end + + end end diff --git a/lib/hubspot/workflow.rb b/lib/hubspot/workflow.rb new file mode 100644 index 00000000..86d1456d --- /dev/null +++ b/lib/hubspot/workflow.rb @@ -0,0 +1,37 @@ +module Hubspot + # + # HubSpot Workflow API + # + # {https://developers.hubspot.com/docs/methods/workflows/workflows_overview} + # + # TODO: work on all endpoints + class Workflow + GET_WORKFLOWS_PATH = '/automation/v3/workflows' + ENROLL_A_CONTACT_PATH = '/automation/v2/workflows/:workflowId/enrollments/contacts/:email' + + class << self + # {https://developers.hubspot.com/docs/methods/workflows/v3/get_workflows} + def all(opts={}) + response = Hubspot::Connection.get_json(GET_WORKFLOWS_PATH, opts) + response["workflows"].map! { |workflow| new(workflow) } + end + end + + attr_reader :id, :name + + def initialize(response_hash) + @name = response_hash['name'] + @id = response_hash['id'] + end + + # {https://developers.hubspot.com/docs/methods/workflows/add_contact} + def enroll_contact(email:) + json = {params: + {email: email, workflowId: @id}, + body: {} + } + Hubspot::Connection.post_json(ENROLL_A_CONTACT_PATH, json) + end + + end +end diff --git a/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_email.yml b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_email.yml new file mode 100644 index 00000000..e4a89c58 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_email.yml @@ -0,0 +1,46 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/automation/v2/workflows/2582322/enrollments/contacts/hahha@hubspot.com?hapikey=demo + body: + encoding: UTF-8 + string: "{}" + headers: + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Fri, 16 Feb 2018 21:36:49 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '191' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d9c760cf3cc056603a6ec8a36c44119aa1518817009; expires=Sat, 16-Feb-19 + 21:36:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + X-Hubspot-Notfound: + - 'true' + X-Trace: + - 2B5E01D3EBB7F53B8A53B3580CB84212BD3C415F68000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a507bf0f99e6-EWR + body: + encoding: UTF-8 + string: '{"status":"error","message":"Couldn''t find a Contact with the email + ''hahha@hubspot.com''","correlationId":"2981981b-825a-4930-aca4-3440a6f80022","requestId":"e4b40c14c7a5211d9086cde0731d04f0"}' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:49 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_workflowId.yml b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_workflowId.yml new file mode 100644 index 00000000..45d62589 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_failed_workflowId.yml @@ -0,0 +1,45 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/automation/v2/workflows/22210900/enrollments/contacts/testingapis@hubspot.com?hapikey=demo + body: + encoding: UTF-8 + string: "{}" + headers: + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Fri, 16 Feb 2018 21:36:50 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '151' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d000e39c41c4b9b533e365161ba9723f31518817009; expires=Sat, 16-Feb-19 + 21:36:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + X-Hubspot-Notfound: + - 'true' + X-Trace: + - 2BD609D86865AA2954AE3E9B2FCEBF3715B96D3D9A000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a5084d4399ec-EWR + body: + encoding: UTF-8 + string: '{"status":"error","message":"resource not found","correlationId":"44a5e851-85a7-4db0-b3dd-f19b6d1f50ea","requestId":"1c7314ca1b7b601f7b5da2470aeadca6"}' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:50 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_no_steps.yml b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_no_steps.yml new file mode 100644 index 00000000..64fa3341 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_no_steps.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/automation/v2/workflows/2325759/enrollments/contacts/testingapis@hubspot.com?hapikey=demo + body: + encoding: UTF-8 + string: "{}" + headers: + Content-Type: + - application/json + response: + status: + code: 412 + message: Precondition Failed + headers: + Date: + - Fri, 16 Feb 2018 21:36:49 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '210' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d9c760cf3cc056603a6ec8a36c44119aa1518817009; expires=Sat, 16-Feb-19 + 21:36:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + X-Trace: + - 2BA8C121309A20E64F119B859F3C2A2BBD4F06F258000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a506ee6a99e6-EWR + body: + encoding: UTF-8 + string: '{"status":"error","message":"There are no steps on this workflow to + execute","correlationId":"1efbf441-0c42-44b4-9b1a-c2c7c709c646","type":"WORKFLOW_HAS_NO_STEPS","requestId":"123f9921ebf7bcf951dc4af9bc15a696"}' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:49 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_success.yml b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_success.yml new file mode 100644 index 00000000..6483c081 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/enroll_contact_in_workflow_success.yml @@ -0,0 +1,39 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.hubapi.com/automation/v2/workflows/2582322/enrollments/contacts/testingapis@hubspot.com?hapikey=demo + body: + encoding: UTF-8 + string: "{}" + headers: + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Date: + - Fri, 16 Feb 2018 21:36:49 GMT + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d19711a529ce92f647b8eea27fe2f76451518817009; expires=Sat, 16-Feb-19 + 21:36:49 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + X-Trace: + - 2BD087F471301899ADAE4A4493C9745D79C82F4BCE000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a506084899f8-EWR + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:49 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/find_all_workflows.yml b/spec/fixtures/vcr_cassettes/find_all_workflows.yml new file mode 100644 index 00000000..ebb3309a --- /dev/null +++ b/spec/fixtures/vcr_cassettes/find_all_workflows.yml @@ -0,0 +1,121 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.hubapi.com/automation/v3/workflows?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, 16 Feb 2018 21:36:50 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '1686' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d563de5adc62af654bf2f211f593621fd1518817010; expires=Sat, 16-Feb-19 + 21:36:50 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding, User-Agent + X-Trace: + - 2BA03334E84BF93B65F22E19F21441485C1914D4E2000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a508cc109278-EWR + body: + encoding: ASCII-8BIT + string: '{"workflows":[{"type":"DRIP_DELAY","name":"New Workflow","id":2325759,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510086175105},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510086175104},"originalAuthorUserId":215482,"insertedAt":1510086175105,"updatedAt":1510086175105,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":299452,"active":299453,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"Test","id":2349483,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2349483/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510718106596},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510717895133},"originalAuthorUserId":215482,"insertedAt":1510717895133,"updatedAt":1510718106596,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300700,"active":300701,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"CA + Test","id":2352932,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2352932/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510798127260},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510782688718},"originalAuthorUserId":215482,"insertedAt":1510782688718,"updatedAt":1510798127260,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300772,"active":300773,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"CA + Test (cloned)","id":2354553,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2354553/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510828566598},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510828546381},"originalAuthorUserId":215482,"insertedAt":1510828546381,"updatedAt":1510828566598,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300813,"active":300814,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"MyTest","id":2355345,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510842554848},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510842554848},"originalAuthorUserId":215482,"insertedAt":1510842554848,"updatedAt":1510842554848,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300817,"active":300818,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"On + Demand Update","id":2361926,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2361926/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510962826774},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510962760211},"originalAuthorUserId":215482,"insertedAt":1510962760211,"updatedAt":1510962826774,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":301060,"active":301061,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"DiscoverOrg","id":2371909,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2371909/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511304680292},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511304582530},"originalAuthorUserId":215482,"insertedAt":1511304582531,"updatedAt":1511304680292,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":377557,"active":377558,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"test","id":2376914,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2376914/settings/general"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511437718083},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511437416318},"originalAuthorUserId":215482,"insertedAt":1511437416318,"updatedAt":1511437718083,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":401352,"active":401353,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"New + Workflow","id":2376990,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2376990/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511438953892},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511438943908},"originalAuthorUserId":215482,"insertedAt":1511438943908,"updatedAt":1511438953892,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":401359,"active":401360,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"ID","id":2385708,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2385708/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511825906867},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511825840420},"originalAuthorUserId":215482,"insertedAt":1511825840420,"updatedAt":1511825906867,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402117,"active":402118,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"test8 + (cloned)","id":2399512,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/?sortBy=totalContacts&sortOrder=descending"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512128229232},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/?sortBy=totalContacts&sortOrder=descending"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512128229231},"originalAuthorUserId":215482,"insertedAt":1512128229232,"updatedAt":1512128229232,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402417,"active":402418,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"testing","id":2399515,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2399515/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512128457342},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512128345394},"originalAuthorUserId":215482,"insertedAt":1512128345394,"updatedAt":1512128457342,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402421,"active":402422,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"test + workflow EGR","id":2418779,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2418779/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512660443400},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512660399633},"originalAuthorUserId":215482,"insertedAt":1512660399633,"updatedAt":1512660443400,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403243,"active":403244,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"qwerty","id":2422013,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422013/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512723108969},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512722505452},"originalAuthorUserId":215482,"insertedAt":1512722505452,"updatedAt":1512723108969,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403331,"active":403332,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"test + form flow","id":2422103,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422103/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512725932330},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512725722153},"originalAuthorUserId":215482,"insertedAt":1512725722153,"updatedAt":1512725932330,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403352,"active":403353,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"tst","id":2422356,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422356/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512733480320},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512733416038},"originalAuthorUserId":215482,"insertedAt":1512733416038,"updatedAt":1512733480320,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403409,"active":403410,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"tests","id":2524746,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2524746/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516933726039},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516131600255},"originalAuthorUserId":215482,"insertedAt":1516131600288,"updatedAt":1516933726039,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":410363,"active":410364,"steps":[0]},"contactCounts":{"active":0,"enrolled":26},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"Bora","id":2524867,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2524867/edit"},"updatedByUser":{"userId":3076259,"userEmail":"tiagoluiz_design@yahoo.com.br"},"updatedAt":1516133139605},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":3076259,"userEmail":"tiagoluiz_design@yahoo.com.br"},"createdAt":1516133050697},"originalAuthorUserId":3076259,"insertedAt":1516133050720,"updatedAt":1516133139605,"lastUpdatedByUserId":3076259,"contactListIds":{"enrolled":410367,"active":410368,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"New + Purchase","id":2529214,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516219567969},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516219567969},"originalAuthorUserId":215482,"insertedAt":1516219567999,"updatedAt":1516219567969,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":410676,"active":410677,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"LeeTest","id":2542332,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2542332/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516648416782},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516647653339},"originalAuthorUserId":215482,"insertedAt":1516647653380,"updatedAt":1516648416782,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":411934,"active":411935,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"IW + Test","id":2542884,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2542884/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516654954537},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516653799110},"originalAuthorUserId":215482,"insertedAt":1516653799139,"updatedAt":1516654954537,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":411973,"active":411974,"steps":[0]},"contactCounts":{"active":0,"enrolled":1},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"New + Workflow","id":2555705,"enabled":false,"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2555705/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516879311036},"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516879227954},"originalAuthorUserId":215482,"insertedAt":1516879228077,"updatedAt":1516879311036,"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":412784,"active":412785,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582283,"enabled":false,"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522396784},"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522396784},"insertedAt":1517522397424,"updatedAt":1517522396784,"contactListIds":{"enrolled":414647,"active":414648,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582308,"enabled":false,"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522576931},"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522576931},"insertedAt":1517522577040,"updatedAt":1517522576931,"contactListIds":{"enrolled":414651,"active":414652,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582322,"enabled":false,"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522774672},"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522774672},"insertedAt":1517522774727,"updatedAt":1517522774672,"contactListIds":{"enrolled":414655,"active":414656,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"personaTagIds":[]}]}' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:50 GMT +- request: + method: get + uri: https://api.hubapi.com/automation/v3/workflows?hapikey=demo&page=2 + 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, 16 Feb 2018 21:36:50 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '1676' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d0a7b113a04145cf2b3903f97c3b99e501518817010; expires=Sat, 16-Feb-19 + 21:36:50 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding, User-Agent + X-Trace: + - 2BBAB5A9ACB79BBF815839515CC69A27FEE8E3420B000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3ee3a509b840922a-EWR + body: + encoding: ASCII-8BIT + string: '{"workflows":[{"type":"DRIP_DELAY","name":"New Workflow","id":2325759,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510086175104},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":299452,"active":299453,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510086175105},"insertedAt":1510086175105,"updatedAt":1510086175105},{"type":"DRIP_DELAY","name":"Test","id":2349483,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510717895133},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300700,"active":300701,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2349483/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510718106596},"insertedAt":1510717895133,"updatedAt":1510718106596},{"type":"DRIP_DELAY","name":"CA + Test","id":2352932,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510782688718},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300772,"active":300773,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2352932/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510798127260},"insertedAt":1510782688718,"updatedAt":1510798127260},{"type":"DRIP_DELAY","name":"CA + Test (cloned)","id":2354553,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510828546381},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300813,"active":300814,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2354553/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510828566598},"insertedAt":1510828546381,"updatedAt":1510828566598},{"type":"DRIP_DELAY","name":"MyTest","id":2355345,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510842554848},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":300817,"active":300818,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510842554848},"insertedAt":1510842554848,"updatedAt":1510842554848},{"type":"DRIP_DELAY","name":"On + Demand Update","id":2361926,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1510962760211},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":301060,"active":301061,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2361926/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1510962826774},"insertedAt":1510962760211,"updatedAt":1510962826774},{"type":"DRIP_DELAY","name":"DiscoverOrg","id":2371909,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511304582530},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":377557,"active":377558,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2371909/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511304680292},"insertedAt":1511304582531,"updatedAt":1511304680292},{"type":"DRIP_DELAY","name":"test","id":2376914,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511437416318},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":401352,"active":401353,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2376914/settings/general"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511437718083},"insertedAt":1511437416318,"updatedAt":1511437718083},{"type":"DRIP_DELAY","name":"New + Workflow","id":2376990,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511438943908},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":401359,"active":401360,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2376990/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511438953892},"insertedAt":1511438943908,"updatedAt":1511438953892},{"type":"DRIP_DELAY","name":"ID","id":2385708,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1511825840420},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402117,"active":402118,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2385708/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1511825906867},"insertedAt":1511825840420,"updatedAt":1511825906867},{"type":"DRIP_DELAY","name":"test8 + (cloned)","id":2399512,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/?sortBy=totalContacts&sortOrder=descending"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512128229231},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402417,"active":402418,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/?sortBy=totalContacts&sortOrder=descending"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512128229232},"insertedAt":1512128229232,"updatedAt":1512128229232},{"type":"DRIP_DELAY","name":"testing","id":2399515,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512128345394},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":402421,"active":402422,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2399515/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512128457342},"insertedAt":1512128345394,"updatedAt":1512128457342},{"type":"DRIP_DELAY","name":"test + workflow EGR","id":2418779,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512660399633},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403243,"active":403244,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2418779/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512660443400},"insertedAt":1512660399633,"updatedAt":1512660443400},{"type":"DRIP_DELAY","name":"qwerty","id":2422013,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512722505452},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403331,"active":403332,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422013/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512723108969},"insertedAt":1512722505452,"updatedAt":1512723108969},{"type":"DRIP_DELAY","name":"test + form flow","id":2422103,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512725722153},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403352,"active":403353,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422103/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512725932330},"insertedAt":1512725722153,"updatedAt":1512725932330},{"type":"DRIP_DELAY","name":"tst","id":2422356,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1512733416038},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":403409,"active":403410,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2422356/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1512733480320},"insertedAt":1512733416038,"updatedAt":1512733480320},{"type":"DRIP_DELAY","name":"tests","id":2524746,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516131600255},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":410363,"active":410364,"steps":[0]},"contactCounts":{"active":0,"enrolled":26},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2524746/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516933726039},"insertedAt":1516131600288,"updatedAt":1516933726039},{"type":"DRIP_DELAY","name":"Bora","id":2524867,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515"},"createdByUser":{"userId":3076259,"userEmail":"tiagoluiz_design@yahoo.com.br"},"createdAt":1516133050697},"originalAuthorUserId":3076259,"personaTagIds":[],"lastUpdatedByUserId":3076259,"contactListIds":{"enrolled":410367,"active":410368,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2524867/edit"},"updatedByUser":{"userId":3076259,"userEmail":"tiagoluiz_design@yahoo.com.br"},"updatedAt":1516133139605},"insertedAt":1516133050720,"updatedAt":1516133139605},{"type":"DRIP_DELAY","name":"New + Purchase","id":2529214,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516219567969},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":410676,"active":410677,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516219567969},"insertedAt":1516219567999,"updatedAt":1516219567969},{"type":"DRIP_DELAY","name":"LeeTest","id":2542332,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516647653339},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":411934,"active":411935,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2542332/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516648416782},"insertedAt":1516647653380,"updatedAt":1516648416782},{"type":"DRIP_DELAY","name":"IW + Test","id":2542884,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516653799110},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":411973,"active":411974,"steps":[0]},"contactCounts":{"active":0,"enrolled":1},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2542884/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516654954537},"insertedAt":1516653799139,"updatedAt":1516654954537},{"type":"DRIP_DELAY","name":"New + Workflow","id":2555705,"enabled":false,"creationSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/create"},"createdByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"createdAt":1516879227954},"originalAuthorUserId":215482,"personaTagIds":[],"lastUpdatedByUserId":215482,"contactListIds":{"enrolled":412784,"active":412785,"steps":[]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"WORKFLOWS_APP","serviceName":"https://app.hubspot.com/workflows/62515/flow/2555705/edit"},"updatedByUser":{"userId":215482,"userEmail":"testapi@hubspot.com"},"updatedAt":1516879311036},"insertedAt":1516879228077,"updatedAt":1516879311036},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582283,"enabled":false,"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522396784},"personaTagIds":[],"contactListIds":{"enrolled":414647,"active":414648,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522396784},"insertedAt":1517522397424,"updatedAt":1517522396784},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582308,"enabled":false,"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522576931},"personaTagIds":[],"contactListIds":{"enrolled":414651,"active":414652,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522576931},"insertedAt":1517522577040,"updatedAt":1517522576931},{"type":"DRIP_DELAY","name":"Test + Workflow","id":2582322,"enabled":false,"creationSource":{"sourceApplication":{"source":"DIRECT_API"},"createdAt":1517522774672},"personaTagIds":[],"contactListIds":{"enrolled":414655,"active":414656,"steps":[0]},"contactCounts":{"active":0,"enrolled":0},"updateSource":{"sourceApplication":{"source":"DIRECT_API"},"updatedAt":1517522774672},"insertedAt":1517522774727,"updatedAt":1517522774672}]}' + http_version: + recorded_at: Fri, 16 Feb 2018 21:36:50 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/vcr_cassettes/workflow_enrollments.yml b/spec/fixtures/vcr_cassettes/workflow_enrollments.yml new file mode 100644 index 00000000..5c20345f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/workflow_enrollments.yml @@ -0,0 +1,99 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?hapikey=demo&property=email + 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: + - Mon, 26 Feb 2018 21:32:17 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '4596' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d1193a35bf5705568b48d2dff78c5434a1519680736; expires=Tue, 26-Feb-19 + 21:32:16 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding + - Accept-Encoding + X-Trace: + - 2B43303F2C3B25D34CD42A8FEB0063C2249A018AD2000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3f36041e2f7399e0-EWR + body: + encoding: ASCII-8BIT + string: '{"contacts":[{"addedAt":1519680640618,"vid":6165724,"canonical-vid":6165724,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMXRb1Kzg4knSY-ftJPeUXQoYSSzQ5iam_apwKnzekEtf3ZHRz8YQMoAjQsU0lYmaxdkR9MyihOmgYdO_Vra2rDjt9vFQmQG0EpLEOyyCGV2-rwfgGuSdEV58yjhmfXlLdcYORa","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMXRb1Kzg4knSY-ftJPeUXQoYSSzQ5iam_apwKnzekEtf3ZHRz8YQMoAjQsU0lYmaxdkR9MyihOmgYdO_Vra2rDjt9vFQmQG0EpLEOyyCGV2-rwfgGuSdEV58yjhmfXlLdcYORa/","properties":{"lastmodifieddate":{"value":"1519680640618"}},"form-submissions":[],"identity-profiles":[{"vid":6165724,"saved-at-timestamp":1519680628858,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"243d6327-a9df-455d-83ae-8d155edb286f","timestamp":1519680628853}]}],"merge-audits":[]},{"addedAt":1519679597795,"vid":6165674,"canonical-vid":6165674,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mM1wA_mZiLDPDVbWOxsW0T1H99gWBjK8GETLubfvqxGUy3YMXJRcbn1b8_hk2o0KXteGOfNfjIAwNNs-Jw0gzPHHQj8wFLXZlVsizKqIe-JBuLHBf5I_WpY_9n3uMyij9diQ-Ye","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mM1wA_mZiLDPDVbWOxsW0T1H99gWBjK8GETLubfvqxGUy3YMXJRcbn1b8_hk2o0KXteGOfNfjIAwNNs-Jw0gzPHHQj8wFLXZlVsizKqIe-JBuLHBf5I_WpY_9n3uMyij9diQ-Ye/","properties":{"lastmodifieddate":{"value":"1519679597795"}},"form-submissions":[],"identity-profiles":[{"vid":6165674,"saved-at-timestamp":1519679570662,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"6e2d65a0-9e6b-4b50-93bb-03b47db5b32b","timestamp":1519679570659}]}],"merge-audits":[]},{"addedAt":1519678068471,"vid":6165524,"canonical-vid":6165524,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMgm8pmhLoRFxFavCvqI8TGXSAqjiLbHXXpEGOT_dkXxn9va-xOx5Xho4ivHj-un0qE3gA3e6-jMmxtmqD1gFhbkRa8S7uT8lQBtG74apvIE5cPL5bCvcBWHRNWKrvLeF0f4N5v","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMgm8pmhLoRFxFavCvqI8TGXSAqjiLbHXXpEGOT_dkXxn9va-xOx5Xho4ivHj-un0qE3gA3e6-jMmxtmqD1gFhbkRa8S7uT8lQBtG74apvIE5cPL5bCvcBWHRNWKrvLeF0f4N5v/","properties":{"lastmodifieddate":{"value":"1519678068471"},"email":{"value":"test.02260246@test.com"}},"form-submissions":[],"identity-profiles":[{"vid":6165524,"saved-at-timestamp":1519678063030,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"test.02260246@test.com","timestamp":1519678062905,"is-primary":true},{"type":"LEAD_GUID","value":"0a3fe910-a655-4dd9-bd92-9a0e2adea1f3","timestamp":1519678062964}]}],"merge-audits":[]},{"addedAt":1519676799266,"vid":6165374,"canonical-vid":6165374,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPodV5N3Zxw_jDQczFdhALUG_3Gru4Y4OUbhCOjz-mjclYZvqzoqXK-gk_q8capGNNNKL4DDsJlGvYShwo_T47T8DnnER0NSPNtFRgGaoV7kUrOI-iZ_aW8ICSOzsf4jnkyHV5s","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPodV5N3Zxw_jDQczFdhALUG_3Gru4Y4OUbhCOjz-mjclYZvqzoqXK-gk_q8capGNNNKL4DDsJlGvYShwo_T47T8DnnER0NSPNtFRgGaoV7kUrOI-iZ_aW8ICSOzsf4jnkyHV5s/","properties":{"lastmodifieddate":{"value":"1519676799266"}},"form-submissions":[],"identity-profiles":[{"vid":6165374,"saved-at-timestamp":1519676790824,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"76368eab-8eb3-4e6f-8520-3c96f5924234","timestamp":1519676790820}]}],"merge-audits":[]},{"addedAt":1519676656029,"vid":6165324,"canonical-vid":6165324,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mM1OZsQsM4hK2V0wMsgcfpguUUdO7b-1Q62yt7dhFwDuDG37ZbUQcOJkQtqrDRVMqG7WrwSEpJGIabDrgj0Qm2W4ggoECCORt07KrjrzOXuZaDTg95K1q-J4nO-zKVsno-siYnq","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mM1OZsQsM4hK2V0wMsgcfpguUUdO7b-1Q62yt7dhFwDuDG37ZbUQcOJkQtqrDRVMqG7WrwSEpJGIabDrgj0Qm2W4ggoECCORt07KrjrzOXuZaDTg95K1q-J4nO-zKVsno-siYnq/","properties":{"lastmodifieddate":{"value":"1519676656029"}},"form-submissions":[],"identity-profiles":[{"vid":6165324,"saved-at-timestamp":1519676647501,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"e6a413a4-959e-4965-80c8-fd6ff257d809","timestamp":1519676647498}]}],"merge-audits":[]},{"addedAt":1519675968631,"vid":6165274,"canonical-vid":6165274,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOgLVVWuWpKkaUyveyFfV7ulRpdNU_Od2NpAeVJBwrXBi7KCZxI6SzuqTknjPysS0YZrkp8K9hPs-qvW3KpP7bfETg4vnLpXQwwe4aRIH5dAbSgYM_WwZdB38O7Ax6n4UA7KAqx","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOgLVVWuWpKkaUyveyFfV7ulRpdNU_Od2NpAeVJBwrXBi7KCZxI6SzuqTknjPysS0YZrkp8K9hPs-qvW3KpP7bfETg4vnLpXQwwe4aRIH5dAbSgYM_WwZdB38O7Ax6n4UA7KAqx/","properties":{"lastmodifieddate":{"value":"1519675968631"}},"form-submissions":[],"identity-profiles":[{"vid":6165274,"saved-at-timestamp":1519675958776,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"577ac12b-80c4-4914-aaa1-e889b7d1d61a","timestamp":1519675958772}]}],"merge-audits":[]},{"addedAt":1519675510342,"vid":6165224,"canonical-vid":6165224,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMApG9Gpf61xwZ5tgPD1FPkHQw4AAjzyvq0yBzQLhlFnozRdZJqK21m7hpz6cq3VLmur_9eo09hta6oTMoJQDerQcrpKwAYa-5BEbpONMkRlIaGryp_bO2fniOL2kDRWJ7wWL2E","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMApG9Gpf61xwZ5tgPD1FPkHQw4AAjzyvq0yBzQLhlFnozRdZJqK21m7hpz6cq3VLmur_9eo09hta6oTMoJQDerQcrpKwAYa-5BEbpONMkRlIaGryp_bO2fniOL2kDRWJ7wWL2E/","properties":{"lastmodifieddate":{"value":"1519675510342"}},"form-submissions":[],"identity-profiles":[{"vid":6165224,"saved-at-timestamp":1519675503936,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"f21f3b99-613c-44f4-9f41-ff8488d2b2c0","timestamp":1519675503932}]}],"merge-audits":[]},{"addedAt":1519674797170,"vid":6165174,"canonical-vid":6165174,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMzrKMhVDFS-N6wGEWfr73GRca855cLBoziOaaJkNPPWJW3q6k5q7oaZnTBWy7PBnYX98CiLd1fdLK5Ei7gLL9jpUPgdSL9n4pVJZeX26QRetNxrz7jaLejWzk_Vs4i5fTrdfY_","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMzrKMhVDFS-N6wGEWfr73GRca855cLBoziOaaJkNPPWJW3q6k5q7oaZnTBWy7PBnYX98CiLd1fdLK5Ei7gLL9jpUPgdSL9n4pVJZeX26QRetNxrz7jaLejWzk_Vs4i5fTrdfY_/","properties":{"lastmodifieddate":{"value":"1519674797170"}},"form-submissions":[],"identity-profiles":[{"vid":6165174,"saved-at-timestamp":1519674780704,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"0f992e5e-dbdb-4148-88f6-1014d8d2cf33","timestamp":1519674780696}]}],"merge-audits":[]},{"addedAt":1519674424437,"vid":5875324,"canonical-vid":5875324,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPeZyk3boD9m-TPjVpXg4eO_B99L6xPwUJgA7akRS-KPJceq-sgmNk3gOa4YEfgb0pVe3YfPk2vIEPQmcdc_prJWnBWo_H1tmTqvyhOd5Igbpy0phkSRtksI7YcL4-zcA5otd7J","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPeZyk3boD9m-TPjVpXg4eO_B99L6xPwUJgA7akRS-KPJceq-sgmNk3gOa4YEfgb0pVe3YfPk2vIEPQmcdc_prJWnBWo_H1tmTqvyhOd5Igbpy0phkSRtksI7YcL4-zcA5otd7J/","properties":{"lastmodifieddate":{"value":"1519674424437"},"email":{"value":"nadya.shepida@gmail.com"}},"form-submissions":[{"conversion-id":"0c320bce-6e4a-4c29-a6d2-2004d8680351","timestamp":1519674422742,"form-id":"1e32cdda-b0ea-4e28-855c-f32a18b954b1","portal-id":62515,"page-url":"http://franz.youte.am/messages/624","page-title":"Message","title":"For + QA tests on dev server","form-type":"HUBSPOT","meta-data":[]}],"identity-profiles":[{"vid":5875324,"saved-at-timestamp":1516877750163,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"nadya.shepida@gmail.com","timestamp":1516877748592,"is-primary":true},{"type":"LEAD_GUID","value":"755dda95-3a96-4fae-8793-a7c09a2bb45a","timestamp":1516877750161}]}],"merge-audits":[]},{"addedAt":1519672867116,"vid":5883524,"canonical-vid":5883524,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPNAgGR918YHa4WVnuHmjksye37PL3Ip9GsSLfOfIdgMHdYGUXhD7Hbn2dX4w2eX5_IRvjd407kRxO_9QRAFtlDFWTBmyp2Hzv_qwh4ml5dgtxZjXYlAAONWrafA21TJqkQoQGX","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPNAgGR918YHa4WVnuHmjksye37PL3Ip9GsSLfOfIdgMHdYGUXhD7Hbn2dX4w2eX5_IRvjd407kRxO_9QRAFtlDFWTBmyp2Hzv_qwh4ml5dgtxZjXYlAAONWrafA21TJqkQoQGX/","properties":{"lastmodifieddate":{"value":"1519672867116"},"email":{"value":"test@hubspot.com"}},"form-submissions":[],"identity-profiles":[{"vid":5883524,"saved-at-timestamp":1516926593636,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"test@hubspot.com","timestamp":1516926593535,"is-primary":true},{"type":"LEAD_GUID","value":"af307972-dd3d-4a37-b071-d6f512941f95","timestamp":1516926593634}]}],"merge-audits":[]},{"addedAt":1519672835382,"vid":5794774,"canonical-vid":5794774,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPFb_HshyYyiIuMV3Whph0Lr39O0J3SgzhH2xf8E5GyFZwJo3FxZwNL0pAjuz1nZsqsKWWK2fM_fFt56bCguymDu1zjCC-DBp2RGH_GTw9MBgJIf9oKglK6C8YmMTK7TpjdxXMn","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPFb_HshyYyiIuMV3Whph0Lr39O0J3SgzhH2xf8E5GyFZwJo3FxZwNL0pAjuz1nZsqsKWWK2fM_fFt56bCguymDu1zjCC-DBp2RGH_GTw9MBgJIf9oKglK6C8YmMTK7TpjdxXMn/","properties":{"lastmodifieddate":{"value":"1519672835382"},"email":{"value":"sinoptik.lab@gmail.com"}},"form-submissions":[{"conversion-id":"83c9c37b-fa8b-4560-934a-59cfd6fe54a5","timestamp":1519672827732,"form-id":"1e32cdda-b0ea-4e28-855c-f32a18b954b1","portal-id":62515,"page-url":"http://franz.youte.am/messages/286","page-title":"Message","title":"For + QA tests on dev server","form-type":"HUBSPOT","meta-data":[]}],"identity-profiles":[{"vid":5794774,"saved-at-timestamp":1515995676811,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"sinoptik.lab@gmail.com","timestamp":1515995675516,"is-primary":true},{"type":"LEAD_GUID","value":"8f7aecb9-118a-4bce-971b-9b1530022e92","timestamp":1515995676808}]}],"merge-audits":[]},{"addedAt":1519672735796,"vid":6165124,"canonical-vid":6165124,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOoCuOdFO50RGXs8oj8aVIEV4OjRiFYuBBIshrDNpL4WpuzSIIkPXaPXdIoNSV4M7mmqnou576ov2Fp5glT74_nvRy7Jhsdvk6SPLHFWvWP3rgTLCpJDrNSjCmOQThVGqLLz1u0","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOoCuOdFO50RGXs8oj8aVIEV4OjRiFYuBBIshrDNpL4WpuzSIIkPXaPXdIoNSV4M7mmqnou576ov2Fp5glT74_nvRy7Jhsdvk6SPLHFWvWP3rgTLCpJDrNSjCmOQThVGqLLz1u0/","properties":{"lastmodifieddate":{"value":"1519672735796"}},"form-submissions":[],"identity-profiles":[{"vid":6165124,"saved-at-timestamp":1519672724271,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"064fc19d-ef4d-4768-8011-ab40892a7bc9","timestamp":1519672724268}]}],"merge-audits":[]},{"addedAt":1519672200622,"vid":6164874,"canonical-vid":6164874,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mMBYnBmZ5aekDR3Dl3zucIY-evgf4mFruEthYqhJJ8kHbWOHfYYf4bt_VsLHxTriwHfcs-Y9RRPqG5li8nx0GLYTPRNkBAu9eC_98UYgyA0WWMT-wdao7u78_kfe4RQXoRQloS_","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMBYnBmZ5aekDR3Dl3zucIY-evgf4mFruEthYqhJJ8kHbWOHfYYf4bt_VsLHxTriwHfcs-Y9RRPqG5li8nx0GLYTPRNkBAu9eC_98UYgyA0WWMT-wdao7u78_kfe4RQXoRQloS_/","properties":{"lastmodifieddate":{"value":"1519672200622"},"email":{"value":"test.02261224@test.com"}},"form-submissions":[],"identity-profiles":[{"vid":6164874,"saved-at-timestamp":1519669647366,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"test.02261224@test.com","timestamp":1519669647327,"is-primary":true},{"type":"LEAD_GUID","value":"f56e263f-ad5e-4ed5-8183-736f05696d62","timestamp":1519669647331}]}],"merge-audits":[]},{"addedAt":1519672200420,"vid":6164474,"canonical-vid":6164474,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mP9xIY1DaCsqbn4w7ZIFhiWPHqLOw5DcsLgdQopxITC7Ixwc5Dm4d_VVQdCewovIYsBt5kVQFzqXZkcdVSJxm75G_WQTfR6kFtkeJxVfilTVnAlSNVUjXVo-PpnYhq3hnnChd3o","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mP9xIY1DaCsqbn4w7ZIFhiWPHqLOw5DcsLgdQopxITC7Ixwc5Dm4d_VVQdCewovIYsBt5kVQFzqXZkcdVSJxm75G_WQTfR6kFtkeJxVfilTVnAlSNVUjXVo-PpnYhq3hnnChd3o/","properties":{"lastmodifieddate":{"value":"1519672200420"},"email":{"value":"test.02261123@test.com"}},"form-submissions":[],"identity-profiles":[{"vid":6164474,"saved-at-timestamp":1519665837320,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"test.02261123@test.com","timestamp":1519665837312,"is-primary":true},{"type":"LEAD_GUID","value":"e08d4da5-6cd5-426c-90dd-555f95eee434","timestamp":1519665837316}]}],"merge-audits":[]},{"addedAt":1519671601494,"vid":6165074,"canonical-vid":6165074,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPflc3fYqfF2XreOOpMezqJ4po4koUpGLQK9Mn4-Ay3UyQEl6VEUpOPp9fF8VX92rn-bQQ3vQ_rhjvMhngQ830NQQpIvXY0g7tB24tsDIudZQeofX0KtSNT1lCndHJo3ReL2UtZ","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPflc3fYqfF2XreOOpMezqJ4po4koUpGLQK9Mn4-Ay3UyQEl6VEUpOPp9fF8VX92rn-bQQ3vQ_rhjvMhngQ830NQQpIvXY0g7tB24tsDIudZQeofX0KtSNT1lCndHJo3ReL2UtZ/","properties":{"lastmodifieddate":{"value":"1519671601494"}},"form-submissions":[],"identity-profiles":[{"vid":6165074,"saved-at-timestamp":1519671592180,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"e26bf6e2-c980-469f-b9d1-73ca022eb52c","timestamp":1519671592174}]}],"merge-audits":[]},{"addedAt":1519671581511,"vid":6165024,"canonical-vid":6165024,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPJlXwdwaSTZo1v1fjVOdTneo80btV_avweyaQEgaEV3o0F7eA1VgCIvcnR5JuB08PL2XsD2nMA4iw3MMOyS7ak8QTPnpZ3IQfVrei0pS_whoL9DWhCEd8d2KHSkjguXiVIawOD","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPJlXwdwaSTZo1v1fjVOdTneo80btV_avweyaQEgaEV3o0F7eA1VgCIvcnR5JuB08PL2XsD2nMA4iw3MMOyS7ak8QTPnpZ3IQfVrei0pS_whoL9DWhCEd8d2KHSkjguXiVIawOD/","properties":{"lastmodifieddate":{"value":"1519671581511"}},"form-submissions":[],"identity-profiles":[{"vid":6165024,"saved-at-timestamp":1519671570212,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"139c2ce7-2d0c-4370-ab04-961b8af41a72","timestamp":1519671570208}]}],"merge-audits":[]},{"addedAt":1519670182522,"vid":6164924,"canonical-vid":6164924,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOjG1LDyNM5YZRRFpg0ex5BkDS-llpPDtgFFMfsw_BIz6LfArbqDKPKYGgJ714QCPzlEklxTm91XY1TaepSyiUQHjx2eXfDE72wanqcoSoU7D2xOps0UA7XtbiIu1AcxDnwAiTt","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOjG1LDyNM5YZRRFpg0ex5BkDS-llpPDtgFFMfsw_BIz6LfArbqDKPKYGgJ714QCPzlEklxTm91XY1TaepSyiUQHjx2eXfDE72wanqcoSoU7D2xOps0UA7XtbiIu1AcxDnwAiTt/","properties":{"lastmodifieddate":{"value":"1519670182522"}},"form-submissions":[],"identity-profiles":[{"vid":6164924,"saved-at-timestamp":1519670158258,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"20812e89-ddf8-47e5-a823-295ea6c03515","timestamp":1519670158255}]}],"merge-audits":[]},{"addedAt":1519670039646,"vid":5584674,"canonical-vid":5584674,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOnxOn915T-yCrBL4b8gO1PVcE_0I6frTkunCVLwPRRkW4Ep-rHpn-Pjl5cCBOeao6OzP5FYJpMDpazC-1m4U-ZPBz88m19uR6hCdhaXOAGMaVk9-IfS_bMXvXRPrAVPBg688te","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOnxOn915T-yCrBL4b8gO1PVcE_0I6frTkunCVLwPRRkW4Ep-rHpn-Pjl5cCBOeao6OzP5FYJpMDpazC-1m4U-ZPBz88m19uR6hCdhaXOAGMaVk9-IfS_bMXvXRPrAVPBg688te/","properties":{"lastmodifieddate":{"value":"1519670039646"},"email":{"value":"taras.bilohan@youteam.co.uk"}},"form-submissions":[{"conversion-id":"ff6898aa-d613-4e85-9fb1-0410fb377311","timestamp":1519670038202,"form-id":"1e32cdda-b0ea-4e28-855c-f32a18b954b1","portal-id":62515,"page-url":"http://youteam.mls/messages/602","page-title":"Message","title":"For + QA tests on dev server","form-type":"HUBSPOT","meta-data":[]}],"identity-profiles":[{"vid":5584674,"saved-at-timestamp":1518112607865,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"dd7eb52f-b046-4be0-bcea-476520881d65","timestamp":1513011432897},{"type":"EMAIL","value":"jinoti@pied-piper.org","timestamp":1516383596768,"is-secondary":true},{"type":"EMAIL","value":"wenita@pied-piper.org","timestamp":1516383634414,"is-secondary":true},{"type":"EMAIL","value":"peqe@pied-piper.org","timestamp":1516727722018,"is-secondary":true},{"type":"EMAIL","value":"bafufah@pied-piper.org","timestamp":1516799897435,"is-secondary":true},{"type":"EMAIL","value":"figumo@pied-piper.org","timestamp":1516800050317,"is-secondary":true},{"type":"EMAIL","value":"qelaje@pied-piper.org","timestamp":1517223041227,"is-secondary":true},{"type":"EMAIL","value":"wuligusi@pied-piper.org","timestamp":1517223059981,"is-secondary":true},{"type":"EMAIL","value":"kixove@pied-piper.org","timestamp":1517223076334,"is-secondary":true},{"type":"EMAIL","value":"taras.bilohan@youteam.co.uk","timestamp":1518112606141,"is-primary":true},{"type":"EMAIL","value":"rewyme@pied-piper.org","timestamp":1518112014322,"is-secondary":true}]}],"merge-audits":[]},{"addedAt":1519669492175,"vid":6164824,"canonical-vid":6164824,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOnU7-5lLPUfTX7Mk0DSCTMVpupxZ3F8-PMmUSk2qcz-_zKV5y02T2zeB7FPjQ3wRfOhHVL_7TDu2OUFRJdpzNuaoe4Ky4kQX6Iek-gGtfaNs5lY9SECiRVqWniPUlAikpNgLAr","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOnU7-5lLPUfTX7Mk0DSCTMVpupxZ3F8-PMmUSk2qcz-_zKV5y02T2zeB7FPjQ3wRfOhHVL_7TDu2OUFRJdpzNuaoe4Ky4kQX6Iek-gGtfaNs5lY9SECiRVqWniPUlAikpNgLAr/","properties":{"lastmodifieddate":{"value":"1519669492175"}},"form-submissions":[],"identity-profiles":[{"vid":6164824,"saved-at-timestamp":1519669487036,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"04d51954-809a-4ea8-bc19-2ffa9870a896","timestamp":1519669487033}]}],"merge-audits":[]},{"addedAt":1519669455060,"vid":6164774,"canonical-vid":6164774,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mNeBUaCwxd4lIHJIbl_0TKUciyWkxd2R41oIzAdcwSToTowCHfBtZez7RrGzUTfEapCFnXEMRX-5tubWbwyN3cOdu3RchbMaIynIz63hRUFmnqRsVI7iUNW4ctKckTeyWy040m5","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNeBUaCwxd4lIHJIbl_0TKUciyWkxd2R41oIzAdcwSToTowCHfBtZez7RrGzUTfEapCFnXEMRX-5tubWbwyN3cOdu3RchbMaIynIz63hRUFmnqRsVI7iUNW4ctKckTeyWy040m5/","properties":{"lastmodifieddate":{"value":"1519669455060"}},"form-submissions":[],"identity-profiles":[{"vid":6164774,"saved-at-timestamp":1519669447420,"deleted-changed-timestamp":0,"identities":[{"type":"LEAD_GUID","value":"75023c4b-8919-471c-afe6-b47b7b44b53b","timestamp":1519669447372}]}],"merge-audits":[]}],"has-more":true,"vid-offset":6164774,"time-offset":1519669455060}' + http_version: + recorded_at: Mon, 26 Feb 2018 21:32:17 GMT +- request: + method: get + uri: https://api.hubapi.com/automation/v2/workflows/enrollments/contacts/6165724?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: + - Mon, 26 Feb 2018 21:32:17 GMT + Content-Type: + - application/json; charset=UTF-8 + Content-Length: + - '22' + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d1c77379e7c727ff49e6f649eded5ccfe1519680737; expires=Tue, 26-Feb-19 + 21:32:17 GMT; path=/; domain=.hubapi.com; HttpOnly + Access-Control-Allow-Credentials: + - 'false' + Vary: + - Accept-Encoding, User-Agent + X-Trace: + - 2B57E9D62C70CBD7E71208B065485EC0DB40690683000000000000000000 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 3f360420aa099212-EWR + body: + encoding: ASCII-8BIT + string: "[]" + http_version: + recorded_at: Mon, 26 Feb 2018 21:32:17 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/lib/hubspot/contact_spec.rb b/spec/lib/hubspot/contact_spec.rb index d538072c..674f779f 100644 --- a/spec/lib/hubspot/contact_spec.rb +++ b/spec/lib/hubspot/contact_spec.rb @@ -377,4 +377,14 @@ subject{ contact } its(:destroyed?){ should be_false } end + + describe "#enrollments" do + cassette 'workflow_enrollments' + it "returns all workflows this contact is enrolled in" do + contacts = Hubspot::Contact.all(recent: true) + first = contacts.first + enrollments = first.enrollments + expect(enrollments.count).to eq(0) + end + end end diff --git a/spec/lib/hubspot/workflow_spec.rb b/spec/lib/hubspot/workflow_spec.rb new file mode 100644 index 00000000..c77a6ee1 --- /dev/null +++ b/spec/lib/hubspot/workflow_spec.rb @@ -0,0 +1,90 @@ +describe Hubspot::Workflow do + + before{ Hubspot.configure(hapikey: 'demo') } + + describe '#enroll_contact' do + context 'success' do + cassette 'enroll_contact_in_workflow_success' + it "returns a 204 response for a success" do + email = "testingapis@hubspot.com" + workflow = Hubspot::Workflow.new({'name' => "hello workflow", 'id' => 2582322}) + expect { + workflow.enroll_contact(email: email) + }.not_to raise_error + end + end + + context 'workflow without any steps' do + cassette 'enroll_contact_in_workflow_no_steps' + it "returns a 412 if the workflow is not valid" do + email = "testingapis@hubspot.com" + workflow = Hubspot::Workflow.new({'name' => "hello workflow", 'id' => 2325759}) + expect { + workflow.enroll_contact(email: email) + }.to raise_error(/There are no steps on this workflow to execute/) + end + end + + context 'invalid email' do + cassette 'enroll_contact_in_workflow_failed_email' + it "returns a 404 if the customer email does not exist" do + email = "hahha@hubspot.com" + workflow = Hubspot::Workflow.new({'name' => "hello workflow", 'id' => 2582322}) + expect { + workflow.enroll_contact(email: email) + }.to raise_error(/Couldn't find a Contact with the email 'hahha@hubspot.com'/) + end + end + + context 'invalid workflow id' do + cassette 'enroll_contact_in_workflow_failed_workflowId' + it "returns a 404 if the workflow does not exist" do + email = "testingapis@hubspot.com" + workflow = Hubspot::Workflow.new({'name' => "hello workflow", 'id' => 22210900}) + expect { + workflow.enroll_contact(email: email) + }.to raise_error(/resource not found/) + end + end + end + + describe '.all' do + context 'all workflows' do + cassette 'find_all_workflows' + it 'must get the workflows list' do + workflows = Hubspot::Workflow.all + + expect(workflows.size).to eql 25 + + first = workflows.first + last = workflows.last + + expect(first).to be_a Hubspot::Workflow + expect(first.id).to eql 2325759 + expect(first.name).to eql 'New Workflow' + + expect(last).to be_a Hubspot::Workflow + expect(last.id).to eql 2582322 + expect(last.name).to eql 'Test Workflow' + end + + it "must get the workflows list for page 2" do + workflows = Hubspot::Workflow.all({page: 2}) + + expect(workflows.size).to eql 25 + + first = workflows.first + last = workflows.last + + expect(first).to be_a Hubspot::Workflow + expect(first.id).to eql 2325759 + expect(first.name).to eql 'New Workflow' + + expect(last).to be_a Hubspot::Workflow + expect(last.id).to eql 2582322 + expect(last.name).to eql 'Test Workflow' + end + end + + end +end