simple_hubspot 0.1.1 → 0.1.2

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
- YzVkZjIxZjM2NzVjYjk5ZmYwM2IzMDJjOTE1YmQ5ZmZhNjJkYzM0Zg==
4
+ YjY1NTcwNzhmYmM4MWViYzZhZjY1ODA3OGEyNzVlMTM5ZjE5NmQzNw==
5
5
  data.tar.gz: !binary |-
6
- NzkxODMwZTYxZjEwODdlOGI4MDg0ZTdkYWZjZTJjZGI0OGQ1ODgzNg==
6
+ NzZmNDRkYzcyMjE2MmQ4NTYzM2Q5ZTYzNzIyMGQzMzBiOTBmNzg1NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDFkZGRjZDBjZWQ5ZjE5N2JiOTM5MzU2NDFlMTBiNzExMzY1Y2VmZWNhM2Zl
10
- OWZhYzZiM2Q3N2NmOTNiYjBhNGU5MjRhYzU3M2M0NGJhZWU1NzJiODQ1M2E2
11
- NWEzMTUzMjJjMmQ2OGM0ODkyZjhmYmI4NTNjNjU3OGI0YjdhZTI=
9
+ OWViMDk1ODYxZTI2ZDNiN2YxZTE4ZDYzMzQ2OTU0YTAxZTNhYmM3ZTM0YTA0
10
+ Mzk5MmU2NzdlMDQzN2MzMmNmOWNmMWU5ZmMxMjdlMDk3ODEyNGUyYWVkYjBl
11
+ ODM2NDY1MDRlNTYyZTg4ZWQ2ZmFmNzhhMDcyMTBhYzdlMDhkMzY=
12
12
  data.tar.gz: !binary |-
13
- N2U2NGMyODUwMGEzOWE2MDcyZWU5Yzk2MjdmNjI0OGE5ZGUxY2Q0YmM5ZjYx
14
- ZjlmYjIyYTIxZjY2OWYwMWQ4MmFkZjBiNWQ2YjZhMTFmNmNmOWY4NmJmMTI5
15
- MDU3NWQ2OGUxY2ZjZjJjNGJmNmY5ZDNjMzMzYmQ0YWU4NTdjMWQ=
13
+ ZjczYzExYTg3NDU3YjZjZTgxNzY0MGI4ZmExN2FhNzZiMTI5YWE5MjNmMGNl
14
+ MDllMzJjOGYxMDQ5NTVmYzYxYmQ5ODM4Yjg2NWYwODBlM2Q3YTNlMzg0Y2U1
15
+ ZmM2YTQyNWMwODE2Nzg4MGUyMjVkZWQ5OTZkYTJkY2E3YjExOGM=
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
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
@@ -0,0 +1,3 @@
1
+ SimpleHubspot.configure do |config|
2
+ config.hapikey: "YOUR API KEY"
3
+ end
@@ -28,4 +28,6 @@ module SimpleHubspot
28
28
  @api_base = 'https://api.hubapi.com'
29
29
  end
30
30
  end
31
+
32
+ require 'simple_hubspot/railtie' if defined?(Rails)
31
33
  end
@@ -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
@@ -0,0 +1,9 @@
1
+ module SimpleHubspot
2
+ class Railtie < Rails::Railtie
3
+
4
+ rake_tasks do
5
+ load "task/simple_hubspot.rake"
6
+ end
7
+
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleHubspot
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
File without changes
@@ -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 = "exe"
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Breno Oliveira
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
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: