hubspot 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/lib/hubspot.rb +53 -4
  3. data/lib/hubspot/api/transaction_email/single_send.rb +37 -0
  4. data/lib/hubspot/delivery_method.rb +18 -0
  5. data/lib/hubspot/errors.rb +21 -0
  6. data/lib/hubspot/http_request.rb +44 -0
  7. data/lib/hubspot/http_response.rb +31 -0
  8. data/lib/hubspot/mailer.rb +18 -0
  9. data/lib/hubspot/object.rb +33 -0
  10. data/lib/hubspot/railtie.rb +13 -0
  11. data/lib/hubspot/transaction_email/delivery_method.rb +17 -0
  12. data/lib/hubspot/transaction_email/mailer.rb +12 -0
  13. data/lib/hubspot/version.rb +1 -1
  14. metadata +245 -158
  15. data/MIT-LICENSE +0 -20
  16. data/README.rdoc +0 -158
  17. data/Rakefile +0 -38
  18. data/app/helpers/hubspot_helper.rb +0 -17
  19. data/app/models/hubspot/base.rb +0 -40
  20. data/app/models/hubspot/blog.rb +0 -35
  21. data/app/models/hubspot/blogs/blog_association.rb +0 -35
  22. data/app/models/hubspot/blogs/comment.rb +0 -5
  23. data/app/models/hubspot/blogs/post.rb +0 -12
  24. data/app/models/hubspot/blogs/posts/comment.rb +0 -23
  25. data/app/models/hubspot/connection.rb +0 -46
  26. data/app/models/hubspot/event.rb +0 -39
  27. data/app/models/hubspot/keyword.rb +0 -49
  28. data/app/models/hubspot/lead.rb +0 -26
  29. data/app/models/hubspot/performable/event.rb +0 -67
  30. data/lib/hubspot/action_controller_extensions.rb +0 -15
  31. data/lib/hubspot/engine.rb +0 -30
  32. data/lib/tasks/hubspot_tasks.rake +0 -4
  33. data/test/dummy/README.rdoc +0 -261
  34. data/test/dummy/Rakefile +0 -7
  35. data/test/dummy/app/assets/javascripts/application.js +0 -15
  36. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  37. data/test/dummy/app/controllers/application_controller.rb +0 -3
  38. data/test/dummy/app/helpers/application_helper.rb +0 -2
  39. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  40. data/test/dummy/config.ru +0 -4
  41. data/test/dummy/config/application.rb +0 -56
  42. data/test/dummy/config/boot.rb +0 -10
  43. data/test/dummy/config/database.yml +0 -25
  44. data/test/dummy/config/environment.rb +0 -5
  45. data/test/dummy/config/environments/development.rb +0 -37
  46. data/test/dummy/config/environments/production.rb +0 -67
  47. data/test/dummy/config/environments/test.rb +0 -37
  48. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  49. data/test/dummy/config/initializers/inflections.rb +0 -15
  50. data/test/dummy/config/initializers/mime_types.rb +0 -5
  51. data/test/dummy/config/initializers/secret_token.rb +0 -7
  52. data/test/dummy/config/initializers/session_store.rb +0 -8
  53. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  54. data/test/dummy/config/locales/en.yml +0 -5
  55. data/test/dummy/config/routes.rb +0 -58
  56. data/test/dummy/db/test.sqlite3 +0 -0
  57. data/test/dummy/log/test.log +0 -2326
  58. data/test/dummy/public/404.html +0 -26
  59. data/test/dummy/public/422.html +0 -26
  60. data/test/dummy/public/500.html +0 -25
  61. data/test/dummy/public/favicon.ico +0 -0
  62. data/test/dummy/script/rails +0 -6
  63. data/test/fixtures/vcr_cassettes/blog-comments.yml +0 -74
  64. data/test/fixtures/vcr_cassettes/blog-find.yml +0 -36
  65. data/test/fixtures/vcr_cassettes/blog-posts.yml +0 -75
  66. data/test/fixtures/vcr_cassettes/blogs-list.yml +0 -39
  67. data/test/fixtures/vcr_cassettes/event-create.yml +0 -36
  68. data/test/fixtures/vcr_cassettes/event-record.yml +0 -47
  69. data/test/fixtures/vcr_cassettes/events-list.yml +0 -41
  70. data/test/fixtures/vcr_cassettes/keyword-create.yml +0 -36
  71. data/test/fixtures/vcr_cassettes/keywords-list.yml +0 -385
  72. data/test/fixtures/vcr_cassettes/lead-find.yml +0 -103
  73. data/test/fixtures/vcr_cassettes/lead-update.yml +0 -239
  74. data/test/fixtures/vcr_cassettes/leads-list.yml +0 -190
  75. data/test/fixtures/vcr_cassettes/post-comments.yml +0 -72
  76. data/test/fixtures/vcr_cassettes/post-find.yml +0 -39
  77. data/test/hubspot_test.rb +0 -5
  78. data/test/test_helper.rb +0 -22
  79. data/test/unit/blog_test.rb +0 -37
  80. data/test/unit/event_test.rb +0 -21
  81. data/test/unit/keyword_test.rb +0 -22
  82. data/test/unit/lead_test.rb +0 -31
  83. data/test/unit/performable_event_test.rb +0 -22
  84. data/test/unit/post_test.rb +0 -20
