closeio 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +21 -10
- data/README.md +20 -17
- data/closeio.gemspec +10 -6
- data/lib/closeio.rb +1 -42
- data/lib/closeio/client.rb +59 -0
- data/lib/closeio/resources/activity.rb +81 -0
- data/lib/closeio/resources/bulk_action.rb +34 -0
- data/lib/closeio/resources/contact.rb +37 -0
- data/lib/closeio/resources/custom_field.rb +33 -0
- data/lib/closeio/resources/email_template.rb +32 -0
- data/lib/closeio/resources/lead.rb +40 -0
- data/lib/closeio/resources/lead_status.rb +29 -0
- data/lib/closeio/resources/opportunity.rb +37 -0
- data/lib/closeio/resources/opportunity_status.rb +29 -0
- data/lib/closeio/resources/organization.rb +15 -0
- data/lib/closeio/resources/paginated_list.rb +4 -0
- data/lib/closeio/resources/report.rb +19 -0
- data/lib/closeio/resources/smart_view.rb +33 -0
- data/lib/closeio/resources/task.rb +37 -0
- data/lib/closeio/resources/user.rb +15 -0
- data/lib/closeio/version.rb +1 -1
- metadata +86 -35
- data/.document +0 -5
- data/lib/closeio/activity_report.rb +0 -20
- data/lib/closeio/base.rb +0 -92
- data/lib/closeio/bulk_action.rb +0 -25
- data/lib/closeio/config.rb +0 -23
- data/lib/closeio/contact.rb +0 -3
- data/lib/closeio/custom_field.rb +0 -8
- data/lib/closeio/custom_report.rb +0 -15
- data/lib/closeio/email_activity.rb +0 -8
- data/lib/closeio/email_template.rb +0 -3
- data/lib/closeio/lead.rb +0 -28
- data/lib/closeio/lead_status.rb +0 -7
- data/lib/closeio/note_activity.rb +0 -8
- data/lib/closeio/opportunity.rb +0 -15
- data/lib/closeio/opportunity_status.rb +0 -7
- data/lib/closeio/organization.rb +0 -8
- data/lib/closeio/paginated_list.rb +0 -27
- data/lib/closeio/railtie.rb +0 -12
- data/lib/closeio/saved_search.rb +0 -7
- data/lib/closeio/status_report.rb +0 -11
- data/lib/closeio/task.rb +0 -3
- data/lib/closeio/user.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16b49e31f5b6acbc4eb3293e99a30f416b741ac8
|
4
|
+
data.tar.gz: 37b287421327a1e720791f953d3e845f424fcaf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812abd08ffa6dec4fcacda892f1e605721e2dc3d48013e6db5b88812ab3a246dc66de45f7ae06ed9f3c1c13b0302338188779911d79555202cc274fd6c12e437
|
7
|
+
data.tar.gz: 7e81b77ab2775c44574274ddef182f162123efa1ca9f1c546b31b756f30b81b6537486827327326c9004146521c3d8b00746c8e97a02118966a8d1e7b9ef612a
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,29 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
closeio (
|
5
|
-
|
6
|
-
|
4
|
+
closeio (2.0.0)
|
5
|
+
faraday
|
6
|
+
faraday_middleware
|
7
|
+
hashie
|
8
|
+
json
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: https://rubygems.org/
|
10
12
|
specs:
|
13
|
+
addressable (2.3.7)
|
11
14
|
crack (0.4.2)
|
12
15
|
safe_yaml (~> 1.0.0)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
faraday (0.9.1)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
faraday_middleware (0.9.1)
|
19
|
+
faraday (>= 0.7.4, < 0.10)
|
20
|
+
hashie (3.4.0)
|
16
21
|
json (1.8.2)
|
17
|
-
|
22
|
+
minitest (5.5.1)
|
23
|
+
multipart-post (2.0.0)
|
18
24
|
rake (10.1.0)
|
19
25
|
safe_yaml (1.0.4)
|
20
|
-
|
26
|
+
vcr (2.9.3)
|
27
|
+
webmock (1.20.4)
|
28
|
+
addressable (>= 2.3.6)
|
29
|
+
crack (>= 0.3.2)
|
21
30
|
|
22
31
|
PLATFORMS
|
23
32
|
ruby
|
24
33
|
|
25
34
|
DEPENDENCIES
|
26
|
-
bundler
|
35
|
+
bundler
|
27
36
|
closeio!
|
37
|
+
minitest
|
28
38
|
rake
|
29
|
-
|
39
|
+
vcr
|
40
|
+
webmock
|
data/README.md
CHANGED
@@ -8,30 +8,29 @@ I :heart: Close.io, so if you have problems using the gem or would like to see s
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
````ruby
|
10
10
|
# in your Gemfile
|
11
|
-
gem 'closeio'
|
11
|
+
gem 'closeio', '~2.0'
|
12
12
|
|
13
13
|
# then...
|
14
14
|
bundle install
|
15
|
-
|
16
|
-
# Set your Api Key (`config/initializers/closeio.rb` or `config/environment/*.rb`)
|
17
|
-
Closeio.configure("xxxxxx")
|
18
15
|
````
|
19
16
|
|
20
17
|
### Usage
|
21
18
|
````ruby
|
19
|
+
client = Closeio::Client.new("api key")
|
20
|
+
|
22
21
|
# Find a specific lead
|
23
|
-
|
22
|
+
client.find_lead('lead_xxxxxxxxxxxx')
|
24
23
|
|
25
24
|
# See some data about the lead
|
26
|
-
lead.addresses
|
27
|
-
lead.contacts
|
28
|
-
lead.opportunities
|
25
|
+
lead.data.addresses
|
26
|
+
lead.data.contacts
|
27
|
+
lead.data.opportunities
|
29
28
|
|
30
29
|
# Find leads that match fields
|
31
|
-
|
30
|
+
client.list_leads('custom.favorite_color:"cornflower blue"')
|
32
31
|
|
33
32
|
# Create a lead
|
34
|
-
|
33
|
+
client.create_lead(
|
35
34
|
name: "Bluth Company",
|
36
35
|
contacts: [{
|
37
36
|
name: "Buster Bluth",
|
@@ -40,19 +39,23 @@ Add this line to your application's Gemfile:
|
|
40
39
|
)
|
41
40
|
|
42
41
|
# Saved Search (SmartView)
|
43
|
-
|
44
|
-
|
42
|
+
smart_view = client.list_smart_views
|
43
|
+
smart_views.leads
|
45
44
|
````
|
46
45
|
|
46
|
+
### History
|
47
|
+
|
48
|
+
View the [changelog](https://github.com/taylorbrooks/closeio/blob/master/CHANGELOG.md)
|
49
|
+
This gem follows [Semantic Versioning](http://semver.org/)
|
47
50
|
|
48
51
|
### Contributing
|
49
52
|
|
50
|
-
|
51
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
-
5. Create new Pull Request
|
53
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
55
54
|
|
55
|
+
- [Report bugs](https://github.com/taylorbrooks/closeio/issues)
|
56
|
+
- Fix bugs and [submit pull requests](https://github.com/taylorbrooks/closeio/pulls)
|
57
|
+
- Write, clarify, or fix documentation
|
58
|
+
- Suggest or add new features
|
56
59
|
|
57
60
|
### Copyright
|
58
61
|
Copyright (c) 2015 Taylor Brooks. See LICENSE for details.
|
data/closeio.gemspec
CHANGED
@@ -15,14 +15,18 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split($/)
|
17
17
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
-
s.test_files = s.files.grep(%r{^(test
|
18
|
+
s.test_files = s.files.grep(%r{^(test)/})
|
19
19
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_runtime_dependency
|
23
|
-
s.add_runtime_dependency
|
22
|
+
s.add_runtime_dependency 'faraday'
|
23
|
+
s.add_runtime_dependency 'faraday_middleware'
|
24
|
+
s.add_runtime_dependency 'json'
|
25
|
+
s.add_runtime_dependency 'hashie'
|
24
26
|
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
27
|
+
s.add_development_dependency 'bundler'
|
28
|
+
s.add_development_dependency 'rake'
|
29
|
+
s.add_development_dependency 'minitest'
|
30
|
+
s.add_development_dependency 'vcr'
|
31
|
+
s.add_development_dependency 'webmock'
|
28
32
|
end
|
data/lib/closeio.rb
CHANGED
@@ -1,45 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'ostruct'
|
3
|
-
require 'forwardable'
|
4
|
-
|
5
|
-
require 'closeio/base'
|
6
|
-
require 'closeio/bulk_action'
|
7
|
-
require 'closeio/contact'
|
8
|
-
require 'closeio/custom_field'
|
9
|
-
require 'closeio/email_activity'
|
10
|
-
require 'closeio/email_template'
|
11
|
-
require 'closeio/lead'
|
12
|
-
require 'closeio/lead_status'
|
13
|
-
require 'closeio/note_activity'
|
14
|
-
require 'closeio/organization'
|
15
|
-
require 'closeio/opportunity'
|
16
|
-
require 'closeio/opportunity_status'
|
17
|
-
require 'closeio/paginated_list'
|
18
|
-
require 'closeio/activity_report'
|
19
|
-
require 'closeio/custom_report'
|
20
|
-
require 'closeio/status_report'
|
21
|
-
require 'closeio/saved_search'
|
22
|
-
require 'closeio/task'
|
23
|
-
require 'closeio/user'
|
24
|
-
require 'closeio/version'
|
25
|
-
require 'closeio/config'
|
26
|
-
require 'closeio/railtie' if defined?(Rails)
|
1
|
+
require_relative 'closeio/client'
|
27
2
|
|
28
3
|
module Closeio
|
29
|
-
def self.configure(api_key=nil, opts={})
|
30
|
-
set_api_keys(api_key, opts={})
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.reset
|
34
|
-
set_api_keys(nil)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.set_api_keys(api_key, opts={})
|
38
|
-
hash = {basic_auth: {username: api_key, password: ''}}.merge!(opts)
|
39
|
-
|
40
|
-
Closeio::Base.default_options.merge!(hash)
|
41
|
-
Closeio::Base.descendants.each do |resource|
|
42
|
-
resource.default_options.merge!(hash)
|
43
|
-
end
|
44
|
-
end
|
45
4
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
|
5
|
+
|
6
|
+
module Closeio
|
7
|
+
class Client
|
8
|
+
include Closeio::Client::Activity
|
9
|
+
include Closeio::Client::BulkAction
|
10
|
+
include Closeio::Client::Contact
|
11
|
+
include Closeio::Client::CustomField
|
12
|
+
include Closeio::Client::EmailTemplate
|
13
|
+
include Closeio::Client::Lead
|
14
|
+
include Closeio::Client::LeadStatus
|
15
|
+
include Closeio::Client::Opportunity
|
16
|
+
include Closeio::Client::OpportunityStatus
|
17
|
+
include Closeio::Client::Report
|
18
|
+
include Closeio::Client::SmartView
|
19
|
+
include Closeio::Client::Task
|
20
|
+
include Closeio::Client::User
|
21
|
+
|
22
|
+
attr_reader :api_key
|
23
|
+
|
24
|
+
def initialize(api_key)
|
25
|
+
@api_key = api_key
|
26
|
+
end
|
27
|
+
|
28
|
+
def get(path, options={})
|
29
|
+
connection.get(path, options).body
|
30
|
+
end
|
31
|
+
|
32
|
+
def post(path, req_body)
|
33
|
+
connection.post do |req|
|
34
|
+
req.url(path)
|
35
|
+
req.body = req_body
|
36
|
+
end.body
|
37
|
+
end
|
38
|
+
|
39
|
+
def put(url, options={})
|
40
|
+
connection.put(path, options).body
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete(url, options = {})
|
44
|
+
connection.delete(path, options).body
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def connection
|
49
|
+
Faraday.new(url: "https://app.close.io/api/v1", headers: { accept: 'application/json' }) do |connection|
|
50
|
+
connection.basic_auth api_key, ''
|
51
|
+
connection.request :json
|
52
|
+
connection.response :logger
|
53
|
+
connection.use FaradayMiddleware::Mashify
|
54
|
+
connection.response :json
|
55
|
+
connection.adapter Faraday.default_adapter
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Closeio
|
2
|
+
class Client
|
3
|
+
module Activity
|
4
|
+
|
5
|
+
def list_activities(options={})
|
6
|
+
get(activity_path, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# Note Activities
|
11
|
+
#
|
12
|
+
|
13
|
+
def list_notes(options={})
|
14
|
+
get(note_path, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_note(options)
|
18
|
+
post(note_path, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_note(id)
|
22
|
+
get("#{note_path}#{id}/")
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete_note(id)
|
26
|
+
delete("#{note_path}#{id}/")
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Email Activities
|
31
|
+
#
|
32
|
+
|
33
|
+
def list_emails(options={})
|
34
|
+
get(email_path, options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_email(body)
|
38
|
+
post(email_path, body)
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_email(id, options={})
|
42
|
+
put("#{email_path}#{id}/", options)
|
43
|
+
end
|
44
|
+
|
45
|
+
def delete_email(id)
|
46
|
+
delete("#{email_path}#{id}/")
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Call Activities
|
51
|
+
#
|
52
|
+
|
53
|
+
def create_call(options={})
|
54
|
+
post(call_path, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete_call(id)
|
58
|
+
delete("#{call_path}#{id}/")
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def activity_path
|
64
|
+
"activity/"
|
65
|
+
end
|
66
|
+
|
67
|
+
def note_path
|
68
|
+
"activity/note/"
|
69
|
+
end
|
70
|
+
|
71
|
+
def email_path
|
72
|
+
"activity/email/"
|
73
|
+
end
|
74
|
+
|
75
|
+
def call_path
|
76
|
+
"activity/call/"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Closeio
|
2
|
+
class Client
|
3
|
+
module BulkAction
|
4
|
+
|
5
|
+
def list_bulk_emails
|
6
|
+
get(bulk_action_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def send_bulk_email(options={})
|
10
|
+
post("#{bulk_action_path}email/", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def bulk_delete(options={})
|
14
|
+
post("#{bulk_action_path}delete/", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bulk_edit(options={})
|
18
|
+
# query: search query for the edit
|
19
|
+
# type:
|
20
|
+
# set_lead_status: lead_status_id
|
21
|
+
# clear_custom_field: custom_field_name
|
22
|
+
# set_custom_field: custom_field_name, custom_field_value
|
23
|
+
post("#{bulk_action_path}edit/", options)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def bulk_action_path
|
29
|
+
"bulk_action/"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Closeio
|
2
|
+
class Client
|
3
|
+
module Contact
|
4
|
+
|
5
|
+
def list_contacts(params=nil)
|
6
|
+
get(contact_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_contact(id)
|
10
|
+
get(individual_contact_path(id))
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_contact
|
14
|
+
post(contact_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_contact
|
18
|
+
put(individual_contact_path(id))
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_contact(id)
|
22
|
+
delete(individual_contact_path(id))
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def contact_path
|
28
|
+
"contact/"
|
29
|
+
end
|
30
|
+
|
31
|
+
def individual_contact_path(id)
|
32
|
+
"#{contact_path}#{id}/"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Closeio
|
2
|
+
class Client
|
3
|
+
module CustomField
|
4
|
+
|
5
|
+
def list_custom_fields
|
6
|
+
get(custom_field_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def lead_custom_fields(id)
|
10
|
+
get("#{custom_field_path}#{id}/")
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_custom_field(options={})
|
14
|
+
post(custom_field_path, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_custom_field(id, options={})
|
18
|
+
put("#{custom_field_path}#{id}/", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_custom_field(id)
|
22
|
+
delete("#{custom_field_path}#{id}/")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def custom_field_path
|
28
|
+
"/custom_fields/lead/"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|