closeio 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: daa2d5616721a1e2cc75b3e01dc0c727908136d9
4
+ data.tar.gz: c6d7dfa07f8788fa15fd760b9d1de7fb0d19d8e4
5
+ SHA512:
6
+ metadata.gz: 5180e1431257b5308f9b7a7663424442ac799683a02881180de72660a5ec6bff4dec5941b1a40375d8a6f57dc03528e501dd0e3a371c7fcf2806d2c16a629489
7
+ data.tar.gz: d15fbfb8687b2051f2a59ce66a3290655af6b83091c6abb38961f3c412c6247ae321ac50f3409635f5839387e661e39a10ede961c3ec5641828cc8a2071eeb15
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ closeio (0.0.1)
5
+ crack (>= 0.1.8)
6
+ httparty (>= 0.11.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ crack (0.4.1)
12
+ safe_yaml (~> 0.9.0)
13
+ httparty (0.11.0)
14
+ multi_json (~> 1.0)
15
+ multi_xml (>= 0.5.2)
16
+ multi_json (1.7.9)
17
+ multi_xml (0.5.5)
18
+ rake (10.1.0)
19
+ safe_yaml (0.9.5)
20
+ test-unit (2.5.5)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ closeio!
27
+ rake
28
+ test-unit
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Taylor Brooks
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ ### A Ruby wrapper for the Close.IO API
2
+
3
+ Learn about the Closeio API at http://developer.close.io.
4
+
5
+ ### Installation
6
+ Add this line to your application's Gemfile:
7
+ gem 'closeio'
8
+
9
+ And then execute:
10
+ $ bundle
11
+
12
+ Or install it yourself as:
13
+ $ gem install closeio
14
+
15
+ ### Usage
16
+ ````ruby
17
+ # Find a specific lead
18
+ lead = Closeio::Lead.find 'lead_xxxxxxxxxxxx'
19
+
20
+ # See some data about the lead
21
+ lead.addresses
22
+ lead.contacts
23
+ lead.opportunities
24
+
25
+ # Find leads that match fields
26
+ Closeio::Lead.where query: 'custom.current_system:[Simple Donation]'
27
+
28
+ # Saved Search (SmartView)
29
+ saved_search = Closeio::SavedSearch.first
30
+ saved_search.leads
31
+ ````
32
+
33
+ ### Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
40
+
41
+
42
+ ### Copyright
43
+ Copyright (c) 2013 Taylor Brooks. See LICENSE for details.
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rdoc/task'
4
+ Rake::RDocTask.new do |rdoc|
5
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
6
+
7
+ rdoc.rdoc_dir = 'rdoc'
8
+ rdoc.title = "closeio #{version}"
9
+ rdoc.rdoc_files.include('README*')
10
+ rdoc.rdoc_files.include('lib/**/*.rb')
11
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "closeio/version"
4
+ require "base64"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "closeio"
8
+ s.version = Closeio::VERSION
9
+ s.authors = ["Taylor Brooks"]
10
+ s.email = ["dGJyb29rc0BnbWFpbC5jb20="].map{ |e| Base64.decode64(e) }
11
+ s.homepage = "https://github.com/taylorbrooks/closeio"
12
+ s.summary = %q{A Ruby wrapper for the CloseIO API}
13
+ s.description = %q{A Ruby wrapper for the CloseIO API -- a sales CRM built by salespeople, for salespeople.}
14
+ s.license = "MIT"
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency(%q<crack>, [">= 0.1.8"])
23
+ s.add_runtime_dependency(%q<httparty>, [">= 0.11.0"])
24
+
25
+ s.add_development_dependency "bundler", "~> 1.3"
26
+ s.add_development_dependency "rake"
27
+ s.add_development_dependency "test-unit"
28
+ end
@@ -0,0 +1,15 @@
1
+ require 'httparty'
2
+ require 'ostruct'
3
+ require 'forwardable'
4
+
5
+ require 'closeio/base'
6
+ require 'closeio/activity'
7
+ require 'closeio/contact'
8
+ require 'closeio/email_template'
9
+ require 'closeio/lead'
10
+ require 'closeio/organization'
11
+ require 'closeio/paginated_list'
12
+ require 'closeio/report'
13
+ require 'closeio/saved_search'
14
+ require 'closeio/task'
15
+ require 'closeio/version'
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class Activity < Base; end
3
+ end
@@ -0,0 +1,72 @@
1
+ module Closeio
2
+ class Base < OpenStruct
3
+
4
+ include HTTParty
5
+ base_uri 'https://app.close.io/api/v1'
6
+ basic_auth ENV['CLOSEIO_API_KEY'], ''
7
+ headers 'Content-Type' => 'application/json'
8
+ debug_output $stdout
9
+ format :json
10
+
11
+ extend Forwardable
12
+ def_delegators 'self.class', :delete, :get, :post, :put, :resource_path, :bad_response
13
+
14
+ attr_reader :data
15
+
16
+ def initialize attrs={}
17
+ if attrs['data']
18
+ super attrs['data']
19
+ else
20
+ super attrs
21
+ end
22
+ end
23
+
24
+ class << self
25
+ def bad_response response
26
+ if response.class == HTTParty::Response
27
+ raise HTTParty::ResponseError, response
28
+ end
29
+ raise StandardError, 'Unknown error'
30
+ end
31
+
32
+ def all response = nil, opts={}
33
+ res = response || get(resource_path, opts)
34
+
35
+ if res.success?
36
+ res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
37
+ else
38
+ bad_response res
39
+ end
40
+ end
41
+
42
+ # Closeio::Lead.create(name: "Brooks Company", contacts: [{name: "Wyatt Brooks", emails: [{email: "wyatt@gmail.com"}]}]
43
+ def create opts={}
44
+ res = post resource_path, body: opts.to_json
45
+ res.success? ? new(res) : bad_response(res)
46
+ end
47
+
48
+ def update id, opts={}
49
+ put "#{resource_path}#{id}", body: opts.to_json
50
+ end
51
+
52
+ def destroy
53
+ if res['data'].is_a? Array
54
+ raise "Yo I'm an array"
55
+
56
+ delete "#{resource_path}#{id}"
57
+ end
58
+
59
+ end
60
+
61
+ def find id
62
+ res = get "#{resource_path}#{id}"
63
+ res.ok? ? new(res) : bad_response(res)
64
+ end
65
+
66
+ def resource_path
67
+ klass = name.split('::').last.gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
68
+ return "/#{klass}/"
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class Contact < Base; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class EmailTemplate < Base; end
3
+ end
@@ -0,0 +1,16 @@
1
+ module Closeio
2
+ class Lead < Base
3
+ #
4
+ # Options: '_limit' => 1000, 'query' => 'custom.status:2'
5
+ #
6
+ def self.where opts={}
7
+ res = get(resource_path, query: opts)
8
+
9
+ if res.success?
10
+ res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
11
+ else
12
+ bad_response res
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class Organization < Base; end
3
+ end
@@ -0,0 +1,27 @@
1
+ module Closeio
2
+ class PaginatedList < ::Array
3
+ attr_reader :total, :pages, :per_page, :page
4
+ def initialize(results)
5
+ @total = results['total']
6
+ @pages = results['pages']
7
+ @per_page = results['per_page']
8
+ @page = results['page']
9
+
10
+ result_key, result_class =
11
+ if results.has_key?('shots')
12
+ ['shots', Closeio::Shot]
13
+ elsif results.has_key?('lead')
14
+ ['leads', Closeio::Lead]
15
+ else
16
+ ['comments', Closeio::Comment]
17
+ end
18
+
19
+ super((results[result_key] || []).map { |attrs| result_class.new attrs })
20
+ end
21
+
22
+ def inspect
23
+ ivar_str = instance_variables.map {|iv| "#{iv}=#{instance_variable_get(iv).inspect}"}.join(", ")
24
+ "#<#{self.class.inspect} #{ivar_str}, @contents=#{super}>"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class Report < Base; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class SavedSearch < Base; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ class Task < Base; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Closeio
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: closeio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Taylor Brooks
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: crack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.11.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.11.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A Ruby wrapper for the CloseIO API -- a sales CRM built by salespeople,
84
+ for salespeople.
85
+ email:
86
+ - tbrooks@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .document
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - closeio.gemspec
98
+ - lib/closeio.rb
99
+ - lib/closeio/activity.rb
100
+ - lib/closeio/base.rb
101
+ - lib/closeio/contact.rb
102
+ - lib/closeio/email_template.rb
103
+ - lib/closeio/lead.rb
104
+ - lib/closeio/organization.rb
105
+ - lib/closeio/paginated_list.rb
106
+ - lib/closeio/report.rb
107
+ - lib/closeio/saved_search.rb
108
+ - lib/closeio/task.rb
109
+ - lib/closeio/version.rb
110
+ homepage: https://github.com/taylorbrooks/closeio
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.0.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: A Ruby wrapper for the CloseIO API
134
+ test_files: []