@@ -1,39 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.hubapi.com/blog/v1/posts/6ca6fdc5-a81f-44db-a63b-f56ab2636c69.json?hapikey=demo&portalId=62515
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Date:
22
- - Wed, 04 Apr 2012 23:39:14 GMT
23
- Content-Type:
24
- - application/json;charset=UTF-8
25
- Transfer-Encoding:
26
- - chunked
27
- Connection:
28
- - keep-alive
29
- Server:
30
- - Apache-Coyote/1.1
31
- body:
32
- encoding: US-ASCII
33
- string: ! '{"authorDisplayName":"testapi@hubspot.com","authorEmail":"testapi@hubspot.com","blogGuid":"0d61e4ca-e395-4c1c-8766-afaa48bf68db","body":"<b>This
34
- is the content of the blog post<\/b>","createTimestamp":1333483438000,"draft":true,"guid":"6ca6fdc5-a81f-44db-a63b-f56ab2636c69","jsonUrl":"https://api.hubapi.com/blog/v1/posts/6ca6fdc5-a81f-44db-a63b-f56ab2636c69.json","lastUpdateTimestamp":1333483438000,"metaDescription":"test
35
- metaDescription!","metaKeywords":"these are totally test keywords.","portalId":62515,"postAnalytics":null,"publishTimestamp":1333483438000,"sendNotifications":true,"summary":"This
36
- is a test summary","tags":["tag2","tag1"],"title":"I am a test post","url":"http://demo.hubapi.com/blog-for-testing/bid/103902/"}'
37
- http_version:
38
- recorded_at: Wed, 04 Apr 2012 23:39:14 GMT
39
- recorded_with: VCR 2.0.1
@@ -1,5 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HubspotTest < ActiveSupport::TestCase
4
-
5
- end
@@ -1,22 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
6
- require 'vcr'
7
-
8
- Rails.backtrace_cleaner.remove_silencers!
9
-
10
- # Load support files
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
-
13
- # Load fixtures from the engine
14
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
- end
17
-
18
- VCR.configure do |c|
19
- c.cassette_library_dir = File.expand_path("../fixtures/vcr_cassettes", __FILE__)
20
- c.allow_http_connections_when_no_cassette = true
21
- c.hook_into :webmock
22
- end
@@ -1,37 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class BlogTest < ActiveSupport::TestCase
4
-
5
- def test_should_return_blogs
6
- VCR.use_cassette('blogs-list') do
7
- blogs = Hubspot::Blog.find(:all, :params => { :max => 5 })
8
- assert_equal 5, blogs.size
9
-
10
- blog = blogs.first
11
- assert_equal ["0d61e4ca-e395-4c1c-8766-afaa48bf68db", "Test Blog (content from customers.hubspot.com)", "demo.hubapi.com/CMS/UI/Modules/BizBlogger/rss.aspx?moduleId=584130&tabId=300291", "https://api.hubapi.com/blog/v1/0d61e4ca-e395-4c1c-8766-afaa48bf68db.json", "demo.hubapi.com/blog-for-testing"], Hubspot::Blog.known_attributes.map{|attribute| blog.send(attribute)}
12
- end
13
- end
14
-
15
- def test_should_find_blog_by_guid
16
- VCR.use_cassette('blog-find') do
17
- blog = Hubspot::Blog.find("0d61e4ca-e395-4c1c-8766-afaa48bf68db")
18
- assert_not_nil blog
19
- assert_equal ["0d61e4ca-e395-4c1c-8766-afaa48bf68db", "Test Blog (content from customers.hubspot.com)", "demo.hubapi.com/CMS/UI/Modules/BizBlogger/rss.aspx?moduleId=584130&tabId=300291", "https://api.hubapi.com/blog/v1/0d61e4ca-e395-4c1c-8766-afaa48bf68db.json", "demo.hubapi.com/blog-for-testing"], Hubspot::Blog.known_attributes.map{|attribute| blog.send(attribute)}
20
- end
21
- end
22
-
23
- def test_should_return_blog_posts
24
- VCR.use_cassette('blog-posts') do
25
- blog = Hubspot::Blog.find("0d61e4ca-e395-4c1c-8766-afaa48bf68db")
26
- assert blog.posts(:max => 2).any?
27
- end
28
- end
29
-
30
- def test_should_return_blog_comments
31
- VCR.use_cassette('blog-comments') do
32
- blog = Hubspot::Blog.find("0d61e4ca-e395-4c1c-8766-afaa48bf68db")
33
- assert blog.comments(:max => 2).any?
34
- end
35
- end
36
-
37
- end
@@ -1,21 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class EventTest < ActiveSupport::TestCase
4
-
5
- def test_should_return_events
6
- VCR.use_cassette('events-list') do
7
- events = Hubspot::Event.find(:all, :params => { :max => 5 })
8
- assert_equal 5, events.size
9
-
10
- event = events.first
11
- assert_equal ["Atom Updated Atom-Powered Robots Run Amok", "iReach Distribution", "", 1333085425000], Hubspot::Event.known_attributes.map{|attribute| event.send(attribute)}
12
- end
13
- end
14
-
15
- def test_should_create_events
16
- VCR.use_cassette('event-create') do
17
- assert_equal 201, Hubspot::Event.create(:eventType => 'new event', :description => 'test', :url => 'http://dev.hubspot.com', :createDate => '1323272544000')
18
- end
19
- end
20
-
21
- end
@@ -1,22 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class KeywordTest < ActiveSupport::TestCase
4
-
5
- def test_should_return_keywords
6
- VCR.use_cassette('keywords-list') do
7
- keywords = Hubspot::Keyword.find(:all, :params => { :max => 5 })
8
- assert keywords.any?
9
-
10
- keyword = keywords.first
11
- assert_equal ["hapipy_test_keyword838"], Hubspot::Keyword.known_attributes.map{|attribute| keyword.send(attribute)}
12
- end
13
- end
14
-
15
- def test_should_create_keywords
16
- VCR.use_cassette('keyword-create') do
17
- assert keyword = Hubspot::Keyword.create({ :keyword => { :keyword => 'sleutel' }})
18
- assert_equal "1a33db71-3371-45c3-9e43-42ee24288d15", keyword.id
19
- end
20
- end
21
-
22
- end
@@ -1,31 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class LeadTest < ActiveSupport::TestCase
4
- def test_should_return_leads
5
- VCR.use_cassette('leads-list') do
6
- leads = Hubspot::Lead.find(:all, :params => { :max => 10 })
7
- assert_equal 10, leads.size
8
-
9
- lead = leads.first
10
- assert_equal ["8a41f2f22906b93a012906b9438f0008", "", "rein", "Kanaki", "adrian@hubspot.com", "http://hubspot.com", "Proquest", "", "Maharashtra", "<a href=\"http://boston.com\">Boston</a>", "12", "etas unis", "321-123-3211", "1231231234", "123", "", "Devloper", "adrianmott", "123.321.123.321", 90.6981], Hubspot::Lead.known_attributes.map{|attribute| lead.send(attribute)}
11
- end
12
- end
13
-
14
- def test_should_find_lead_by_guid
15
- VCR.use_cassette('lead-find') do
16
- lead = Hubspot::Lead.find("8a41f2f22906b93a012906b9438f0008")
17
- assert_not_nil lead
18
- assert_equal ["8a41f2f22906b93a012906b9438f0008", "", "rein", "Kanaki", "adrian@hubspot.com", "http://hubspot.com", "Proquest", "", "Maharashtra", "<a href=\"http://boston.com\">Boston</a>", "12", "etas unis", "321-123-3211", "1231231234", "123", "", "Devloper", "adrianmott", "123.321.123.321", 90.6981], Hubspot::Lead.known_attributes.map{|attribute| lead.send(attribute)}
19
- end
20
- end
21
-
22
- def test_should_update_lead
23
- VCR.use_cassette('lead-update') do
24
- lead = Hubspot::Lead.find("8a41f2f22906b93a012906b9438f0008")
25
- assert lead.update_attributes(:firstName => 'John')
26
-
27
- lead.reload
28
- assert_equal ["8a41f2f22906b93a012906b9438f0008", "", "John", "Kanaki", "adrian@hubspot.com", "http://hubspot.com", "Proquest", "", "Maharashtra", "<a href=\"http://boston.com\">Boston</a>", "12", "etas unis", "321-123-3211", "1231231234", "123", "", "Devloper", "adrianmott", "123.321.123.321", 90.6981], Hubspot::Lead.known_attributes.map{|attribute| lead.send(attribute)}
29
- end
30
- end
31
- end
@@ -1,22 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class PerformableEventTest < ActiveSupport::TestCase
4
- setup do
5
- @event = Hubspot::Performable::Event.new('event-12345', Date.civil(2012), nil, 'http://example.com')
6
- end
7
-
8
- def test_should_create_query_string
9
- assert_equal "_a=demo&_l=http%3A%2F%2Fexample.com&_n=event-12345&_t=2012-01-01", @event.to_param
10
-
11
- @event.custom_parameters = { :email => 'test@example.com' }
12
- assert_equal "_a=demo&_l=http%3A%2F%2Fexample.com&_n=event-12345&_t=2012-01-01&email=test%40example.com", @event.to_param
13
- end
14
-
15
- def test_should_record_events
16
- VCR.use_cassette('event-record') do
17
- @event.custom_parameters = { :email => 'test@example.com' }
18
- assert_equal 200, @event.record
19
- end
20
- end
21
-
22
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class PostTest < ActiveSupport::TestCase
4
-
5
- def test_should_find_post_by_guid
6
- VCR.use_cassette('post-find') do
7
- post = Hubspot::Blogs::Post.find "6ca6fdc5-a81f-44db-a63b-f56ab2636c69", :params => { :blog_guid => "0d61e4ca-e395-4c1c-8766-afaa48bf68db" }
8
- assert_not_nil post
9
- assert_equal 'This is a test summary', post.summary
10
- end
11
- end
12
-
13
- def test_should_return_post_comments
14
- VCR.use_cassette('post-comments') do
15
- post = Hubspot::Blogs::Post.find "6ca6fdc5-a81f-44db-a63b-f56ab2636c69", :params => { :blog_guid => "0d61e4ca-e395-4c1c-8766-afaa48bf68db" }
16
- assert post.comments(:max => 2).empty?
17
- end
18
- end
19
-
20
- end