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 +8 -8
- data/.gitignore +3 -0
- data/README.md +12 -0
- data/lib/generators/simple_hubspot/templates/simple_hubspot.rb +1 -0
- data/lib/simple_hubspot.rb +4 -1
- data/lib/simple_hubspot/api_client.rb +11 -0
- data/lib/simple_hubspot/form.rb +13 -0
- data/lib/simple_hubspot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2JjMDdiYzYyYTA1YmZlOGNjZTcyMDVhYjkyMWY3OWI0MjYxYWE4MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGZhNzMyYzA1MGUxZDY1MGY4YmVhMDA1ZGYyZTgxZmQ2MjlhMDQ3Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWQ0NzdkMzNmOGExZWZjMGYwYTAxYzhkMmY4ZTgzNjg2ODAxOTE2OGEzNDc3
|
10
|
+
YmNmMTczMTAzZTUwMTVjNThmMDk2ZmVkYWU5MTI3OTE5NGYxYmNiN2QwZTNm
|
11
|
+
NmY3ZTI0NTJjNzg2NTE2NjY5OTM3OTc2YjlmYmZmNjIxZjQzYTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWJhZjlhMTMyZDI3NTA3NWFlYzkyYTE0ZGQ2MjJmNmJkMDA3MTA5YzA4MmJl
|
14
|
+
ZWJlOGNkOTE4MzVjNjA0ZDk2NTdhYWJiNTViMzk3MDRjYTIzNjNmYmU0M2Rl
|
15
|
+
MWUxM2YyYWYxZjAyOGI2NTVhZWFmY2IzOWNhODc0MWFkZjNmMDU=
|
data/.gitignore
CHANGED
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.
|
data/lib/simple_hubspot.rb
CHANGED
@@ -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}"
|
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.
|
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-
|
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
|