simple_hubspot 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/README.md +19 -1
- data/generators/simple_hubspot/simple_hubspot_generator.rb +8 -0
- data/lib/generators/simple_hubspot/install_generator.rb +15 -0
- data/lib/generators/simple_hubspot/templates/simple_hubspot.rb +3 -0
- data/lib/simple_hubspot.rb +2 -0
- data/lib/simple_hubspot/api_client.rb +19 -0
- data/lib/simple_hubspot/contact.rb +4 -1
- data/lib/simple_hubspot/railtie.rb +9 -0
- data/lib/simple_hubspot/version.rb +1 -1
- data/lib/task/simple_hubspot.rake +0 -0
- data/simple_hubspot.gemspec +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjY1NTcwNzhmYmM4MWViYzZhZjY1ODA3OGEyNzVlMTM5ZjE5NmQzNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzZmNDRkYzcyMjE2MmQ4NTYzM2Q5ZTYzNzIyMGQzMzBiOTBmNzg1NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWViMDk1ODYxZTI2ZDNiN2YxZTE4ZDYzMzQ2OTU0YTAxZTNhYmM3ZTM0YTA0
|
10
|
+
Mzk5MmU2NzdlMDQzN2MzMmNmOWNmMWU5ZmMxMjdlMDk3ODEyNGUyYWVkYjBl
|
11
|
+
ODM2NDY1MDRlNTYyZTg4ZWQ2ZmFmNzhhMDcyMTBhYzdlMDhkMzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjczYzExYTg3NDU3YjZjZTgxNzY0MGI4ZmExN2FhNzZiMTI5YWE5MjNmMGNl
|
14
|
+
MDllMzJjOGYxMDQ5NTVmYzYxYmQ5ODM4Yjg2NWYwODBlM2Q3YTNlMzg0Y2U1
|
15
|
+
ZmM2YTQyNWMwODE2Nzg4MGUyMjVkZWQ5OTZkYTJkY2E3YjExOGM=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# SimpleHubspot
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/simple_hubspot.svg)](https://badge.fury.io/rb/simple_hubspot) [![Build Status](https://travis-ci.org/brenooliveira/simple_hubspot.svg?branch=master)](https://travis-ci.org/brenooliveira/simple_hubspot) [![Code Climate](https://codeclimate.com/github/brenooliveira/simple_hubspot/badges/gpa.svg)](https://codeclimate.com/github/brenooliveira/simple_hubspot)
|
2
3
|
|
3
4
|
SimpleHubspot Gem is a pure light-weight implementation for Hubspot API
|
4
5
|
|
@@ -26,7 +27,13 @@ Or install it yourself as:
|
|
26
27
|
require 'simple_hubspot'
|
27
28
|
```
|
28
29
|
|
29
|
-
Setting your `hapikey`
|
30
|
+
Setting your `hapikey` you can create a new file in initializers from Rails
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
rails g simple_hubspot:install
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Without Rails
|
30
37
|
|
31
38
|
```ruby
|
32
39
|
SimpleHubspot.configure do |config|
|
@@ -34,6 +41,17 @@ SimpleHubspot.configure do |config|
|
|
34
41
|
end
|
35
42
|
```
|
36
43
|
|
44
|
+
#### Create Or Update Contact
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
SimpleHubspot.create_or_update "email@email.com", { name: "John", age: 14, country: 'BRAZIL' }
|
48
|
+
```
|
49
|
+
|
50
|
+
#### Find by e-mail
|
51
|
+
```ruby
|
52
|
+
SimpleHubspot.find_by_email "email@email.com"
|
53
|
+
```
|
54
|
+
|
37
55
|
## Development
|
38
56
|
|
39
57
|
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.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class SimpleHubspotGenerator < Rails::Generator::Base
|
2
|
+
desc "This generator creates an initializer file at config/initializers"
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
namespace 'simple_hubspot'
|
5
|
+
def copy_initializer_file
|
6
|
+
copy_file "simple_hubspot.rb", "config/initializers/#{file_name}.rb"
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module SimpleHubspot
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
desc "This generator creates an initializer file at config/initializers"
|
8
|
+
class_option :orm
|
9
|
+
def copy_initializer
|
10
|
+
copy_file "simple_hubspot.rb", "config/initializers/simple_hubspot.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/simple_hubspot.rb
CHANGED
@@ -4,8 +4,17 @@ module SimpleHubspot
|
|
4
4
|
|
5
5
|
def do_post(path = nil, params = {}, headers = {})
|
6
6
|
response = RestClient.post "#{SimpleHubspot.configuration.api_base}#{path}#{add_apikey}", params.to_json, { content_type: :json }
|
7
|
+
response_success response.body
|
8
|
+
rescue RestClient::BadRequest => e
|
9
|
+
response_fail e.response.body
|
10
|
+
end
|
11
|
+
|
12
|
+
def do_get(path = nil, params = {}, headers = {})
|
13
|
+
response = RestClient.get "#{SimpleHubspot.configuration.api_base}#{path}#{add_apikey}"
|
7
14
|
json = JSON.parse(response.body, symbolize_names: true)
|
8
15
|
json.merge(success: true)
|
16
|
+
rescue RestClient::BadRequest => e
|
17
|
+
response_fail e.response.body
|
9
18
|
end
|
10
19
|
|
11
20
|
private
|
@@ -13,6 +22,16 @@ module SimpleHubspot
|
|
13
22
|
"?hapikey=#{SimpleHubspot.configuration.hapikey}"
|
14
23
|
end
|
15
24
|
|
25
|
+
def response_fail(response = {})
|
26
|
+
json = JSON.parse(response, symbolize_names: true)
|
27
|
+
json.merge(success: false)
|
28
|
+
end
|
29
|
+
|
30
|
+
def response_success(response = {})
|
31
|
+
json = JSON.parse(response, symbolize_names: true)
|
32
|
+
json.merge(success: true)
|
33
|
+
end
|
34
|
+
|
16
35
|
end
|
17
36
|
end
|
18
37
|
end
|
@@ -4,9 +4,12 @@ module SimpleHubspot
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def create_or_update(email, params)
|
7
|
-
ApiClient.do_post "/contacts/v1/contact/createOrUpdate/email/#{email}", Utils.hash_to_properties(params)
|
7
|
+
ApiClient.do_post "/contacts/v1/contact/createOrUpdate/email/#{email}", { properties: Utils.hash_to_properties(params) }
|
8
8
|
end
|
9
9
|
|
10
|
+
def find_by_email(email)
|
11
|
+
ApiClient.do_get "/contacts/v1/contact/email/#{email}/profile"
|
12
|
+
end
|
10
13
|
end
|
11
14
|
|
12
15
|
end
|
File without changes
|
data/simple_hubspot.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.license = "MIT"
|
20
20
|
|
21
21
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
spec.bindir = "
|
22
|
+
spec.bindir = "bin"
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Breno Oliveira
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,11 +70,16 @@ files:
|
|
70
70
|
- Rakefile
|
71
71
|
- bin/console
|
72
72
|
- bin/setup
|
73
|
+
- generators/simple_hubspot/simple_hubspot_generator.rb
|
74
|
+
- lib/generators/simple_hubspot/install_generator.rb
|
75
|
+
- lib/generators/simple_hubspot/templates/simple_hubspot.rb
|
73
76
|
- lib/simple_hubspot.rb
|
74
77
|
- lib/simple_hubspot/api_client.rb
|
75
78
|
- lib/simple_hubspot/contact.rb
|
79
|
+
- lib/simple_hubspot/railtie.rb
|
76
80
|
- lib/simple_hubspot/utils.rb
|
77
81
|
- lib/simple_hubspot/version.rb
|
82
|
+
- lib/task/simple_hubspot.rake
|
78
83
|
- simple_hubspot.gemspec
|
79
84
|
homepage: https://github.com/brenooliveira/simple_hubspot
|
80
85
|
licenses:
|