hubspot-ruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -4,15 +4,15 @@ GEM
4
4
  activesupport (3.2.12)
5
5
  i18n (~> 0.6)
6
6
  multi_json (~> 1.0)
7
- addressable (2.3.2)
7
+ addressable (2.3.3)
8
8
  awesome_print (1.1.0)
9
9
  crack (0.3.2)
10
- diff-lcs (1.1.3)
10
+ diff-lcs (1.2.1)
11
11
  git (1.2.5)
12
12
  httparty (0.10.2)
13
13
  multi_json (~> 1.0)
14
14
  multi_xml (>= 0.5.2)
15
- i18n (0.6.1)
15
+ i18n (0.6.4)
16
16
  jeweler (1.8.4)
17
17
  bundler (~> 1.0)
18
18
  git (>= 1.2.5)
@@ -22,25 +22,25 @@ GEM
22
22
  multi_json (1.6.1)
23
23
  multi_xml (0.5.3)
24
24
  rake (10.0.3)
25
- rdoc (3.12.1)
25
+ rdoc (4.0.0)
26
26
  json (~> 1.4)
27
27
  rr (1.0.4)
28
- rspec (2.12.0)
29
- rspec-core (~> 2.12.0)
30
- rspec-expectations (~> 2.12.0)
31
- rspec-mocks (~> 2.12.0)
32
- rspec-core (2.12.2)
33
- rspec-expectations (2.12.1)
34
- diff-lcs (~> 1.1.3)
35
- rspec-mocks (2.12.2)
28
+ rspec (2.13.0)
29
+ rspec-core (~> 2.13.0)
30
+ rspec-expectations (~> 2.13.0)
31
+ rspec-mocks (~> 2.13.0)
32
+ rspec-core (2.13.0)
33
+ rspec-expectations (2.13.0)
34
+ diff-lcs (>= 1.1.3, < 2.0)
35
+ rspec-mocks (2.13.0)
36
36
  simplecov (0.7.1)
37
37
  multi_json (~> 1.0)
38
38
  simplecov-html (~> 0.7.1)
39
39
  simplecov-html (0.7.1)
40
40
  vcr (2.4.0)
41
- webmock (1.9.0)
41
+ webmock (1.10.1)
42
42
  addressable (>= 2.2.7)
43
- crack (>= 0.1.7)
43
+ crack (>= 0.3.2)
44
44
 
45
45
  PLATFORMS
46
46
  ruby
data/hubspot-ruby.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hubspot-ruby"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew DiMichele"]
12
- s.date = "2013-02-22"
12
+ s.date = "2013-03-04"
13
13
  s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
14
14
  s.email = "andrew@omadahealth.com"
15
15
  s.extra_rdoc_files = [
@@ -29,22 +29,27 @@ Gem::Specification.new do |s|
29
29
  "lib/hubspot/config.rb",
30
30
  "lib/hubspot/contact.rb",
31
31
  "lib/hubspot/exceptions.rb",
32
+ "lib/hubspot/form.rb",
32
33
  "lib/hubspot/utils.rb",
33
34
  "lib/hubspot/version.rb",
34
35
  "spec/fixtures/vcr_cassettes/contact_create.yml",
35
36
  "spec/fixtures/vcr_cassettes/contact_create_existing_email.yml",
36
37
  "spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml",
37
38
  "spec/fixtures/vcr_cassettes/contact_create_with_params.yml",
39
+ "spec/fixtures/vcr_cassettes/contact_destroy.yml",
38
40
  "spec/fixtures/vcr_cassettes/contact_example.yml",
39
41
  "spec/fixtures/vcr_cassettes/contact_find_by_email.yml",
40
42
  "spec/fixtures/vcr_cassettes/contact_find_by_id.yml",
43
+ "spec/fixtures/vcr_cassettes/contact_find_by_utk.yml",
41
44
  "spec/fixtures/vcr_cassettes/contact_update.yml",
42
45
  "spec/lib/hubspot-ruby_spec.rb",
43
46
  "spec/lib/hubspot/config_spec.rb",
44
47
  "spec/lib/hubspot/contact_spec.rb",
48
+ "spec/lib/hubspot/form_spec.rb",
45
49
  "spec/lib/hubspot/utils_spec.rb",
46
50
  "spec/live/contacts_integration_spec.rb",
47
- "spec/spec_helper.rb"
51
+ "spec/spec_helper.rb",
52
+ "spec/support/cassette_helper.rb"
48
53
  ]
49
54
  s.homepage = "http://github.com/omadahealth/hubspot-ruby"
50
55
  s.require_paths = ["lib"]
data/lib/hubspot-ruby.rb CHANGED
@@ -3,6 +3,7 @@ require 'httparty'
3
3
  require 'hubspot/exceptions'
4
4
  require 'hubspot/config'
5
5
  require 'hubspot/contact'
6
+ require 'hubspot/form'
6
7
 
7
8
  module Hubspot
8
9
  def self.configure(config={})
@@ -3,17 +3,26 @@ module Hubspot
3
3
  class << self
4
4
  attr_reader :hapikey
5
5
  attr_reader :base_url
6
+ attr_reader :portal_id
6
7
 
7
8
  def configure(config)
8
9
  config.stringify_keys!
9
10
  @hapikey = config["hapikey"]
10
11
  @base_url = config["base_url"] || "https://api.hubapi.com"
12
+ @portal_id = config["portal_id"]
11
13
  self
12
14
  end
13
15
 
14
16
  def reset!
15
17
  @hapikey = nil
16
18
  @base_url = "https://api.hubapi.com"
19
+ @portal_id = nil
20
+ end
21
+
22
+ def ensure!(*params)
23
+ params.each do |p|
24
+ raise Hubspot::ConfigurationError.new("'#{p}' not configured") unless instance_variable_get "@#{p}"
25
+ end
17
26
  end
18
27
  end
19
28
 
@@ -11,7 +11,9 @@ module Hubspot
11
11
  CREATE_CONTACT_PATH = "/contacts/v1/contact"
12
12
  GET_CONTACT_BY_EMAIL_PATH = "/contacts/v1/contact/email/:contact_email/profile"
13
13
  GET_CONTACT_BY_ID_PATH = "/contacts/v1/contact/vid/:contact_id/profile"
14
+ GET_CONTACT_BY_UTK_PATH = "/contacts/v1/contact/utk/:contact_utk/profile"
14
15
  UPDATE_CONTACT_PATH = "/contacts/v1/contact/vid/:contact_id/profile"
16
+ DESTROY_CONTACT_PATH = "/contacts/v1/contact/vid/:contact_id"
15
17
 
16
18
  class << self
17
19
  # Creates a new contact
@@ -36,7 +38,7 @@ module Hubspot
36
38
  def find_by_email(email)
37
39
  url = Hubspot::Utils.generate_url(GET_CONTACT_BY_EMAIL_PATH, {contact_email: email})
38
40
  resp = HTTParty.get(url, format: :json)
39
- if resp.code == 200
41
+ if resp.success?
40
42
  Hubspot::Contact.new(resp.parsed_response)
41
43
  else
42
44
  nil
@@ -49,19 +51,25 @@ module Hubspot
49
51
  def find_by_id(vid)
50
52
  url = Hubspot::Utils.generate_url(GET_CONTACT_BY_ID_PATH, {contact_id: vid})
51
53
  resp = HTTParty.get(url, format: :json)
52
- if resp.code == 200
54
+ if resp.success?
53
55
  Hubspot::Contact.new(resp.parsed_response)
54
56
  else
55
57
  nil
56
58
  end
57
59
  end
58
60
 
59
- # TODO: Finds a contact by its User Token (hubspotutk cookie value)
61
+ # Finds a contact by its User Token (hubspotutk cookie value)
60
62
  # {https://developers.hubspot.com/docs/methods/contacts/get_contact_by_utk}
61
63
  # @param utk [String] hubspotutk cookie value
62
64
  # @return [Hubspot::Contact, nil] the contact found or nil
63
65
  def find_by_utk(utk)
