hubspot-ruby 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -22
  3. data/Gemfile.lock +14 -11
  4. data/LICENSE.txt +0 -2
  5. data/README.md +8 -6
  6. data/RELEASING.md +4 -5
  7. data/Rakefile +2 -17
  8. data/hubspot-ruby.gemspec +20 -157
  9. data/lib/hubspot-ruby.rb +10 -0
  10. data/lib/hubspot/blog.rb +1 -2
  11. data/lib/hubspot/company.rb +149 -0
  12. data/lib/hubspot/company_properties.rb +59 -0
  13. data/lib/hubspot/config.rb +10 -4
  14. data/lib/hubspot/connection.rb +12 -4
  15. data/lib/hubspot/contact.rb +52 -31
  16. data/lib/hubspot/contact_list.rb +16 -16
  17. data/lib/hubspot/contact_properties.rb +53 -6
  18. data/lib/hubspot/deal.rb +2 -2
  19. data/lib/hubspot/deal_pipeline.rb +43 -0
  20. data/lib/hubspot/deal_properties.rb +59 -0
  21. data/lib/hubspot/engagement.rb +133 -0
  22. data/lib/hubspot/exceptions.rb +1 -1
  23. data/lib/hubspot/form.rb +20 -20
  24. data/lib/hubspot/owner.rb +49 -0
  25. data/lib/hubspot/properties.rb +119 -0
  26. data/lib/hubspot/railtie.rb +10 -0
  27. data/lib/hubspot/topic.rb +2 -2
  28. data/lib/hubspot/utils.rb +106 -3
  29. data/spec/lib/hubspot/blog_spec.rb +2 -0
  30. data/spec/lib/hubspot/company_properties_spec.rb +239 -0
  31. data/spec/lib/hubspot/company_spec.rb +190 -0
  32. data/spec/lib/hubspot/config_spec.rb +1 -1
  33. data/spec/lib/hubspot/connection_spec.rb +33 -27
  34. data/spec/lib/hubspot/contact_list_spec.rb +61 -61
  35. data/spec/lib/hubspot/contact_properties_spec.rb +234 -3
  36. data/spec/lib/hubspot/contact_spec.rb +140 -71
  37. data/spec/lib/hubspot/deal_properties_spec.rb +254 -0
  38. data/spec/lib/hubspot/engagement_spec.rb +87 -0
  39. data/spec/lib/hubspot/form_spec.rb +72 -60
  40. data/spec/lib/hubspot/owner_spec.rb +56 -0
  41. data/spec/lib/hubspot/properties_spec.rb +45 -0
  42. data/spec/lib/hubspot/topic_spec.rb +0 -1
  43. data/spec/lib/hubspot/utils_spec.rb +113 -15
  44. data/spec/lib/tasks/properties_spec.rb +90 -0
  45. data/spec/live/companies_integration_spec.rb +23 -0
  46. data/spec/live/companies_properties_integration_spec.rb +120 -0
  47. data/spec/live/contacts_integration_spec.rb +1 -1
  48. data/spec/live/contacts_properties_integration_spec.rb +120 -0
  49. data/spec/live/deal_properties_integration_spec.rb +123 -0
  50. data/spec/live/deals_integration_spec.rb +1 -1
  51. data/spec/support/cassette_helper.rb +1 -1
  52. data/spec/support/tests_helper.rb +3 -3
  53. metadata +39 -78
  54. data/.document +0 -5
  55. data/lib/hubspot/version.rb +0 -9
  56. data/spec/fixtures/vcr_cassettes/add_contacts_to_lists.yml +0 -281
  57. data/spec/fixtures/vcr_cassettes/blog_list.yml +0 -180
  58. data/spec/fixtures/vcr_cassettes/blog_posts.yml +0 -107
  59. data/spec/fixtures/vcr_cassettes/blog_posts_list.yml +0 -6463
  60. data/spec/fixtures/vcr_cassettes/contact_create.yml +0 -64
  61. data/spec/fixtures/vcr_cassettes/contact_create_existing_email.yml +0 -62
  62. data/spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml +0 -63
  63. data/spec/fixtures/vcr_cassettes/contact_create_with_params.yml +0 -64
  64. data/spec/fixtures/vcr_cassettes/contact_destroy.yml +0 -131
  65. data/spec/fixtures/vcr_cassettes/contact_example.yml +0 -32
  66. data/spec/fixtures/vcr_cassettes/contact_find_by_email.yml +0 -59
  67. data/spec/fixtures/vcr_cassettes/contact_find_by_email_batch_mode.yml +0 -509
  68. data/spec/fixtures/vcr_cassettes/contact_find_by_id.yml +0 -59
  69. data/spec/fixtures/vcr_cassettes/contact_find_by_id_batch_mode.yml +0 -33
  70. data/spec/fixtures/vcr_cassettes/contact_find_by_utk.yml +0 -83
  71. data/spec/fixtures/vcr_cassettes/contact_find_by_utk_batch_mode.yml +0 -33
  72. data/spec/fixtures/vcr_cassettes/contact_list_batch_find.yml +0 -65
  73. data/spec/fixtures/vcr_cassettes/contact_list_destroy.yml +0 -63
  74. data/spec/fixtures/vcr_cassettes/contact_list_example.yml +0 -33
  75. data/spec/fixtures/vcr_cassettes/contact_list_find.yml +0 -96
  76. data/spec/fixtures/vcr_cassettes/contact_list_refresh.yml +0 -33
  77. data/spec/fixtures/vcr_cassettes/contact_list_update.yml +0 -36
  78. data/spec/fixtures/vcr_cassettes/contact_update.yml +0 -66
  79. data/spec/fixtures/vcr_cassettes/contacts_among_list.yml +0 -189
  80. data/spec/fixtures/vcr_cassettes/create_form.yml +0 -39
  81. data/spec/fixtures/vcr_cassettes/create_list.yml +0 -36
  82. data/spec/fixtures/vcr_cassettes/create_list_with_filters.yml +0 -36
  83. data/spec/fixtures/vcr_cassettes/deal_create.yml +0 -61
  84. data/spec/fixtures/vcr_cassettes/deal_example.yml +0 -166
  85. data/spec/fixtures/vcr_cassettes/deal_find.yml +0 -115
  86. data/spec/fixtures/vcr_cassettes/destroy_deal.yml +0 -221
  87. data/spec/fixtures/vcr_cassettes/fail_to_create_form.yml +0 -35
  88. data/spec/fixtures/vcr_cassettes/fail_to_create_list.yml +0 -35
  89. data/spec/fixtures/vcr_cassettes/field_among_form.yml +0 -34
  90. data/spec/fixtures/vcr_cassettes/fields_among_form.yml +0 -35
  91. data/spec/fixtures/vcr_cassettes/find_all_contacts.yml +0 -297
  92. data/spec/fixtures/vcr_cassettes/find_all_dynamic_lists.yml +0 -104
  93. data/spec/fixtures/vcr_cassettes/find_all_forms.yml +0 -15378
  94. data/spec/fixtures/vcr_cassettes/find_all_lists.yml +0 -138
  95. data/spec/fixtures/vcr_cassettes/find_all_recent_contacts.yml +0 -33
  96. data/spec/fixtures/vcr_cassettes/find_all_recent_updated_deals.yml +0 -130
  97. data/spec/fixtures/vcr_cassettes/find_all_stastic_lists.yml +0 -21876
  98. data/spec/fixtures/vcr_cassettes/form_destroy.yml +0 -64
  99. data/spec/fixtures/vcr_cassettes/form_example.yml +0 -39
  100. data/spec/fixtures/vcr_cassettes/form_find.yml +0 -69
  101. data/spec/fixtures/vcr_cassettes/form_post.yml +0 -31
  102. data/spec/fixtures/vcr_cassettes/form_submit_data.yml +0 -130
  103. data/spec/fixtures/vcr_cassettes/form_update.yml +0 -77
  104. data/spec/fixtures/vcr_cassettes/one_month_blog_posts_filter_state.yml +0 -19127
  105. data/spec/fixtures/vcr_cassettes/one_month_blog_posts_list.yml +0 -34963
  106. data/spec/fixtures/vcr_cassettes/remove_contacts_from_lists.yml +0 -315
  107. data/spec/fixtures/vcr_cassettes/topic_list.yml +0 -48
  108. data/spec/fixtures/vcr_cassettes/topics_list.yml +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1be19f1656874dfa75e7c0477b26b3c9d615710d
