simple_hubspot 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmQ0YTZiMmQ5YmU0NzE5ZGE4OTI3MjFhNjRiYjMyNDVmYjJmMTllMw==
5
+ data.tar.gz: !binary |-
6
+ ZGZlNDNjOWZkMGNkOGI4ODg2NjQwMzYyYjgxYTE5MzkyOTAwODI1Nw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDUyYmVmMjQ5ODA0NTI1NjhlZGViM2M1NjQzZDE2ZjBlZmM4ZGIxZTU5YWEy
10
+ ZTJhYmYzY2YwMGIxM2IyNWI2YzVlYzY4NmRiOGFhODE1MTE2NGM3YmIzZmY2
11
+ MzZmZGRlODRmN2ZjMWJlNDAxZjRlM2E0NjM2OTE2YTk3ZmVhM2E=
12
+ data.tar.gz: !binary |-
13
+ OTYzOWNlMjRlMWIwNGZjY2IzMjY4YTcwMTk1MmIxMjVkZDIyMWZkYjllOTcx
14
+ MDg3ZGJkNjg2MzY5MzIyYTE5MmVjOGEyZGMyNGI5ZmI5NmVkNTA2ZmMzODU2
15
+ N2IyZWIzMjFmOWRiZjc4NzYwZDlhMzc2MzcyZGJjOWNlMGU4Y2U=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format d
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+
3
+ before_install:
4
+ - gem install bundler
5
+ - gem update bundler
6
+
7
+ rvm:
8
+ - 2.0.0
9
+ - 2.1
10
+ - 2.2
11
+ - 2.3.0
12
+
13
+ deploy:
14
+ provider: rubygems
15
+ api_key: $RUBYGEMS_TOKEN
16
+ gem: simple_hubspot
17
+
18
+ sudo: false
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'webmock'
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Simple Hubspot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # SimpleHubspot
2
+
3
+ SimpleHubspot Gem is a pure light-weight implementation for Hubspot API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simple_hubspot'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simple_hubspot
20
+
21
+ ## Usage
22
+
23
+ ### Basic Usage
24
+
25
+ ```ruby
26
+ require 'simple_hubspot'
27
+ ```
28
+
29
+ Setting your `hapikey`
30
+
31
+ ```ruby
32
+ SimpleHubspot.configure do |config|
33
+ config.hapikey: "YOUR API KEY"
34
+ end
35
+ ```
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/simple_hubspot/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+ rescue LoadError
11
+ # no rspec available
12
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simple_hubspot"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ module SimpleHubspot
2
+ class ApiClient
3
+ class << self
4
+
5
+ def do_post(path = nil, params = {}, headers = {})
6
+ response = RestClient.post "#{SimpleHubspot.configuration.api_base}#{path}#{add_apikey}", params, { content_type: :json }
7
+ json = JSON.parse(response.body, symbolize_names: true)
8
+ json.merge(success: true)
9
+ end
10
+
11
+ private
12
+ def add_apikey
13
+ "?hapikey=#{SimpleHubspot.configuration.hapikey}"
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module SimpleHubspot
2
+ class Contact
3
+
4
+ class << self
5
+
6
+ def create_or_update(email, params)
7
+ ApiClient.do_post "/contacts/v1/contact/createOrUpdate/email", Utils.hash_to_properties(params)
8
+ end
9
+
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleHubspot
2
+ class Utils
3
+ class << self
4
+ def properties_to_hash(props)
5
+ newprops = HashWithIndifferentAccess.new
6
+ props.each { |k, v| newprops[k] = v["value"] }
7
+ newprops
8
+ end
9
+
10
+ def hash_to_properties(hash, opts = {})
11
+ key_name = opts[:key_name] || "property"
12
+ hash.map { |k, v| { key_name => k.to_s, "value" => v } }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleHubspot
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ require "simple_hubspot/version"
2
+
3
+ require 'ostruct'
4
+ require 'json'
5
+ require 'rest-client'
6
+ require 'logger'
7
+
8
+ require 'simple_hubspot/utils'
9
+ require 'simple_hubspot/api_client'
10
+ require 'simple_hubspot/contact'
11
+
12
+ module SimpleHubspot
13
+
14
+ class << self
15
+ attr_accessor :configuration
16
+ end
17
+
18
+ def self.configure
19
+ self.configuration ||= Configuration.new
20
+ yield(configuration)
21
+ end
22
+
23
+ class Configuration
24
+ attr_accessor :hapikey, :api_base
25
+
26
+ def initialize
27
+ @hapikey = ''
28
+ @api_base = 'https://api.hubapi.com'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simple_hubspot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_hubspot"
8
+ spec.version = SimpleHubspot::VERSION
9
+ spec.authors = ["Breno Oliveira"]
10
+ spec.email = ["breno26@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ end
15
+
16
+ spec.summary = %q{SimpleHubspot Gem is a pure light-weight implementation for Hubspot API. Best for non-rails apps.}
17
+ spec.description = %q{SimpleHubspot Gem is a pure light-weight implementation for Hubspot API. Best for non-rails apps.}
18
+ spec.homepage = "https://github.com/brenooliveira/simple_hubspot"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.8"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_dependency 'rest-client'
29
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_hubspot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Breno Oliveira
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: SimpleHubspot Gem is a pure light-weight implementation for Hubspot API.
56
+ Best for non-rails apps.
57
+ email:
58
+ - breno26@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - .travis.yml
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - lib/simple_hubspot.rb
74
+ - lib/simple_hubspot/api_client.rb
75
+ - lib/simple_hubspot/contact.rb
76
+ - lib/simple_hubspot/utils.rb
77
+ - lib/simple_hubspot/version.rb
78
+ - simple_hubspot.gemspec
79
+ homepage: https://github.com/brenooliveira/simple_hubspot
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'' to prevent pushes
84
+ to rubygems.org, or delete to allow pushes to any server.'
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.4.5
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: SimpleHubspot Gem is a pure light-weight implementation for Hubspot API.
105
+ Best for non-rails apps.
106
+ test_files: []