simple_hubspot 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTgzMmRiODNkZGY3MDhmNGIwMTg2NzUxODZjOGY2OTYxMDEzYTEyZg==
4
+ N2JjMDdiYzYyYTA1YmZlOGNjZTcyMDVhYjkyMWY3OWI0MjYxYWE4MA==
5
5
  data.tar.gz: !binary |-
6
- YjVhN2U0YzczYjI1OTVjOThjMDExOTYwMmE5NTA5M2EzMzM1ZmEzYw==
6
+ ZGZhNzMyYzA1MGUxZDY1MGY4YmVhMDA1ZGYyZTgxZmQ2MjlhMDQ3Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjIzODFkMmRiNWZmYzk4MmZiY2JkYWMyMWM1MmJhZTkwMjE0NjY3YTc1NGVi
10
- ZjBhZDQ1NWYxNjczYWJkMjhlNzEyNTNiOTI0MWI4YjBjMWVmMzgyZWVjYjU5
11
- NGZkOTY4MjU5ZDU1Mjc3Y2I0ZTRhYTc3MzdlMDY5MDFiNTAyZTM=
9
+ ZWQ0NzdkMzNmOGExZWZjMGYwYTAxYzhkMmY4ZTgzNjg2ODAxOTE2OGEzNDc3
10
+ YmNmMTczMTAzZTUwMTVjNThmMDk2ZmVkYWU5MTI3OTE5NGYxYmNiN2QwZTNm
11
+ NmY3ZTI0NTJjNzg2NTE2NjY5OTM3OTc2YjlmYmZmNjIxZjQzYTA=
12
12
  data.tar.gz: !binary |-
13
- NzRjZmIyZDJhOWE5MjhiZGE2YTkxODRjN2ZjNWNiNGY3OTk2MzQ0YTE3ZWRi
14
- NDQ5NzNjZGEwMGM0Njg5ZGEyMjkxMDQwYTI1NzFlMmQwNTRkYmFkODg3ZGVh
15
- MWRlYzA1OTRhN2UxYjBlYTczYWZlNTAzMzc3ZDY4NDIyNjZmMDY=
13
+ YWJhZjlhMTMyZDI3NTA3NWFlYzkyYTE0ZGQ2MjJmNmJkMDA3MTA5YzA4MmJl
14
+ ZWJlOGNkOTE4MzVjNjA0ZDk2NTdhYWJiNTViMzk3MDRjYTIzNjNmYmU0M2Rl
15
+ MWUxM2YyYWYxZjAyOGI2NTVhZWFmY2IzOWNhODc0MWFkZjNmMDU=
data/.gitignore CHANGED
@@ -8,3 +8,6 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.gem
11
+ .ruby-gemset
12
+ .ruby-version
13
+ *.sublime-*
data/README.md CHANGED
@@ -57,6 +57,18 @@ SimpleHubspot::Contact.find_by_email "email@email.com"
57
57
  SimpleHubspot::Contact.update 1234, { email: "email@email.com" }
58
58
  ```
59
59
 
60
+ #### Submit a Form
61
+ ```ruby
62
+ payload = { email: 'test@example.com',
63
+ property_one: 'value 1',
64
+ property_two: 'value 2',
65
+ hs_context: { hutk: '60c2ccdfe4892f0fa0593940b12c11aa',
66
+ ipAddress: '127.0.0.10',
67
+ pageUrl: 'http://demo.hubapi.com/contact/',
68
+ pageName: 'Contact Us' } }
69
+ SimpleHubspot::Form.submit_form 'FORM_GUID', payload
70
+ ```
71
+
60
72
  ## Development
61
73
 
62
74
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,4 @@
1
1
  SimpleHubspot.configure do |config|
2
2
  config.hapikey= "YOUR API KEY"
3
+ config.portal_id= "YOUR PORTAL ID"
3
4
  end
@@ -8,6 +8,7 @@ require 'logger'
8
8
  require 'simple_hubspot/utils'
9
9
  require 'simple_hubspot/api_client'
10
10
  require 'simple_hubspot/contact'
11
+ require 'simple_hubspot/form'
11
12
 
12
13
  module SimpleHubspot
13
14
 
@@ -21,11 +22,13 @@ module SimpleHubspot
21
22
  end
22
23
 
23
24
  class Configuration
24
- attr_accessor :hapikey, :api_base
25
+ attr_accessor :hapikey, :api_base, :portal_id, :form_submit_base
25
26
 
26
27
  def initialize
27
28
  @hapikey = ''
29
+ @portal_id = ''
28
30
  @api_base = 'https://api.hubapi.com'
31
+ @form_submit_base = 'https://forms.hubspot.com/uploads/form/v2/'
29
32
  end
30
33
  end
31
34
 
@@ -17,6 +17,17 @@ module SimpleHubspot
17
17
  response_fail e.response.body
18
18
  end
19
19
 
20
+ def do_form_post(guid = nil, params = {}, headers = {})
21
+ response = RestClient.post "#{SimpleHubspot.configuration.form_submit_base}#{SimpleHubspot.configuration.portal_id}/#{guid}",
22
+ params.to_json,
23
+ { content_type: 'application/x-www-form-urlencoded'}
24
+ response_success response.body
25
+ rescue RestClient::BadRequest => e
26
+ response_fail e.response.body
27
+ rescue RestClient::NotFound => e
28
+ response_fail e.response.body
29
+ end
30
+
20
31
  private
21
32
  def add_apikey
22
33
  "?hapikey=#{SimpleHubspot.configuration.hapikey}"
@@ -0,0 +1,13 @@
1
+ module SimpleHubspot
2
+ class Form
3
+
4
+ class << self
5
+
6
+ def submit_form(guid, params)
7
+ raise ArgumentError unless guid
8
+ ApiClient.do_form_post guid, { properties: Utils.hash_to_properties(params) }
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleHubspot
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_hubspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Breno Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,6 +75,7 @@ files:
75
75
  - lib/simple_hubspot.rb
76
76
  - lib/simple_hubspot/api_client.rb
77
77
  - lib/simple_hubspot/contact.rb
78
+ - lib/simple_hubspot/form.rb
78
79
  - lib/simple_hubspot/railtie.rb
79
80
  - lib/simple_hubspot/utils.rb
80
81
  - lib/simple_hubspot/version.rb