4
- data.tar.gz: a70226ee0a0bac7a0fc14d4b7bf8c3a0d4fdac2a
3
+ metadata.gz: 16ee939bb4d593cc623309e093902d9a937b9fda
4
+ data.tar.gz: d5c6b6765d4a3a7adda09fbb6b9a1768c91b1d86
5
5
  SHA512:
6
- metadata.gz: 120f944669ecb856d410a9490043a7e57a8ad66bbea4cc1dcfaaffbf8c8e0d741e243538b2fdc52bf760430277b54476ab1b79b4202ac18be63b6883c95dd4fe
7
- data.tar.gz: 5a5412877b5a4cc50d56321c85b40c9750e4c7ea865beef1d98c0664740656815f0cec6385e1a8c386acf8806b5b800aa480189cadd81cfa90a40e7a5e0da5b5
6
+ metadata.gz: 6f22e580fac3d5a5f4b1ac812cf21040c6105e8fc86ad4e03dc71b0aa0276bf48f4b89cf826d806eb2a7cef5be90a820c47a81a23ca27d34833bdf77a4076dfe
7
+ data.tar.gz: d322208c51497e956f63d9cb7453ce90540691af81661bcea456ca3118deb53da6fcb95a9ecd8a91f2dc433a12a47a482bb2eec1fd7043a12e7fd27ef425c32c
data/Gemfile CHANGED
@@ -1,23 +1,3 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- gem "activesupport", ">=3.0.0"
7
- gem "httparty", ">=0.10.0"
8
-
9
- # Add dependencies to develop your gem here.
10
- # Include everything needed to run rake, tests, features, etc.
11
- group :development do
12
- gem "rspec"
13
- gem "rr"
14
- gem "webmock", '< 1.10'
15
- gem "vcr"
16
- gem "rdoc"
17
- gem "bundler"
18
- gem "jeweler"
19
- gem "simplecov"
20
- gem "awesome_print"
21
- gem "timecop"
22
- gem "guard-rspec", require: false
23
- end
2
+ # Add dependencies to hubspot-ruby.gemspec
3
+ gemspec
@@ -1,3 +1,10 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hubspot-ruby (0.2.0)
5
+ activesupport (>= 3.0.0)
6
+ httparty (>= 0.10.0)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
@@ -14,7 +21,6 @@ GEM
14
21
  diff-lcs (1.2.1)