64
- raise NotImplementedError
66
+ url = Hubspot::Utils.generate_url(GET_CONTACT_BY_UTK_PATH, {contact_utk: utk})
67
+ resp = HTTParty.get(url, format: :json)
68
+ if resp.success?
69
+ Hubspot::Contact.new(resp.parsed_response)
70
+ else
71
+ nil
72
+ end
65
73
  end
66
74
 
67
75
  # TODO: Get all contacts
@@ -113,6 +121,10 @@ module Hubspot
113
121
  @properties["email"]
114
122
  end
115
123
 
124
+ def utk
125
+ @properties["usertoken"]
126
+ end
127
+
116
128
  # Updates the properties of a contact
117
129
  # {https://developers.hubspot.com/docs/methods/contacts/update_contact}
118
130
  # @param params [Hash] hash of properties to update
@@ -127,11 +139,18 @@ module Hubspot
127
139
  self
128
140
  end
129
141
 
130
- # TODO: Archives the contact in hubspot
142
+ # Archives the contact in hubspot
131
143
  # {https://developers.hubspot.com/docs/methods/contacts/delete_contact}
132
- # @return [nil]
144
+ # @return [TrueClass] true
133
145
  def destroy!
134
- raise NotImplementedError
146
+ url = Hubspot::Utils.generate_url(DESTROY_CONTACT_PATH, {contact_id: vid})
147
+ resp = HTTParty.delete(url, format: :json)
148
+ raise(Hubspot::RequestError.new(resp)) unless resp.success?
149
+ @destroyed = true
150
+ end
151
+
152
+ def destroyed?
153
+ !!@destroyed
135
154
  end
136
155
  end
137
156
  end
@@ -0,0 +1,11 @@
1
+ module Hubspot
2
+ class Form
3
+ def initialize(form_guid)
4
+ @form_guid = form_guid
5
+ end
6
+
7
+ def url
8
+ Hubspot::Utils.generate_url("/uploads/form/v2/:portal_id/:form_guid", {form_guid: @form_guid}, {base_url: "https://forms.hubspot.com", hapikey: false})
9
+ end
10
+ end
11
+ end
data/lib/hubspot/utils.rb CHANGED
@@ -20,11 +20,18 @@ module Hubspot
20
20
  #
21
21
  # @return [String]
22
22
  #
23
- def generate_url(path, params={})
24
- raise Hubspot::ConfigurationError.new("'hapikey' not configured") unless Hubspot::Config.hapikey
23
+ def generate_url(path, params={}, options={})
24
+ Hubspot::Config.ensure! :hapikey
25
25
  path = path.clone
26
26
  params = params.clone
27
- params["hapikey"] = Hubspot::Config.hapikey
27
+ base_url = options[:base_url] || Hubspot::Config.base_url
28
+ params["hapikey"] = Hubspot::Config.hapikey unless options[:hapikey] == false
29
+
30
+ if path =~ /:portal_id/
31
+ Hubspot::Config.ensure! :portal_id
32
+ params["portal_id"] = Hubspot::Config.portal_id if path =~ /:portal_id/
33
+ end
34
+
28
35
  params.each do |k,v|
29
36
  if path.match(":#{k}")
30
37
  path.gsub!(":#{k}",v.to_s)
@@ -33,7 +40,8 @@ module Hubspot
33
40
  end
34
41
  raise(Hubspot::MissingInterpolation.new("Interpolation not resolved")) if path =~ /:/
35
42
  query = params.map{ |k,v| "#{k}=#{v}" }.join("&")
36
- Hubspot::Config.base_url + path + "?" + query
43
+ path += "?" if query.present?
44
+ base_url + path + query
37
45
  end
38
46
  end
39
47
  end
@@ -2,7 +2,7 @@ module Hubspot
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -0,0 +1,99 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.hubapi.com/contacts/v1/contact?hapikey=demo
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! '{"properties":[{"property":"email","value":"newcontact_y_1362339049@hsgem.com"}]}'
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Access-Control-Allow-Credentials:
16
+ - 'false'
17
+ Content-Type:
18
+ - text/plain; charset=utf-8
19
+ Date:
20
+ - Sun, 03 Mar 2013 19:30:50 GMT
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ Content-Length:
24
+ - '1093'
25
+ Connection:
26
+ - keep-alive
27
+ body:
28
+ encoding: US-ASCII
29
+ string: ! '{"vid":163808,"portal-id":62515,"profile-token":"AO_T-mMji2Iv1oSx0LuXtcLlejNz0naS-l00tAfVhctds-q3zsMUlISjDLHGNObWRvyaRtQtErwRE8c5KRae9_tRCUhKqLXFCnbQsXpzZndlsY0j5uTCQWIeYGG9i1REd183fSyDgspc","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMji2Iv1oSx0LuXtcLlejNz0naS-l00tAfVhctds-q3zsMUlISjDLHGNObWRvyaRtQtErwRE8c5KRae9_tRCUhKqLXFCnbQsXpzZndlsY0j5uTCQWIeYGG9i1REd183fSyDgspc/","properties":{"email":{"value":"newcontact_y_1362339049@hsgem.com","versions":[{"value":"newcontact_y_1362339049@hsgem.com","source-type":"API","source-id":null,"source-label":null,"timestamp":1362339050201,"selected":false}]},"createdate":{"value":"1362339050201","versions":[{"value":"1362339050201","source-type":"API","source-id":null,"source-label":null,"timestamp":1362339050201,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":163808,"identities":[{"type":"EMAIL","value":"newcontact_y_1362339049@hsgem.com","timestamp":1362339050201},{"type":"LEAD_GUID","value":"cbad3425-1495-4680-b267-162b11bc240f","timestamp":1362339050235}]}]}'
30
+ http_version:
31
+ recorded_at: Sun, 03 Mar 2013 19:30:50 GMT
32
+ - request:
33
+ method: delete
34
+ uri: https://api.hubapi.com/contacts/v1/contact/vid/163808?hapikey=demo
35
+ body:
36
+ encoding: US-ASCII
37
+ string: ''
38
+ headers: {}
39
+ response:
40
+ status:
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ Access-Control-Allow-Credentials:
45
+ - 'false'
46
+ Content-Type:
47
+ - text/plain; charset=utf-8
48
+ Date:
49
+ - Sun, 03 Mar 2013 19:30:51 GMT
50
+ Server:
51
+ - Apache-Coyote/1.1
52
+ Content-Length:
53
+ - '29'
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ! '{"vid":163808,"deleted":true}'
59
+ http_version:
60
+ recorded_at: Sun, 03 Mar 2013 19:30:51 GMT
61
+ - request:
62
+ method: delete
63
+ uri: https://api.hubapi.com/contacts/v1/contact/vid/invalid?hapikey=demo
64
+ body:
65
+ encoding: US-ASCII
66
+ string: ''
67
+ headers: {}
68
+ response:
69
+ status:
70
+ code: 404
71
+ message: Not Found
72
+ headers:
73
+ Content-Type:
74
+ - text/html;charset=utf-8
75
+ Date:
76
+ - Sun, 03 Mar 2013 19:30:51 GMT
77
+ Server:
78
+ - Apache-Coyote/1.1
79
+ Content-Length:
80
+ - '979'
81
+ Connection:
82
+ - keep-alive
83
+ body:
84
+ encoding: US-ASCII
85
+ string: ! '<html><head><title>Apache Tomcat/6.0.30 - Error report</title><style><!--H1
86
+ {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
87
+ H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
88
+ H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
89
+ BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
90
+ B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
91
+ P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
92
+ {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP
93
+ Status 404 - Not Found</h1><HR size="1" noshade="noshade"><p><b>type</b> Status
94
+ report</p><p><b>message</b> <u>Not Found</u></p><p><b>description</b> <u>The
95
+ requested resource (Not Found) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache
96
+ Tomcat/6.0.30</h3></body></html>'
97
+ http_version:
98
+ recorded_at: Sun, 03 Mar 2013 19:30:51 GMT
99
+ recorded_with: VCR 2.4.0
@@ -26,7 +26,7 @@ http_interactions:
26
26
  - keep-alive
27
27
  body:
28
28
  encoding: US-ASCII
29
- string: ! '{"vid":82325,"canonical-vid":82325,"portal-id":62515,"profile-token":"AO_T-mNv5DxWksowkR_cUZwe4J5-pxmNlzGQ4bJOas20MGNrJtrQWj7vtreBvekW74KmTCsbeEx0Kwy3YfptnFT6fDiQ-3kEnQz44wTQsEvmusYBjUYqvfv0twCciwlZ1vCwerCEuRUo","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNv5DxWksowkR_cUZwe4J5-pxmNlzGQ4bJOas20MGNrJtrQWj7vtreBvekW74KmTCsbeEx0Kwy3YfptnFT6fDiQ-3kEnQz44wTQsEvmusYBjUYqvfv0twCciwlZ1vCwerCEuRUo/","properties":{"hs_analytics_num_visits":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_referrer":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_linkedin_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_url":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_last_engagement":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_num_broadcast_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"hs_social_facebook_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"createdate":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"API","source-id":null,"source-label":null,"timestamp":1345062449002,"selected":false}]},"lastname":{"value":"Eastwood","versions":[{"value":"Eastwood","source-type":"API","source-id":null,"source-label":null,"timestamp":1361147932002,"selected":false},{"value":"Cunningham","source-type":"API","source-id":null,"source-label":null,"timestamp":1361146313002,"selected":false}]},"hs_social_twitter_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"phone":{"value":"555-555-5432"},"firstname":{"value":"Clint","versions":[{"value":"Clint","source-type":"API","source-id":null,"source-label":null,"timestamp":1361147932002,"selected":false},{"value":"Steve","source-type":"API","source-id":null,"source-label":null,"timestamp":1361146313002,"selected":false}]},"hs_analytics_first_url":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source":{"value":"OFFLINE","versions":[{"value":"OFFLINE","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_first_referrer":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_num_event_completions":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"hs_social_google_plus_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"email":{"value":"testingapis@hubspot.com","versions":[{"value":"testingapis@hubspot.com","source-type":"CONTACTS_WEB","source-id":"dadams@hubspot.com","source-label":null,"timestamp":1345062449008,"selected":false}]},"hs_analytics_last_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_num_page_views":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_first_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source_data_2":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source_data_1":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_visit_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":82325,"identities":[{"type":"EMAIL","value":"testingapis@hubspot.com","timestamp":1345062449327},{"type":"LEAD_GUID","value":"c0da5c41-f289-4642-910c-9aa2b0fba245","timestamp":1345062449333}]}]}'
29
+ string: ! '{"vid":82325,"canonical-vid":82325,"portal-id":62515,"profile-token":"AO_T-mNv5DxWksowkR_cUZwe4J5-pxmNlzGQ4bJOas20MGNrJtrQWj7vtreBvekW74KmTCsbeEx0Kwy3YfptnFT6fDiQ-3kEnQz44wTQsEvmusYBjUYqvfv0twCciwlZ1vCwerCEuRUo","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNv5DxWksowkR_cUZwe4J5-pxmNlzGQ4bJOas20MGNrJtrQWj7vtreBvekW74KmTCsbeEx0Kwy3YfptnFT6fDiQ-3kEnQz44wTQsEvmusYBjUYqvfv0twCciwlZ1vCwerCEuRUo/","properties":{"usertoken":{"value":"1234567890"},"hs_analytics_num_visits":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_referrer":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_linkedin_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_url":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_last_engagement":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_social_num_broadcast_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"hs_social_facebook_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"createdate":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"API","source-id":null,"source-label":null,"timestamp":1345062449002,"selected":false}]},"lastname":{"value":"Eastwood","versions":[{"value":"Eastwood","source-type":"API","source-id":null,"source-label":null,"timestamp":1361147932002,"selected":false},{"value":"Cunningham","source-type":"API","source-id":null,"source-label":null,"timestamp":1361146313002,"selected":false}]},"hs_social_twitter_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"phone":{"value":"555-555-5432"},"firstname":{"value":"Clint","versions":[{"value":"Clint","source-type":"API","source-id":null,"source-label":null,"timestamp":1361147932002,"selected":false},{"value":"Steve","source-type":"API","source-id":null,"source-label":null,"timestamp":1361146313002,"selected":false}]},"hs_analytics_first_url":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source":{"value":"OFFLINE","versions":[{"value":"OFFLINE","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_first_referrer":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_num_event_completions":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"hs_social_google_plus_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]},"email":{"value":"testingapis@hubspot.com","versions":[{"value":"testingapis@hubspot.com","source-type":"CONTACTS_WEB","source-id":"dadams@hubspot.com","source-label":null,"timestamp":1345062449008,"selected":false}]},"hs_analytics_last_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_num_page_views":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_first_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source_data_2":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_source_data_1":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345067864004,"selected":false}]},"hs_analytics_last_visit_timestamp":{"value":"1345062449327","versions":[{"value":"1345062449327","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348916431004,"selected":false}]}},"form-submissions":[],"list-memberships":[],"identity-profiles":[{"vid":82325,"identities":[{"type":"EMAIL","value":"testingapis@hubspot.com","timestamp":1345062449327},{"type":"LEAD_GUID","value":"c0da5c41-f289-4642-910c-9aa2b0fba245","timestamp":1345062449333}]}]}'
30
30
  http_version:
31
31
  recorded_at: Fri, 22 Feb 2013 20:31:02 GMT
32
32
  recorded_with: VCR 2.4.0
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.hubapi.com/contacts/v1/contact/utk/f844d2217850188692f2610c717c2e9b/profile?hapikey=demo
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Access-Control-Allow-Credentials:
16
+ - 'false'
17
+ Content-Type:
18
+ - application/json;charset=UTF-8
19
+ Date:
20
+ - Mon, 04 Mar 2013 02:30:08 GMT
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ Transfer-Encoding:
24
+ - chunked
25
+ Connection:
26
+ - keep-alive
27
+ body:
28
+ encoding: US-ASCII
29
+ string: ! '{"vid":61898,"canonical-vid":61898,"portal-id":62515,"profile-token":"AO_T-mMNqz_rXIefv_l5PY2GsnICbphkrt1wuyYPTndpJnWGlNMIguthtY7dQ3hhRtrh_76CSrv-VvR242BELQKGSRhTTYV2pP-oOUkeFKnd7KfkLbd3deD-EcT8Xi0gWgJ39RbPMeG9","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMNqz_rXIefv_l5PY2GsnICbphkrt1wuyYPTndpJnWGlNMIguthtY7dQ3hhRtrh_76CSrv-VvR242BELQKGSRhTTYV2pP-oOUkeFKnd7KfkLbd3deD-EcT8Xi0gWgJ39RbPMeG9/","properties":{"phone":{"value":"7784024899","versions":[{"value":"7784024899","source-type":"FORM","source-id":"9a0ad04cb10e462faa5ab48d656e4f5e","source-label":"Phone","timestamp":1361484447003,"selected":false},{"value":"","source-type":"FORM","source-id":"752837fcc4354d839b41e1b74d79229d","source-label":"Phone","timestamp":1358445501003,"selected":false},{"value":"7784024899","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"Phone","timestamp":1357168954003,"selected":false},{"value":"","source-type":"FORM","source-id":"d21400c2f8c74e54ad8d44f7eab31c1b","source-label":"Phone","timestamp":1352326575003,"selected":false},{"value":"7784024899","source-type":"FORM","source-id":"e399896f2bd746b3a77638ee8e5bbe26","source-label":"Phone","timestamp":1352242517003,"selected":false}]},"hs_social_linkedin_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false}]},"hs_social_num_broadcast_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348928611004,"selected":false}]},"hs_social_facebook_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false}]},"createdate":{"value":"1340137647000","versions":[{"value":"1340137647000","source-type":"FORM","source-id":"0f1d0d8d8d7247c2b1147e05c2ccc9fa","source-label":null,"timestamp":1340137647003,"selected":false}]},"hs_analytics_revenue":{"value":"0.0","versions":[{"value":"0.0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false}]},"lastname":{"value":"test","versions":[{"value":"test","source-type":"FORM","source-id":"9a0ad04cb10e462faa5ab48d656e4f5e","source-label":"LastName","timestamp":1361484447003,"selected":false},{"value":"s","source-type":"FORM","source-id":"752837fcc4354d839b41e1b74d79229d","source-label":"LastName","timestamp":1358445501003,"selected":false},{"value":"Another
30
+ Lead!","source-type":"FORM","source-id":"2467215c8e694aefb2e39b53fd365cbc","source-label":"LastName","timestamp":1357339988003,"selected":false},{"value":"ZOMG","source-type":"FORM","source-id":"4144ac8406154b3687985ac18a97ab4f","source-label":"LastName","timestamp":1357339838003,"selected":false},{"value":"name","source-type":"FORM","source-id":"2a2d05b2a07b487b85b9c1543c9db60d","source-label":"LastName","timestamp":1357174898003,"selected":false},{"value":"Else","source-type":"FORM","source-id":"991ad7ce00af47a48b11f594b26e0d25","source-label":"LastName","timestamp":1357174622003,"selected":false},{"value":"Unbounce","source-type":"FORM","source-id":"4bfb0be48006443dac1cf764d0b1269b","source-label":"LastName","timestamp":1357172814003,"selected":false},{"value":"Rollo","source-type":"FORM","source-id":"b8266433d9224da1b24485d8dc1af965","source-label":"LastName","timestamp":1357172643003,"selected":false},{"value":"Unbounce","source-type":"FORM","source-id":"cb810e81bca449ba9f6eb98244939ac7","source-label":"LastName","timestamp":1357171743003,"selected":false},{"value":"3816","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"LastName","timestamp":1357168954003,"selected":false},{"value":"","source-type":"FORM","source-id":"d21400c2f8c74e54ad8d44f7eab31c1b","source-label":"LastName","timestamp":1352326575003,"selected":false},{"value":"faulk","source-type":"FORM","source-id":"98cbd0673c3e46ea9a6058e520ddbea0","source-label":"LastName","timestamp":1352326414003,"selected":false},{"value":"[]","source-type":"FORM","source-id":"acb2f0225d3b460e9c3646275ef96df0","source-label":"LastName","timestamp":1352325781003,"selected":false},{"value":"Field
31
+ Test","source-type":"FORM","source-id":"e399896f2bd746b3a77638ee8e5bbe26","source-label":"LastName","timestamp":1352242517003,"selected":false},{"value":"Rollo","source-type":"FORM","source-id":"4ad10b0e88f94a81a1372cc374548177","source-label":"LastName","timestamp":1351207972003,"selected":false}]},"pagename":{"value":"c32b6d76-7f6a-11e2-98c6-1231410166db","versions":[{"value":"c32b6d76-7f6a-11e2-98c6-1231410166db","source-type":"FORM","source-id":"a6f361a7-86e7-4789-b0a9-560e6dbb29c1","source-label":"pageName","timestamp":1361824194003,"selected":false}]},"hs_analytics_first_url":{"value":"http://pages-test.unbounce.com/test-37/","versions":[{"value":"http://pages-test.unbounce.com/test-37/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345569345004,"selected":false},{"value":"https://next-test.unbounce.com/variants/13082/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false},{"value":"http://pages-test.unbounce.com/test-37/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"ipaddress":{"value":"216.13.179.82","versions":[{"value":"216.13.179.82","source-type":"FORM","source-id":"4ad10b0e88f94a81a1372cc374548177","source-label":null,"timestamp":1351207972003,"selected":false},{"value":"184.71.173.186","source-type":"FORM","source-id":"b3f035ca7b424b38bb3428d7887174dd","source-label":null,"timestamp":1349291184003,"selected":false},{"value":"64.180.61.162","source-type":"FORM","source-id":"d27eebcd5fa54278baeb38643dc976f0","source-label":null,"timestamp":1349213247003,"selected":false},{"value":"184.71.173.186","source-type":"FORM","source-id":"a484656526b7446db29858f40681d6a8","source-label":null,"timestamp":1347480223003,"selected":false},{"value":"64.180.61.162","source-type":"FORM","source-id":"7b5646eaaa5a4eacbb0dc31193c23f59","source-label":null,"timestamp":1346785121003,"selected":false},{"value":"184.71.173.186","source-type":"FORM","source-id":"58051cb5cbb34e1e9a0f71e3a7c331aa","source-label":null,"timestamp":1346270068003,"selected":false},{"value":"64.180.61.162","source-type":"FORM","source-id":"3b8d5ba5f5bb421599f5968662f5903c","source-label":null,"timestamp":1341442992003,"selected":false},{"value":"184.71.173.186","source-type":"FORM","source-id":"0f1d0d8d8d7247c2b1147e05c2ccc9fa","source-label":null,"timestamp":1340137647003,"selected":false}]},"hs_analytics_first_referrer":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345569345004,"selected":false},{"value":"https://next-test.unbounce.com/variants/13082/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false},{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"hs_analytics_num_event_completions":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348688960004,"selected":false}]},"hs_analytics_source":{"value":"DIRECT_TRAFFIC","versions":[{"value":"DIRECT_TRAFFIC","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"hs_social_google_plus_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348928611004,"selected":false}]},"hs_analytics_last_timestamp":{"value":"1361917230279","versions":[{"value":"1361917230279","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361939034004,"selected":false},{"value":"1361824172765","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361835292004,"selected":false},{"value":"1361484422508","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false},{"value":"1358539966382","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358552239004,"selected":false},{"value":"1358445494031","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358460234004,"selected":false},{"value":"1358375450768","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358398269004,"selected":false},{"value":"1357339965614","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357347575004,"selected":false},{"value":"1357174872993","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357184826004,"selected":false},{"value":"1357172793952","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357175881004,"selected":false},{"value":"1357168959530","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false},{"value":"1355269121937","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"1352918695034","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352926416004,"selected":false},{"value":"1352326568195","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352331344004,"selected":false},{"value":"1352242491868","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352244926004,"selected":false},{"value":"1351207959338","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351210456004,"selected":false}]},"hs_analytics_num_page_views":{"value":"82","versions":[{"value":"82","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361939034004,"selected":false},{"value":"79","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361835292004,"selected":false},{"value":"78","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false},{"value":"77","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358552239004,"selected":false},{"value":"75","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358460234004,"selected":false},{"value":"74","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358398269004,"selected":false},{"value":"72","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357347575004,"selected":false},{"value":"70","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357184826004,"selected":false},{"value":"68","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357175881004,"selected":false},{"value":"66","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false},{"value":"64","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"63","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352926416004,"selected":false},{"value":"62","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352331344004,"selected":false},{"value":"59","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352244926004,"selected":false},{"value":"58","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351210456004,"selected":false}]},"hs_analytics_first_timestamp":{"value":"1340137626697","versions":[{"value":"1340137626697","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345569345004,"selected":false},{"value":"1345062099292","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false},{"value":"1340137626697","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"name":{"value":"Customer
32
+ Success","versions":[{"value":"Customer Success","source-type":"FORM","source-id":"a6f361a7-86e7-4789-b0a9-560e6dbb29c1","source-label":"name","timestamp":1361824194003,"selected":false}]},"hs_analytics_source_data_2":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"usertoken":{"value":"f844d2217850188692f2610c717c2e9b","versions":[{"value":"f844d2217850188692f2610c717c2e9b","source-type":"FORM","source-id":"0f1d0d8d8d7247c2b1147e05c2ccc9fa","source-label":"UserToken","timestamp":1340137647003,"selected":false}]},"hs_analytics_source_data_1":{"value":"","versions":[{"value":"","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1341366894004,"selected":false}]},"hs_analytics_last_visit_timestamp":{"value":"1361917230279","versions":[{"value":"1361917230279","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361939034004,"selected":false},{"value":"1361824172765","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361835292004,"selected":false},{"value":"1361484422508","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false},{"value":"1358445494031","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358460234004,"selected":false},{"value":"1357339965614","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357347575004,"selected":false},{"value":"1357174872993","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357184826004,"selected":false},{"value":"1357172793952","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357175881004,"selected":false},{"value":"1357168959530","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false},{"value":"1355269121937","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"1352326568195","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352331344004,"selected":false},{"value":"1352242491868","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352244926004,"selected":false},{"value":"1351207959338","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351210456004,"selected":false},{"value":"1351200386023","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351202129004,"selected":false},{"value":"1350499562556","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1350506250004,"selected":false},{"value":"1349291261148","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1349293127004,"selected":false}]},"hs_analytics_num_visits":{"value":"60","versions":[{"value":"60","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361939034004,"selected":false},{"value":"57","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361835292004,"selected":false},{"value":"56","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false},{"value":"55","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358460234004,"selected":false},{"value":"54","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357347575004,"selected":false},{"value":"52","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357184826004,"selected":false},{"value":"50","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357175881004,"selected":false},{"value":"48","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false},{"value":"46","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"45","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352331344004,"selected":false},{"value":"42","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352244926004,"selected":false},{"value":"41","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351210456004,"selected":false},{"value":"40","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351202129004,"selected":false},{"value":"39","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1350506250004,"selected":false},{"value":"38","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1349293127004,"selected":false}]},"hs_analytics_last_referrer":{"value":"https://app.unbounce.com/110612/variants/8069482/preview","versions":[{"value":"https://app.unbounce.com/110612/variants/8069482/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358552239004,"selected":false},{"value":"https://app-test.unbounce.com/302/variants/41724/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358398269004,"selected":false},{"value":"https://app-test.unbounce.com/302/variants/40847/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"https://app-test.unbounce.com/302/pages/ffc7029e-29fd-11e2-af7f-1231410166db","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352926416004,"selected":false},{"value":"https://app-test.unbounce.com/2230/pages/7625dffc-0cb0-11e2-b1a0-1231410166db","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351210456004,"selected":false},{"value":"https://app-test.unbounce.com/2230/pages","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1349212502004,"selected":false},{"value":"https://app.unbounce.com/110612/pages/67025a50-09ae-11e2-9662-12313e0080a1","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1349201383004,"selected":false},{"value":"https://app-test.unbounce.com/variants/39101/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348928611004,"selected":false},{"value":"https://app-test.unbounce.com/2230/pages","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1348862187004,"selected":false},{"value":"https://app-test.unbounce.com/variants/39101/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1346362967004,"selected":false},{"value":"https://app-test.unbounce.com/variants/39086/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1346185497004,"selected":false},{"value":"https://next-test.unbounce.com/variants/13082/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345636561004,"selected":false},{"value":"https://next.unbounce.com/pages/519e2000-cb87-11e1-87f3-12313f053c71/preview_toolbar?variant_id=5755892","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345569345004,"selected":false},{"value":"https://next-test.unbounce.com/variants/13082/edit","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false},{"value":"https://next.unbounce.com/pages/519e2000-cb87-11e1-87f3-12313f053c71/preview_toolbar?variant_id=5755892","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1342034058004,"selected":false}]},"hs_analytics_last_url":{"value":"http://pages-test.unbounce.com/video-test/","versions":[{"value":"http://pages-test.unbounce.com/video-test/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361939034004,"selected":false},{"value":"http://pages-test.unbounce.com/email-test-2/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361835292004,"selected":false},{"value":"http://pages-test.unbounce.com/speak2leads-test/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false},{"value":"https://app.unbounce.com/110612/variants/8069482/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358552239004,"selected":false},{"value":"http://pages-test.unbounce.com/test-51/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358460234004,"selected":false},{"value":"https://app-test.unbounce.com/302/variants/41724/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1358398269004,"selected":false},{"value":"http://pages-test.unbounce.com/lead-test/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357347575004,"selected":false},{"value":"http://pages-test.unbounce.com/blank-test-1/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1357172702004,"selected":false},{"value":"http://pages-test.unbounce.com/lp-3509/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1355273549004,"selected":false},{"value":"https://app-test.unbounce.com/302/variants/40847/preview","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352926416004,"selected":false},{"value":"http://pages-test.unbounce.com/f964a310-2913-11e2-a7e9-1231410166db/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352331344004,"selected":false},{"value":"http://pages-test.unbounce.com/42e699b4-284a-11e2-8053-1231410166db-1/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1352244926004,"selected":false},{"value":"http://pages-test.unbounce.com/form-test/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1351202129004,"selected":false},{"value":"http://pages-test.unbounce.com/b0fef270-edb2-11e1-bc3c-1231410166db/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1350506250004,"selected":false},{"value":"http://pages-test.unbounce.com/form-test/","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1349212502004,"selected":false}]},"hs_social_last_engagement":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false}]},"website":{"value":"http://repeat.com","versions":[{"value":"http://repeat.com","source-type":"FORM","source-id":"696997e4848d4cecb10650d18c581930","source-label":"Website","timestamp":1361917251003,"selected":false},{"value":"http://recreate.com","source-type":"FORM","source-id":"481ceaa2ca944396971434e0b4073dae","source-label":"Website","timestamp":1361917185003,"selected":false},{"value":"http://hopeful.com","source-type":"MIGRATION","source-id":null,"source-label":null,"timestamp":1361912064005,"selected":false},{"value":"http://hopeful.com","source-type":"FORM","source-id":"1aa471732f4d40dd9ec8f7b9883d6cf1","source-label":"Website","timestamp":1361912048003,"selected":false}]},"hs_social_twitter_clicks":{"value":"0","versions":[{"value":"0","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1345065074004,"selected":false}]},"firstname":{"value":"test","versions":[{"value":"test","source-type":"FORM","source-id":"9a0ad04cb10e462faa5ab48d656e4f5e","source-label":"FirstName","timestamp":1361484447003,"selected":false},{"value":"Another","source-type":"FORM","source-id":"2467215c8e694aefb2e39b53fd365cbc","source-label":"FirstName","timestamp":1357339988003,"selected":false},{"value":"no","source-type":"FORM","source-id":"2a2d05b2a07b487b85b9c1543c9db60d","source-label":"FirstName","timestamp":1357174898003,"selected":false},{"value":"test","source-type":"FORM","source-id":"991ad7ce00af47a48b11f594b26e0d25","source-label":"FirstName","timestamp":1357174622003,"selected":false},{"value":"Tynan","source-type":"FORM","source-id":"b8266433d9224da1b24485d8dc1af965","source-label":"FirstName","timestamp":1357172643003,"selected":false},{"value":"asdfasdf","source-type":"FORM","source-id":"cb810e81bca449ba9f6eb98244939ac7","source-label":"FirstName","timestamp":1357171743003,"selected":false},{"value":"lp","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"FirstName","timestamp":1357168954003,"selected":false},{"value":"","source-type":"FORM","source-id":"d21400c2f8c74e54ad8d44f7eab31c1b","source-label":"FirstName","timestamp":1352326575003,"selected":false},{"value":"OMG","source-type":"FORM","source-id":"acb2f0225d3b460e9c3646275ef96df0","source-label":"FirstName","timestamp":1352325781003,"selected":false},{"value":"Field","source-type":"FORM","source-id":"e399896f2bd746b3a77638ee8e5bbe26","source-label":"FirstName","timestamp":1352242517003,"selected":false},{"value":"Tynan","source-type":"FORM","source-id":"4ad10b0e88f94a81a1372cc374548177","source-label":"FirstName","timestamp":1351207972003,"selected":false},{"value":"Someone","source-type":"FORM","source-id":"78ceac5d779b4d3db0ccd5170d77093e","source-label":"FirstName","timestamp":1349291206003,"selected":false},{"value":"Tynan","source-type":"FORM","source-id":"b3f035ca7b424b38bb3428d7887174dd","source-label":"FirstName","timestamp":1349291184003,"selected":false},{"value":"safd","source-type":"FORM","source-id":"d27eebcd5fa54278baeb38643dc976f0","source-label":"FirstName","timestamp":1349213247003,"selected":false},{"value":"Tynan","source-type":"FORM","source-id":"71b182af08384ba7aafc289453d51a17","source-label":"FirstName","timestamp":1349208340003,"selected":false}]},"lifecyclestage":{"value":"lead","versions":[{"value":"lead","source-type":"MIGRATION","source-id":null,"source-label":null,"timestamp":1340137657005,"selected":false}]},"country":{"value":"Canada","versions":[{"value":"Canada","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"Country","timestamp":1357168954003,"selected":false}]},"--":{"value":"10:16
33
+ PM UTC","versions":[{"value":"10:16 PM UTC","source-type":"FORM","source-id":"d21400c2f8c74e54ad8d44f7eab31c1b","source-label":"--","timestamp":1352326575003,"selected":false},{"value":"10:13
34
+ PM UTC","source-type":"FORM","source-id":"98cbd0673c3e46ea9a6058e520ddbea0","source-label":"--","timestamp":1352326414003,"selected":false},{"value":"10:55
35
+ PM UTC","source-type":"FORM","source-id":"e399896f2bd746b3a77638ee8e5bbe26","source-label":"--","timestamp":1352242517003,"selected":false}]},"email":{"value":"repeat@test.com","versions":[{"value":"repeat@test.com","source-type":"FORM","source-id":"696997e4848d4cecb10650d18c581930","source-label":"Email","timestamp":1361917251003,"selected":false},{"value":"recreate@tynanrollo.com","source-type":"FORM","source-id":"481ceaa2ca944396971434e0b4073dae","source-label":"Email","timestamp":1361917185003,"selected":false},{"value":"hopeful@test.com","source-type":"FORM","source-id":"1aa471732f4d40dd9ec8f7b9883d6cf1","source-label":"Email","timestamp":1361912048003,"selected":false},{"value":"customer-test@test.ca","source-type":"FORM","source-id":"a6f361a7-86e7-4789-b0a9-560e6dbb29c1","source-label":"email","timestamp":1361824194003,"selected":false},{"value":"test@tynanrollo.com","source-type":"FORM","source-id":"9a0ad04cb10e462faa5ab48d656e4f5e","source-label":"Email","timestamp":1361484447003,"selected":false},{"value":"some@email.com","source-type":"FORM","source-id":"752837fcc4354d839b41e1b74d79229d","source-label":"Email","timestamp":1358445501003,"selected":false},{"value":"another-lead@tynanrollo.com","source-type":"FORM","source-id":"2467215c8e694aefb2e39b53fd365cbc","source-label":"Email","timestamp":1357339988003,"selected":false},{"value":"zomg@tynanrollo.com","source-type":"FORM","source-id":"4144ac8406154b3687985ac18a97ab4f","source-label":"Email","timestamp":1357339838003,"selected":false},{"value":"no-name@tynanrollo.com","source-type":"FORM","source-id":"2a2d05b2a07b487b85b9c1543c9db60d","source-label":"Email","timestamp":1357174898003,"selected":false},{"value":"autosmokes@tynanrollo.com","source-type":"FORM","source-id":"991ad7ce00af47a48b11f594b26e0d25","source-label":"Email","timestamp":1357174622003,"selected":false},{"value":"autosmokes-pro@tynanrollo.com","source-type":"FORM","source-id":"b8266433d9224da1b24485d8dc1af965","source-label":"Email","timestamp":1357172643003,"selected":false},{"value":"coupon_expire@tynanrollo.com","source-type":"FORM","source-id":"cb810e81bca449ba9f6eb98244939ac7","source-label":"Email","timestamp":1357171743003,"selected":false},{"value":"lp-3816@tynanrollo.com","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"Email","timestamp":1357168954003,"selected":false},{"value":"falk@tynanrollo.com","source-type":"FORM","source-id":"98cbd0673c3e46ea9a6058e520ddbea0","source-label":"Email","timestamp":1352326414003,"selected":false},{"value":"babe@tynanrollo.com","source-type":"FORM","source-id":"acb2f0225d3b460e9c3646275ef96df0","source-label":"Email","timestamp":1352325781003,"selected":false}]},"hs_analytics_first_visit_timestamp":{"value":"1340137626697","versions":[{"value":"1340137626697","source-type":"ANALYTICS","source-id":null,"source-label":null,"timestamp":1361491900004,"selected":false}]},"company":{"value":"test","versions":[{"value":"test","source-type":"FORM","source-id":"9a0ad04cb10e462faa5ab48d656e4f5e","source-label":"Company","timestamp":1361484447003,"selected":false},{"value":"s","source-type":"FORM","source-id":"752837fcc4354d839b41e1b74d79229d","source-label":"Company","timestamp":1358445501003,"selected":false},{"value":"another","source-type":"FORM","source-id":"2467215c8e694aefb2e39b53fd365cbc","source-label":"Company","timestamp":1357339988003,"selected":false},{"value":"zomg","source-type":"FORM","source-id":"4144ac8406154b3687985ac18a97ab4f","source-label":"Company","timestamp":1357339838003,"selected":false},{"value":"no
36
+ name","source-type":"FORM","source-id":"2a2d05b2a07b487b85b9c1543c9db60d","source-label":"Company","timestamp":1357174898003,"selected":false},{"value":"Unbounce
37
+ Development","source-type":"FORM","source-id":"991ad7ce00af47a48b11f594b26e0d25","source-label":"Company","timestamp":1357174622003,"selected":false},{"value":"Lucas
38
+ Test","source-type":"FORM","source-id":"cb810e81bca449ba9f6eb98244939ac7","source-label":"Company","timestamp":1357171743003,"selected":false},{"value":"3816","source-type":"FORM","source-id":"43e31c35c1954dd9ae7319ce624d6d1e","source-label":"Company","timestamp":1357168954003,"selected":false},{"value":"","source-type":"FORM","source-id":"d21400c2f8c74e54ad8d44f7eab31c1b","source-label":"Company","timestamp":1352326575003,"selected":false},{"value":"faultk","source-type":"FORM","source-id":"98cbd0673c3e46ea9a6058e520ddbea0","source-label":"Company","timestamp":1352326414003,"selected":false},{"value":"Field
39
+ Test","source-type":"FORM","source-id":"e399896f2bd746b3a77638ee8e5bbe26","source-label":"Company","timestamp":1352242517003,"selected":false}]}},"form-submissions":[{"conversion-id":"696997e4848d4cecb10650d18c581930","timestamp":1361917251000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
40
+ Test","title":"Tynan Test"},{"conversion-id":"481ceaa2ca944396971434e0b4073dae","timestamp":1361917185000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
41
+ Test","title":"Tynan Test"},{"conversion-id":"1aa471732f4d40dd9ec8f7b9883d6cf1","timestamp":1361912048000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
42
+ Test","title":"Tynan Test"},{"conversion-id":"a6f361a7-86e7-4789-b0a9-560e6dbb29c1","timestamp":1361824194284,"form-id":"014c1de3-def3-4957-b708-eb00b884db73","portal-id":62515,"page-url":"pages-test.unbounce.com/email-test-2","page-title":"c32b6d76-7f6a-11e2-98c6-1231410166db","title":"billing_phone"},{"conversion-id":"9a0ad04cb10e462faa5ab48d656e4f5e","timestamp":1361484447000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
43
+ Test","title":"Tynan Test"},{"conversion-id":"752837fcc4354d839b41e1b74d79229d","timestamp":1358445501000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
44
+ Test","title":"Tynan Test"},{"conversion-id":"712b5a36800a4f4d8f1c463d35769f81","timestamp":1358367388000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
45
+ Test","title":"Tynan Test"},{"conversion-id":"2467215c8e694aefb2e39b53fd365cbc","timestamp":1357339988000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
46
+ Test","title":"Tynan Test"},{"conversion-id":"4144ac8406154b3687985ac18a97ab4f","timestamp":1357339838000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
47
+ Test","title":"Tynan Test"},{"conversion-id":"2a2d05b2a07b487b85b9c1543c9db60d","timestamp":1357174898000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
48
+ Test","title":"Tynan Test"},{"conversion-id":"991ad7ce00af47a48b11f594b26e0d25","timestamp":1357174622000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
49
+ Test","title":"Tynan Test"},{"conversion-id":"4bfb0be48006443dac1cf764d0b1269b","timestamp":1357172814000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
50
+ Test","title":"Tynan Test"},{"conversion-id":"b8266433d9224da1b24485d8dc1af965","timestamp":1357172643000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
51
+ Test","title":"Tynan Test"},{"conversion-id":"cb810e81bca449ba9f6eb98244939ac7","timestamp":1357171743000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
52
+ Test","title":"Tynan Test"},{"conversion-id":"43e31c35c1954dd9ae7319ce624d6d1e","timestamp":1357168954000,"form-id":"faad8fc5e9234415bde1a5d64f2ee2e1","portal-id":62515,"page-title":"Tynan
53
+ Test","title":"Tynan Test"}],"list-memberships":[],"identity-profiles":[{"vid":61898,"identities":[{"type":"LEAD_GUID","value":"8a9cc91b38066d800138066dd59c000b","timestamp":1340137647000},{"type":"EMAIL","value":"repeat@test.com","timestamp":1361917251000}]}]}'
54
+ http_version:
55
+ recorded_at: Mon, 04 Mar 2013 02:30:08 GMT
56
+ - request:
57
+ method: get
58
+ uri: https://api.hubapi.com/contacts/v1/contact/utk/invalid/profile?hapikey=demo
59
+ body:
60
+ encoding: US-ASCII
61
+ string: ''
62
+ headers: {}
63
+ response:
64
+ status:
65
+ code: 404
66
+ message: Not Found
67
+ headers:
68
+ Content-Type:
69
+ - application/json;charset=UTF-8
70
+ Date:
71
+ - Mon, 04 Mar 2013 02:30:09 GMT
72
+ Server:
73
+ - Apache-Coyote/1.1
74
+ Content-Length:
75
+ - '95'
76
+ Connection:
77
+ - keep-alive
78
+ body:
79
+ encoding: US-ASCII
80
+ string: ! '{"status":"error","message":"resource not found","guid":"345d34ef-c11d-49d4-8298-28704e565faf"}'
81
+ http_version:
82
+ recorded_at: Mon, 04 Mar 2013 02:30:09 GMT
83
+ recorded_with: VCR 2.4.0
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Hubspot::Config do
4
4
  describe "#configure" do
5
- let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2"} }
5
+ let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2", portal_id: "62515"} }
6
6
  subject{ Hubspot::Config.configure(config) }
7
7
 
8
8
  it "changes the hapikey config" do
@@ -16,5 +16,40 @@ describe Hubspot::Config do
16
16
  it "sets a default value for base_url" do
17
17
  Hubspot::Config.base_url.should == "https://api.hubapi.com"
18
18
  end
19
+
20
+ it "sets a value for portal_id" do
21
+ expect{ subject }.to change(Hubspot::Config, :portal_id).to("62515")
22
+ end
23
+ end
24
+
25
+ describe "#reset!" do
26
+ let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2", portal_id: "62515"} }
27
+ before{ Hubspot::Config.configure(config) }
28
+ subject{ Hubspot::Config.reset! }
29
+ it "clears out the config" do
30
+ subject
31
+ Hubspot::Config.hapikey.should be_nil
32
+ Hubspot::Config.base_url.should == "https://api.hubapi.com"
33
+ Hubspot::Config.portal_id.should be_nil
34
+ end
35
+ end
36
+
37
+ describe "#ensure!" do
38
+ subject{ Hubspot::Config.ensure!(:hapikey, :base_url, :portal_id)}
39
+ before{ Hubspot::Config.configure(config) }
40
+
41
+ context "with a missing parameter" do
42
+ let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2"} }
43
+ it "should raise an error" do
44
+ expect { subject }.to raise_error Hubspot::ConfigurationError
45
+ end
46
+ end
47
+
48
+ context "with all requried parameters" do
49
+ let(:config){ {hapikey: "demo", base_url: "http://api.hubapi.com/v2", portal_id: "62515"} }
50
+ it "should not raise an error" do
51
+ expect { subject }.to_not raise_error
52
+ end
53
+ end
19
54
  end
20
55
  end
@@ -16,13 +16,12 @@ describe Hubspot::Contact do
16
16
  its(["firstname"]){ should == "Clint" }
17
17
  its(["lastname"]){ should == "Eastwood" }
18
18
  its(["phone"]){ should == "555-555-5432" }
19
+ its(:utk){ should == "1234567890" }
19
20
  its(:vid){ should == 82325 }
20
21
  end
21
22
 
22
23
  describe ".create!" do
23
- let(:cassette){ "contact_create" }
24
- before{ VCR.insert_cassette(cassette, record: :new_episodes) }
25
- after{ VCR.eject_cassette }
24
+ cassette "contact_create"
26
25
  let(:params){{}}
27
26
  subject{ Hubspot::Contact.create!(email, params) }
28
27
  context "with a new email" do
@@ -31,7 +30,7 @@ describe Hubspot::Contact do
31
30
  its(:email){ should match /newcontact.*@hsgem.com/ } # Due to VCR the email may not match exactly
32
31
 
33
32
  context "and some params" do
34
- let(:cassette){ "contact_create_with_params" }
33
+ cassette "contact_create_with_params"
35
34
  let(:email){ "newcontact_x_#{Time.now.to_i}@hsgem.com" }
36
35
  let(:params){ {firstname: "Hugh", lastname: "Jackman" } }
37
36
  its(["firstname"]){ should == "Hugh"}
@@ -39,14 +38,14 @@ describe Hubspot::Contact do
39
38
  end
40
39
  end
41
40
  context "with an existing email" do
42
- let(:cassette){ "contact_create_existing_email" }
41
+ cassette "contact_create_existing_email"
43
42
  let(:email){ "testingapis@hubspot.com" }
44
43
  it "raises a ContactExistsError" do
45
44
  expect{ subject }.to raise_error Hubspot::ContactExistsError
46
45
  end
47
46
  end
48
47
  context "with an invalid email" do
49
- let(:cassette){ "contact_create_invalid_email" }
48
+ cassette "contact_create_invalid_email"
50
49
  let(:email){ "not_an_email" }
51
50
  it "raises a RequestError" do
52
51
  expect{ subject }.to raise_error Hubspot::RequestError
@@ -55,8 +54,7 @@ describe Hubspot::Contact do
55
54
  end
56
55
 
57
56
  describe ".find_by_email" do
58
- before{ VCR.insert_cassette("contact_find_by_email", record: :new_episodes) }
59
- after{ VCR.eject_cassette }
57
+ cassette "contact_find_by_email"
60
58
  subject{ Hubspot::Contact.find_by_email(email) }
61
59
 
62
60
  context "when the contact is found" do
@@ -72,8 +70,7 @@ describe Hubspot::Contact do
72
70
  end
73
71
 
74
72
  describe ".find_by_id" do
75
- before{ VCR.insert_cassette("contact_find_by_id", record: :new_episodes) }
76
- after{ VCR.eject_cassette }
73
+ cassette "contact_find_by_id"
77
74
  subject{ Hubspot::Contact.find_by_id(vid) }
78
75
 
79
76
  context "when the contact is found" do
@@ -88,9 +85,24 @@ describe Hubspot::Contact do
88
85
  end
89
86
  end
90
87
 
88
+ describe ".find_by_utk" do
89
+ cassette "contact_find_by_utk"
90
+ subject{ Hubspot::Contact.find_by_utk(utk) }
91
+
92
+ context "when the contact is found" do
93
+ let(:utk){ "f844d2217850188692f2610c717c2e9b" }
94
+ it{ should be_an_instance_of Hubspot::Contact }
95
+ its(:utk){ should == "f844d2217850188692f2610c717c2e9b" }
96
+ end
97
+
98
+ context "when the contact cannot be found" do
99
+ let(:utk){ "invalid" }
100
+ it{ should be_nil }
101
+ end
102
+ end
103
+
91
104
  describe "#update!" do
92
- before{ VCR.insert_cassette("contact_update", record: :new_episodes) }
93
- after{ VCR.eject_cassette }
105
+ cassette "contact_update"
94
106
  let(:contact){ Hubspot::Contact.new(example_contact_hash) }
95
107
  let(:params){ {firstname: "Steve", lastname: "Cunningham"} }
96
108
  subject{ contact.update!(params) }
@@ -106,4 +118,28 @@ describe Hubspot::Contact do
106
118
  end
107
119
  end
108
120
  end
121
+
122
+ describe "#destroy!" do
123
+ cassette "contact_destroy"
124
+ let(:contact){ Hubspot::Contact.create!("newcontact_y_#{Time.now.to_i}@hsgem.com") }
125
+ subject{ contact.destroy! }
126
+ it { should be_true }
127
+ it "should be destroyed" do
128
+ subject
129
+ contact.destroyed?.should be_true
130
+ end
131
+ context "when the request is not successful" do
132
+ let(:contact){ Hubspot::Contact.new({"vid" => "invalid", "properties" => {}})}
133
+ it "raises an error" do
134
+ expect{ subject }.to raise_error Hubspot::RequestError
135
+ contact.destroyed?.should be_false
136
+ end
137
+ end
138
+ end
139
+
140
+ describe "#destroyed?" do
141
+ let(:contact){ Hubspot::Contact.new(example_contact_hash) }
142
+ subject{ contact }
143
+ its(:destroyed?){ should be_false }
144
+ end
109
145
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hubspot::Form do
4
+ describe "#url" do
5
+ let(:form_guid){ "abcd-efgh-1234-5678" }
6
+ subject{ Hubspot::Form.new(form_guid) }
7
+
8
+ context "when a portal_id is configured" do
9
+ before { Hubspot.configure hapikey: "demo", portal_id: "62515" }
10
+ its(:url){ should == "https://forms.hubspot.com/uploads/form/v2/62515/abcd-efgh-1234-5678" }
11
+ end
12
+
13
+ context "when a portal_id is not configured" do
14
+ before { Hubspot.configure hapikey: "demo" }
15
+ it "raises an exception" do
16
+ expect{ subject.url }.to raise_error Hubspot::ConfigurationError
17
+ end
18
+ end
19
+ end
20
+ end
@@ -34,13 +34,20 @@ describe Hubspot::Utils do
34
34
  describe ".generate_url" do
35
35
  let(:path){ "/test/:email/profile" }
36
36
  let(:params){{email: "test"}}
37
- subject{ Hubspot::Utils.generate_url(path, params) }
38
- before{ Hubspot.configure(hapikey: "demo") }
37
+ let(:options){{}}
38
+ subject{ Hubspot::Utils.generate_url(path, params, options) }
39
+ before{ Hubspot.configure(hapikey: "demo", portal_id: "62515") }
39
40
 
40
41
  it "doesn't modify params" do
41
42
  expect{ subject }.to_not change{params}
42
43
  end
43
44
 
45
+ context "with a portal_id param" do
46
+ let(:path){ "/test/:portal_id/profile" }
47
+ let(:params){{}}
48
+ it{ should == "https://api.hubapi.com/test/62515/profile?hapikey=demo" }
49
+ end
50
+
44
51
  context "when configure hasn't been called" do
45
52
  before{ Hubspot::Config.reset! }
46
53
  it "raises a config exception" do
@@ -70,5 +77,11 @@ describe Hubspot::Utils do
70
77
  let(:params){{email: "email@address.com", id: 1234}}
71
78
  it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&hapikey=demo" }
72
79
  end
80
+
81
+ context "with options" do
82
+
83
+ let(:options){ {base_url: "https://cool.com", hapikey: false} }
84
+ it{ should == "https://cool.com/test/test/profile"}
85
+ end
73
86
  end
74
87
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Contacts API Live test", live: true do
4
+ # Let's try to hit all the API endpoints at least once
5
+
4
6
  before do
5
7
  Hubspot.configure hapikey: "demo"
6
8
  end
@@ -13,5 +15,18 @@ describe "Contacts API Live test", live: true do
13
15
  contact["lastname"].should == "Eastwood"
14
16
  end
15
17
 
16
- pending "creates and destroys a contact"
18
+ it "creates and destroys a contact" do
19
+ contact = Hubspot::Contact.find_by_email("create_delete_test@hsgemtest.com")
20
+ contact.destroy! if contact
21
+ Hubspot::Contact.create!("create_delete_test@hsgemtest.com")
22
+ contact = Hubspot::Contact.find_by_email("create_delete_test@hsgemtest.com")
23
+ contact.should be_present
24
+ contact.destroy!
25
+ contact = Hubspot::Contact.find_by_email("create_delete_test@hsgemtest.com")
26
+ contact.should_not be_present
27
+ end
28
+
29
+ it "finds a contact by utk" do
30
+ Hubspot::Contact.find_by_utk("f844d2217850188692f2610c717c2e9b").should be_present
31
+ end
17
32
  end
data/spec/spec_helper.rb CHANGED
@@ -37,4 +37,6 @@ RSpec.configure do |config|
37
37
  WebMock.enable!
38
38
  VCR.turn_on!
39
39
  end
40
+
41
+ config.extend CassetteHelper
40
42
  end
@@ -0,0 +1,13 @@
1
+ module CassetteHelper
2
+ def self.extended(base)
3
+ base.around do |spec|
4
+ VCR.insert_cassette(_cassette, record: :new_episodes) if defined?(_cassette) && _cassette
5
+ spec.run
6
+ VCR.eject_cassette if defined?(_cassette) && _cassette
7
+ end
8
+ end
9
+
10
+ def cassette(cassette_name)
11
+ let(:_cassette){ cassette_name }
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubspot-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -207,22 +207,27 @@ files:
207
207
  - lib/hubspot/config.rb
208
208
  - lib/hubspot/contact.rb
209
209
  - lib/hubspot/exceptions.rb
210
+ - lib/hubspot/form.rb
210
211
  - lib/hubspot/utils.rb
211
212
  - lib/hubspot/version.rb
212
213
  - spec/fixtures/vcr_cassettes/contact_create.yml
213
214
  - spec/fixtures/vcr_cassettes/contact_create_existing_email.yml
214
215
  - spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml
215
216
  - spec/fixtures/vcr_cassettes/contact_create_with_params.yml
217
+ - spec/fixtures/vcr_cassettes/contact_destroy.yml
216
218
  - spec/fixtures/vcr_cassettes/contact_example.yml
217
219
  - spec/fixtures/vcr_cassettes/contact_find_by_email.yml
218
220
  - spec/fixtures/vcr_cassettes/contact_find_by_id.yml
221
+ - spec/fixtures/vcr_cassettes/contact_find_by_utk.yml
219
222
  - spec/fixtures/vcr_cassettes/contact_update.yml
220
223
  - spec/lib/hubspot-ruby_spec.rb
221
224
  - spec/lib/hubspot/config_spec.rb
222
225
  - spec/lib/hubspot/contact_spec.rb
226
+ - spec/lib/hubspot/form_spec.rb
223
227
  - spec/lib/hubspot/utils_spec.rb
224
228
  - spec/live/contacts_integration_spec.rb
225
229
  - spec/spec_helper.rb
230
+ - spec/support/cassette_helper.rb
226
231
  homepage: http://github.com/omadahealth/hubspot-ruby
227
232
  licenses: []
228
233
  post_install_message:
@@ -237,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
242
  version: '0'
238
243
  segments:
239
244
  - 0
240
- hash: 1080958652327679356
245
+ hash: 1072152427736485155
241
246
  required_rubygems_version: !ruby/object:Gem::Requirement
242
247
  none: false
243
248
  requirements: