rd_insightly 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 518232e8e70391e3c3abf96a8c6491be094e8fe0
4
+ data.tar.gz: 2cc0e1719c997568a4087620481c3cc7f0743b66
5
+ SHA512:
6
+ metadata.gz: 4c893f3ba2eb2c0d872e2584034076abeecdd8fc61bf5dd0fb8525a986d0b3ecbdedc8c5451242325384af3f46069ab8795abdf2bfff127807c69322e3bfe9b4
7
+ data.tar.gz: 58ae4284050fb634833387b3ce14e3249110a5da2136c59a3ed7c841c070860349b6a4d486caa84be70b2ec69591c545ae946807f5e02857b98896de9ce3b8ba
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: uY6QS2b7YNwKt4WEyhdSAfy5a4Fz3Ll21
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,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.4
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rd_insightly.gemspec
4
+ gemspec
5
+
6
+ gem 'rest-client'
7
+ gem 'rubocop', require: false
8
+ gem 'coveralls', require: false
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ [ ![Codeship Status for dougpetronilio/rd_insightly](https://codeship.com/projects/d36b91a0-fcc3-0132-8760-5a06a30fe976/status?branch=master)](https://codeship.com/projects/87584)
2
+ [![Code Climate](https://codeclimate.com/github/dougpetronilio/rd_insightly/badges/gpa.svg)](https://codeclimate.com/github/dougpetronilio/rd_insightly)
3
+ [![Coverage Status](https://coveralls.io/repos/dougpetronilio/rd_insightly/badge.svg)](https://coveralls.io/r/dougpetronilio/rd_insightly)
4
+ # RdInsightly
5
+
6
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rd_insightly`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+
8
+ TODO: Delete this and the text above, and describe your gem
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rd_insightly'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rd_insightly
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rd_insightly.
39
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'rd_insightly'
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,23 @@
1
+ module RdInsightly
2
+ class Auth
3
+ attr_reader :api_token
4
+
5
+ def initialize(api_token)
6
+ @api_token = api_token
7
+ end
8
+
9
+ def self.create(api_token = nil)
10
+ fail ApiTokenException if api_token.nil?
11
+ Auth.new(api_token)
12
+ end
13
+
14
+ def authorized?
15
+ @api_token = nil unless ApiInsightly.authentication
16
+ !@api_token.nil?
17
+ end
18
+
19
+ def self.loggout
20
+ @api_token = nil
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module RdInsightly
2
+ class ApiTokenException < Exception
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module RdInsightly
2
+ class LeadException < Exception
3
+ end
4
+ end
@@ -0,0 +1,23 @@
1
+ module RdInsightly
2
+ module ApiInsightly
3
+ AUTHORIZED = true
4
+ UNAUTHORIZED = false
5
+
6
+ def self.authentication
7
+ RestClient.get('https://api.insight.ly/v2.1/contacts', Authorization: authorization_string)
8
+ AUTHORIZED
9
+ rescue
10
+ UNAUTHORIZED
11
+ end
12
+
13
+ def self.leads
14
+ RestClient.get('https://api.insight.ly/v2.1/contacts', Authorization: authorization_string)
15
+ rescue
16
+ nil
17
+ end
18
+
19
+ def self.authorization_string
20
+ "Basic #{Base64.encode64(RdInsightly.api_token)}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module RdInsightly
2
+ class Lead
3
+ attr_reader :name
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ end
8
+
9
+ def self.create(name = nil)
10
+ fail LeadException if name.nil?
11
+ fail ApiTokenException unless RdInsightly.authorized?
12
+ Lead.new name
13
+ end
14
+
15
+ def self.all
16
+ fail ApiTokenException unless RdInsightly.authorized?
17
+ ApiInsightly.leads
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module RdInsightly
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,24 @@
1
+ require 'rd_insightly/version'
2
+ require 'rd_insightly/lead'
3
+ require 'rd_insightly/exception/lead_exception'
4
+ require 'rd_insightly/exception/api_token_exception'
5
+ require 'rd_insightly/auth'
6
+ require 'rd_insightly/insightly/api_insightly'
7
+ require 'rest-client'
8
+ require 'base64'
9
+ require 'singleton'
10
+
11
+ module RdInsightly
12
+ @auth = nil
13
+ def self.create_authorization(api_token)
14
+ @auth = Auth.create(api_token)
15
+ end
16
+
17
+ def self.authorized?
18
+ @auth.authorized?
19
+ end
20
+
21
+ def self.api_token
22
+ @auth.api_token
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rd_insightly/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rd_insightly'
8
+ spec.version = RdInsightly::VERSION
9
+ spec.authors = ['Douglas Oliveira']
10
+ spec.email = ['dougpetronilio@gmail.com']
11
+
12
+ spec.summary = 'Gem built to integrate leads rd and insightly'
13
+ spec.description = 'this Gem was built to integrate leads rd and insightly'
14
+ spec.homepage = 'http://github.com/dougpetronilio/rd_insightly'
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.10'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec'
32
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rd_insightly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Douglas Oliveira
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-25 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: this Gem was built to integrate leads rd and insightly
56
+ email:
57
+ - dougpetronilio@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .coveralls.yml
63
+ - .gitignore
64
+ - .rspec
65
+ - .rubocop.yml
66
+ - .travis.yml
67
+ - Gemfile
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/rd_insightly.rb
73
+ - lib/rd_insightly/auth.rb
74
+ - lib/rd_insightly/exception/api_token_exception.rb
75
+ - lib/rd_insightly/exception/lead_exception.rb
76
+ - lib/rd_insightly/insightly/api_insightly.rb
77
+ - lib/rd_insightly/lead.rb
78
+ - lib/rd_insightly/version.rb
79
+ - rd_insightly.gemspec
80
+ homepage: http://github.com/dougpetronilio/rd_insightly
81
+ licenses: []
82
+ metadata:
83
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.0.14
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Gem built to integrate leads rd and insightly
104
+ test_files: []