15
22
  ffi (1.9.6)
16
23
  formatador (0.2.5)
17
- git (1.2.5)
18
24
  guard (2.6.1)
19
25
  formatador (>= 0.2.4)
20
26
  listen (~> 2.7)
@@ -29,12 +35,7 @@ GEM
29
35
  multi_json (~> 1.0)
30
36
  multi_xml (>= 0.5.2)
31
37
  i18n (0.6.4)
32
- jeweler (1.8.4)
33
- bundler (~> 1.0)
34
- git (>= 1.2.5)
35
- rake
36
- rdoc
37
- json (1.8.1)
38
+ json (1.8.3)
38
39
  listen (2.7.11)
39
40
  celluloid (>= 0.15.2)
40
41
  rb-fsevent (>= 0.9.3)
@@ -47,7 +48,7 @@ GEM
47
48
  coderay (~> 1.1.0)
48
49
  method_source (~> 0.8.1)
49
50
  slop (~> 3.4)
50
- rake (10.0.3)
51
+ rake (10.4.2)
51
52
  rb-fsevent (0.9.4)
52
53
  rb-inotify (0.9.5)
53
54
  ffi (>= 0.5.0)
@@ -81,12 +82,11 @@ PLATFORMS
81
82
  ruby
82
83
 
83
84
  DEPENDENCIES
84
- activesupport (>= 3.0.0)
85
85
  awesome_print
86
86
  bundler
87
87
  guard-rspec
88
- httparty (>= 0.10.0)
89
- jeweler
88
+ hubspot-ruby!
89
+ rake
90
90
  rdoc
91
91
  rr
92
92
  rspec
@@ -94,3 +94,6 @@ DEPENDENCIES
94
94
  timecop
95
95
  vcr
96
96
  webmock (< 1.10)
97
+
98
+ BUNDLED WITH
99
+ 1.13.2
@@ -1,5 +1,3 @@
1
- Copyright (c) 2013 Omada Health, Inc
2
-
3
1
  Permission is hereby granted, free of charge, to any person obtaining
4
2
  a copy of this software and associated documentation files (the
5
3
  "Software"), to deal in the Software without restriction, including
data/README.md CHANGED
@@ -29,7 +29,13 @@ For now, this library only supports authentication with a HubSpot API key (aka "
29
29
 
30
30
  ## Usage
31
31
 
32
- Not much is supported yet, but that will change. Here's what you can do for now:
32
+ Here's what you can do for now:
33
+
34
+ ### Create a contact
35
+
36
+ ```ruby
37
+ Hubspot::Contact.create!("email@address.com", {firstname: "First", lastname: "Last"})
38
+ ```
33
39
 
34
40
  ### Find a contact
35
41
 
@@ -49,7 +55,7 @@ contact.update!({firstname: "First", lastname: "Last"})
49
55
  ```
50
56
 
51
57
  ## Contributing to hubspot-ruby
52
-
58
+
53
59
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
54
60
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
55
61
  * Fork the project.
@@ -72,7 +78,3 @@ order to disable VCR.
72
78
 
73
79
  This project and the code therein was not created by and is not supported by HubSpot, Inc or any of its affiliates.
74
80
 
75
- ## Copyright
76
-
77
- Copyright (c) 2013 Omada Health Inc. See LICENSE.txt for further details.
78
-
@@ -1,7 +1,6 @@
1
1
  # Releasing to Rubygems
2
2
 
3
- 1. Update version in `lib/hubspot/version.rb`.
4
- 2. Regenerate gemspec with `rake gemspec:generate`.
5
- 3. Commiti & push `version.rb` and `hubspot-ruby.gemspec`.
6
- 4. Build the gem with `gem build hubspot-ruby.gemspec`.
7
- 5. Push the resulting .gem file to Rubygems with `gem push`
3
+ 1. Update gemspec.
4
+ 2. Push updates to github.
5
+ 3. Build gem with `gem build hubspot-ruby.gemspec`.
6
+ 4. Push the resulting .gem file to Rubygems with `gem push`
data/Rakefile CHANGED
@@ -11,23 +11,6 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- require './lib/hubspot/version.rb'
16
- Jeweler::Tasks.new do |gem|
17
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
- gem.name = "hubspot-ruby"
19
- gem.homepage = "http://github.com/omadahealth/hubspot-ruby"
20
- #gem.license = "MIT"
21
- gem.summary = %Q{hubspot-ruby is a wrapper for the HubSpot REST API}
22
- gem.description = %Q{hubspot-ruby is a wrapper for the HubSpot REST API}
23
- gem.email = "hello@omadahealth.com"
24
- gem.authors = ["Andrew DiMichele"]
25
- gem.version = Hubspot::Version::STRING
26
-
27
- # dependencies defined in Gemfile
28
- end
29
- Jeweler::RubygemsDotOrgTasks.new
30
-
31
14
  require 'rspec/core'
32
15
  require 'rspec/core/rake_task'
33
16
 
@@ -55,3 +38,5 @@ Rake::RDocTask.new do |rdoc|
55
38
  rdoc.rdoc_files.include('README*')
56
39
  rdoc.rdoc_files.include('lib/**/*.rb')
57
40
  end
41
+
42
+ Dir.glob('lib/tasks/*.rake').each { |r| load r }
@@ -1,167 +1,30 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: hubspot-ruby 0.1.8 ruby lib
6
-
7
1
  Gem::Specification.new do |s|
8
2
  s.name = "hubspot-ruby"
9
- s.version = "0.1.8"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
3
+ s.version = "0.2.0"
12
4
  s.require_paths = ["lib"]
13
5
  s.authors = ["Andrew DiMichele"]
14
- s.date = "2015-05-12"
15
6
  s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
16
- s.email = "hello@omadahealth.com"
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".rspec",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "Guardfile",
27
- "LICENSE.txt",
28
- "README.md",
29
- "RELEASING.md",
30
- "Rakefile",
31
- "hubspot-ruby.gemspec",
32
- "lib/hubspot-ruby.rb",
33
- "lib/hubspot/blog.rb",
34
- "lib/hubspot/config.rb",
35
- "lib/hubspot/connection.rb",
36
- "lib/hubspot/contact.rb",
37
- "lib/hubspot/contact_list.rb",
38
- "lib/hubspot/contact_properties.rb",
39
- "lib/hubspot/deal.rb",
40
- "lib/hubspot/exceptions.rb",
41
- "lib/hubspot/form.rb",
42
- "lib/hubspot/topic.rb",
43
- "lib/hubspot/utils.rb",
44
- "lib/hubspot/version.rb",
45
- "spec/fixtures/vcr_cassettes/add_contacts_to_lists.yml",
46
- "spec/fixtures/vcr_cassettes/blog_list.yml",
47
- "spec/fixtures/vcr_cassettes/blog_posts.yml",
48
- "spec/fixtures/vcr_cassettes/blog_posts_list.yml",
49
- "spec/fixtures/vcr_cassettes/contact_create.yml",
50
- "spec/fixtures/vcr_cassettes/contact_create_existing_email.yml",
51
- "spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml",
52
- "spec/fixtures/vcr_cassettes/contact_create_with_params.yml",
53
- "spec/fixtures/vcr_cassettes/contact_destroy.yml",
54
- "spec/fixtures/vcr_cassettes/contact_example.yml",
55
- "spec/fixtures/vcr_cassettes/contact_find_by_email.yml",
56
- "spec/fixtures/vcr_cassettes/contact_find_by_email_batch_mode.yml",
57
- "spec/fixtures/vcr_cassettes/contact_find_by_id.yml",
58
- "spec/fixtures/vcr_cassettes/contact_find_by_id_batch_mode.yml",
59
- "spec/fixtures/vcr_cassettes/contact_find_by_utk.yml",
60
- "spec/fixtures/vcr_cassettes/contact_find_by_utk_batch_mode.yml",
61
- "spec/fixtures/vcr_cassettes/contact_list_batch_find.yml",
62
- "spec/fixtures/vcr_cassettes/contact_list_destroy.yml",
63
- "spec/fixtures/vcr_cassettes/contact_list_example.yml",
64
- "spec/fixtures/vcr_cassettes/contact_list_find.yml",
65
- "spec/fixtures/vcr_cassettes/contact_list_refresh.yml",
66
- "spec/fixtures/vcr_cassettes/contact_list_update.yml",
67
- "spec/fixtures/vcr_cassettes/contact_update.yml",
68
- "spec/fixtures/vcr_cassettes/contacts_among_list.yml",
69
- "spec/fixtures/vcr_cassettes/create_form.yml",
70
- "spec/fixtures/vcr_cassettes/create_list.yml",
71
- "spec/fixtures/vcr_cassettes/create_list_with_filters.yml",
72
- "spec/fixtures/vcr_cassettes/deal_create.yml",
73
- "spec/fixtures/vcr_cassettes/deal_example.yml",
74
- "spec/fixtures/vcr_cassettes/deal_find.yml",
75
- "spec/fixtures/vcr_cassettes/destroy_deal.yml",
76
- "spec/fixtures/vcr_cassettes/fail_to_create_form.yml",
77
- "spec/fixtures/vcr_cassettes/fail_to_create_list.yml",
78
- "spec/fixtures/vcr_cassettes/field_among_form.yml",
79
- "spec/fixtures/vcr_cassettes/fields_among_form.yml",
80
- "spec/fixtures/vcr_cassettes/find_all_contacts.yml",
81
- "spec/fixtures/vcr_cassettes/find_all_dynamic_lists.yml",
82
- "spec/fixtures/vcr_cassettes/find_all_forms.yml",
83
- "spec/fixtures/vcr_cassettes/find_all_lists.yml",
84
- "spec/fixtures/vcr_cassettes/find_all_recent_contacts.yml",
85
- "spec/fixtures/vcr_cassettes/find_all_recent_updated_deals.yml",
86
- "spec/fixtures/vcr_cassettes/find_all_stastic_lists.yml",
87
- "spec/fixtures/vcr_cassettes/form_destroy.yml",
88
- "spec/fixtures/vcr_cassettes/form_example.yml",
89
- "spec/fixtures/vcr_cassettes/form_find.yml",
90
- "spec/fixtures/vcr_cassettes/form_post.yml",
91
- "spec/fixtures/vcr_cassettes/form_submit_data.yml",
92
- "spec/fixtures/vcr_cassettes/form_update.yml",
93
- "spec/fixtures/vcr_cassettes/one_month_blog_posts_filter_state.yml",
94
- "spec/fixtures/vcr_cassettes/one_month_blog_posts_list.yml",
95
- "spec/fixtures/vcr_cassettes/remove_contacts_from_lists.yml",
96
- "spec/fixtures/vcr_cassettes/topic_list.yml",
97
- "spec/fixtures/vcr_cassettes/topics_list.yml",
98
- "spec/lib/hubspot-ruby_spec.rb",
99
- "spec/lib/hubspot/blog_spec.rb",
100
- "spec/lib/hubspot/config_spec.rb",
101
- "spec/lib/hubspot/connection_spec.rb",
102
- "spec/lib/hubspot/contact_list_spec.rb",
103
- "spec/lib/hubspot/contact_properties_spec.rb",
104
- "spec/lib/hubspot/contact_spec.rb",
105
- "spec/lib/hubspot/deal_spec.rb",
106
- "spec/lib/hubspot/form_spec.rb",
107
- "spec/lib/hubspot/topic_spec.rb",
108
- "spec/lib/hubspot/utils_spec.rb",
109
- "spec/live/contacts_integration_spec.rb",
110
- "spec/live/deals_integration_spec.rb",
111
- "spec/spec_helper.rb",
112
- "spec/support/cassette_helper.rb",
113
- "spec/support/tests_helper.rb"
114
- ]
115
- s.homepage = "http://github.com/omadahealth/hubspot-ruby"
116
- s.rubygems_version = "2.2.2"
7
+ s.files = [".rspec", "Gemfile", "Gemfile.lock", "Guardfile", "LICENSE.txt", "README.md", "RELEASING.md", "Rakefile", "hubspot-ruby.gemspec"]
8
+ s.files += Dir["lib/**/*.rb"]
9
+ s.files += Dir["spec/**/*.rb"]
10
+ s.homepage = "http://github.com/adimichele/hubspot-ruby"
117
11
  s.summary = "hubspot-ruby is a wrapper for the HubSpot REST API"
118
12
 
119
- if s.respond_to? :specification_version then
120
- s.specification_version = 4
13
+ # Add runtime dependencies here
14
+ s.add_runtime_dependency "activesupport", ">=3.0.0"
15
+ s.add_runtime_dependency "httparty", ">=0.10.0"
121
16
 
122
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
123
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
124
- s.add_runtime_dependency(%q<httparty>, [">= 0.10.0"])
125
- s.add_development_dependency(%q<rspec>, [">= 0"])
126
- s.add_development_dependency(%q<rr>, [">= 0"])
127
- s.add_development_dependency(%q<webmock>, ["< 1.10"])
128
- s.add_development_dependency(%q<vcr>, [">= 0"])
129
- s.add_development_dependency(%q<rdoc>, [">= 0"])
130
- s.add_development_dependency(%q<bundler>, [">= 0"])
131
- s.add_development_dependency(%q<jeweler>, [">= 0"])
132
- s.add_development_dependency(%q<simplecov>, [">= 0"])
133
- s.add_development_dependency(%q<awesome_print>, [">= 0"])
134
- s.add_development_dependency(%q<timecop>, [">= 0"])
135
- s.add_development_dependency(%q<guard-rspec>, [">= 0"])
136
- else
137
- s.add_dependency(%q<activesupport>, [">= 3.0.0"])
138
- s.add_dependency(%q<httparty>, [">= 0.10.0"])
139
- s.add_dependency(%q<rspec>, [">= 0"])
140
- s.add_dependency(%q<rr>, [">= 0"])
141
- s.add_dependency(%q<webmock>, ["< 1.10"])
142
- s.add_dependency(%q<vcr>, [">= 0"])
143
- s.add_dependency(%q<rdoc>, [">= 0"])
144
- s.add_dependency(%q<bundler>, [">= 0"])
145
- s.add_dependency(%q<jeweler>, [">= 0"])
146
- s.add_dependency(%q<simplecov>, [">= 0"])
147
- s.add_dependency(%q<awesome_print>, [">= 0"])
148
- s.add_dependency(%q<timecop>, [">= 0"])
149
- s.add_dependency(%q<guard-rspec>, [">= 0"])
150
- end
151
- else
152
- s.add_dependency(%q<activesupport>, [">= 3.0.0"])
153
- s.add_dependency(%q<httparty>, [">= 0.10.0"])
154
- s.add_dependency(%q<rspec>, [">= 0"])
155
- s.add_dependency(%q<rr>, [">= 0"])
156
- s.add_dependency(%q<webmock>, ["< 1.10"])
157
- s.add_dependency(%q<vcr>, [">= 0"])
158
- s.add_dependency(%q<rdoc>, [">= 0"])
159
- s.add_dependency(%q<bundler>, [">= 0"])
160
- s.add_dependency(%q<jeweler>, [">= 0"])
161
- s.add_dependency(%q<simplecov>, [">= 0"])
162
- s.add_dependency(%q<awesome_print>, [">= 0"])
163
- s.add_dependency(%q<timecop>, [">= 0"])
164
- s.add_dependency(%q<guard-rspec>, [">= 0"])
165
- end
17
+ # Add development-only dependencies here
18
+ s.add_development_dependency("rake")
19
+ s.add_development_dependency("rspec")
20
+ s.add_development_dependency("rr")
21
+ s.add_development_dependency("webmock", "< 1.10")
22
+ s.add_development_dependency("vcr")
23
+ s.add_development_dependency("rdoc")
24
+ s.add_development_dependency("bundler")
25
+ s.add_development_dependency("simplecov")
26
+ s.add_development_dependency("awesome_print")
27
+ s.add_development_dependency("timecop")
28
+ s.add_development_dependency("guard-rspec")
166
29
  end
167
30
 
@@ -1,6 +1,10 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext'
2
3
  require 'httparty'
3
4
  require 'hubspot/exceptions'
5
+ require 'hubspot/properties'
6
+ require 'hubspot/company'
7
+ require 'hubspot/company_properties'
4
8
  require 'hubspot/config'
5
9
  require 'hubspot/connection'
6
10
  require 'hubspot/contact'
@@ -10,9 +14,15 @@ require 'hubspot/form'
10
14
  require 'hubspot/blog'
11
15
  require 'hubspot/topic'
12
16
  require 'hubspot/deal'
17
+ require 'hubspot/deal_pipeline'
18
+ require 'hubspot/deal_properties'
19
+ require 'hubspot/owner'
20
+ require 'hubspot/engagement'
13
21
 
14
22
  module Hubspot
15
23
  def self.configure(config={})
16
24
  Hubspot::Config.configure(config)
17
25
  end
26
+
27
+ require 'hubspot/railtie' if defined?(Rails)
18
28
  end
@@ -41,7 +41,7 @@ module Hubspot
41
41
  # defaults to returning the last 2 months worth of published blog posts
42
42
  # in date descending order (i.e. most recent first)
43
43
  # {https://developers.hubspot.com/docs/methods/blogv2/get_blog_posts}
44
- # @return [Hubspot::BlogPost]
44
+ # @return [Hubspot::BlogPost]
45
45
  def posts(params = {})
46
46
  default_params = {
47
47
  content_group_id: self["id"],
@@ -95,5 +95,4 @@ module Hubspot
95
95
  end
96
96
  end
97
97
  end
98
-
99
98
  end
@@ -0,0 +1,149 @@
1
+ module Hubspot
2
+ #
3
+ # HubSpot Companies API
4
+ #
5
+ # {http://developers.hubspot.com/docs/methods/companies/companies-overview}
6
+ #
7
+ class Company
8
+ CREATE_COMPANY_PATH = "/companies/v2/companies/"
9
+ RECENTLY_CREATED_COMPANIES_PATH = "/companies/v2/companies/recent/created"
10
+ RECENTLY_MODIFIED_COMPANIES_PATH = "/companies/v2/companies/recent/modified"
11
+ GET_COMPANY_BY_ID_PATH = "/companies/v2/companies/:company_id"
12
+ GET_COMPANY_BY_DOMAIN_PATH = "/companies/v2/companies/domain/:domain"
13
+ UPDATE_COMPANY_PATH = "/companies/v2/companies/:company_id"
14
+ ADD_CONTACT_TO_COMPANY_PATH = "/companies/v2/companies/:company_id/contacts/:vid"
15
+ DESTROY_COMPANY_PATH = "/companies/v2/companies/:company_id"
16
+ GET_COMPANY_CONTACTS_PATH = "/companies/v2/companies/:company_id/contacts"
17
+
18
+ class << self
19
+ # Find all companies by created date (descending)
20
+ # @param opts [Hash] Possible options are:
21
+ # recently_updated [boolean] (for querying all accounts by modified time)
22
+ # count [Integer] for pagination
23
+ # offset [Integer] for pagination
24
+ # {http://developers.hubspot.com/docs/methods/companies/get_companies_created}
25
+ # {http://developers.hubspot.com/docs/methods/companies/get_companies_modified}
26
+ # @return [Array] Array of Hubspot::Company records
27
+ def all(opts={})
28
+ recently_updated = opts.delete(:recently_updated) { false }
29
+ # limit = opts.delete(:limit) { 20 }
30
+ # skip = opts.delete(:skip) { 0 }
31
+ path = if recently_updated
32
+ RECENTLY_MODIFIED_COMPANIES_PATH
33
+ else
34
+ RECENTLY_CREATED_COMPANIES_PATH
35
+ end
36
+
37
+ response = Hubspot::Connection.get_json(path, opts)
38
+ response['results'].map { |c| new(c) }
39
+ end
40
+
41
+ # Finds a list of companies by domain
42
+ # {http://developers.hubspot.com/docs/methods/companies/get_companies_by_domain}
43
+ # @param domain [String] company domain to search by
44
+ # @return [Array] Array of Hubspot::Company records
45
+ def find_by_domain(domain)
46
+ path = GET_COMPANY_BY_DOMAIN_PATH
47
+ params = { domain: domain }
48
+ raise Hubspot::InvalidParams, 'expecting Integer parameter' unless domain.try(:is_a?, String)
49
+
50
+ companies = []
51
+ begin
52
+ response = Hubspot::Connection.get_json(path, params)
53
+ companies = response.try(:map) { |company| new(company) }
54
+ rescue => e
55
+ raise e unless e.message =~ /not found/ # 404 / hanle the error and kindly return an empty array
56
+ end
57
+ companies
58
+ end
59
+
60
+ # Finds a company by domain
61
+ # {http://developers.hubspot.com/docs/methods/companies/get_company}
62
+ # @param id [Integer] company id to search by
63
+ # @return [Hubspot::Company] Company record
64
+ def find_by_id(id)
65
+ path = GET_COMPANY_BY_ID_PATH
66
+ params = { company_id: id }
67
+ raise Hubspot::InvalidParams, 'expecting Integer parameter' unless id.try(:is_a?, Integer)
68
+ response = Hubspot::Connection.get_json(path, params)
69
+ new(response)
70
+ end
71
+
72
+ # Creates a company with a name
73
+ # {http://developers.hubspot.com/docs/methods/companies/create_company}
74
+ # @param name [String]
75
+ # @return [Hubspot::Company] Company record
76
+ def create!(name, params={})
77
+ params_with_name = params.stringify_keys.merge("name" => name)
78
+ post_data = {properties: Hubspot::Utils.hash_to_properties(params_with_name, key_name: "name")}
79
+ response = Hubspot::Connection.post_json(CREATE_COMPANY_PATH, params: {}, body: post_data )
80
+ new(response)
81
+ end
82
+ end
83
+
84
+ attr_reader :properties
85
+ attr_reader :vid, :name
86
+
87
+ def initialize(response_hash)
88
+ @properties = Hubspot::Utils.properties_to_hash(response_hash["properties"])
89
+ @vid = response_hash["companyId"]
90
+ @name = @properties.try(:[], "name")
91
+ end
92
+
93
+ def [](property)
94
+ @properties[property]
95
+ end
96
+
97
+ # Updates the properties of a company
98
+ # {http://developers.hubspot.com/docs/methods/companies/update_company}
99
+ # @param params [Hash] hash of properties to update
100
+ # @return [Hubspot::Company] self
101
+ def update!(params)
102
+ query = {"properties" => Hubspot::Utils.hash_to_properties(params.stringify_keys!, key_name: "name")}
103
+ Hubspot::Connection.put_json(UPDATE_COMPANY_PATH, params: { company_id: vid }, body: query)
104
+ @properties.merge!(params)
105
+ self
106
+ end
107
+
108
+ # Adds contact to a company
109
+ # {http://developers.hubspot.com/docs/methods/companies/add_contact_to_company}
110
+ # @param id [Integer] contact id to add
111
+ # @return [Hubspot::Company] self
112
+ def add_contact(contact_or_vid)
113
+ contact_vid = if contact_or_vid.is_a?(Hubspot::Contact)
114
+ contact_or_vid.vid
115
+ else
116
+ contact_or_vid
117
+ end
118
+ Hubspot::Connection.put_json(ADD_CONTACT_TO_COMPANY_PATH,
119
+ params: {
120
+ company_id: vid,
121
+ vid: contact_vid,
122
+ },
123
+ body: nil)
124
+ self
125
+ end
126
+
127
+ # Archives the company in hubspot
128
+ # {http://developers.hubspot.com/docs/methods/companies/delete_company}
129
+ # @return [TrueClass] true
130
+ def destroy!
131
+ Hubspot::Connection.delete_json(DESTROY_COMPANY_PATH, { company_id: vid })
132
+ @destroyed = true
133
+ end
134
+
135
+ def destroyed?
136
+ !!@destroyed
137
+ end
138
+
139
+ # Finds company contacts
140
+ # {http://developers.hubspot.com/docs/methods/companies/get_company_contacts}
141
+ # @return [Array] Array of Hubspot::Contact records
142
+ def contacts
143
+ response = Hubspot::Connection.get_json(GET_COMPANY_CONTACTS_PATH, company_id: vid)
144
+ response['contacts'].each_with_object([]) do |contact, memo|
145
+ memo << Hubspot::Contact.find_by_id(contact['vid'])
146
+ end
147
+ end
148
+ end
149
+ end