pipeline_deals 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +79 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/a_spike.rb +72 -0
- data/lib/collection.rb +9 -0
- data/lib/pipeline_deals.rb +18 -0
- data/lib/resource.rb +25 -0
- data/lib/resources/company.rb +7 -0
- data/lib/resources/deal.rb +56 -0
- data/lib/resources/definitions.rb +10 -0
- data/lib/resources/person.rb +6 -0
- data/lib/resources/user.rb +5 -0
- data/lib/version.rb +3 -0
- data/pipeline_deals.gemspec +20 -0
- data/spec/cassettes/list_deals.yml +558 -0
- data/spec/cassettes/paginate_deals.yml +61 -0
- data/spec/pipelinedeals_spec.rb +53 -0
- data/spec/spec_helper.rb +14 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (4.0.0.beta1)
|
5
|
+
activesupport (= 4.0.0.beta1)
|
6
|
+
builder (~> 3.1.0)
|
7
|
+
erubis (~> 2.7.0)
|
8
|
+
rack (~> 1.5.2)
|
9
|
+
rack-test (~> 0.6.2)
|
10
|
+
activemodel (4.0.0.beta1)
|
11
|
+
activesupport (= 4.0.0.beta1)
|
12
|
+
builder (~> 3.1.0)
|
13
|
+
activeresource (4.0.0.beta1)
|
14
|
+
activemodel (>= 4.0.0.beta1)
|
15
|
+
activesupport (>= 4.0.0.beta1)
|
16
|
+
rails-observers (~> 0.1.1)
|
17
|
+
activesupport (4.0.0.beta1)
|
18
|
+
i18n (~> 0.6.2)
|
19
|
+
minitest (~> 4.2)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 0.3.33)
|
23
|
+
addressable (2.3.4)
|
24
|
+
atomic (1.1.8)
|
25
|
+
builder (3.1.4)
|
26
|
+
coderay (1.0.8)
|
27
|
+
crack (0.3.2)
|
28
|
+
diff-lcs (1.1.3)
|
29
|
+
erubis (2.7.0)
|
30
|
+
i18n (0.6.4)
|
31
|
+
json (1.7.7)
|
32
|
+
method_source (0.8.1)
|
33
|
+
minitest (4.3.3)
|
34
|
+
multi_json (1.7.2)
|
35
|
+
pry (0.9.12)
|
36
|
+
coderay (~> 1.0.5)
|
37
|
+
method_source (~> 0.8)
|
38
|
+
slop (~> 3.4)
|
39
|
+
rack (1.5.2)
|
40
|
+
rack-test (0.6.2)
|
41
|
+
rack (>= 1.0)
|
42
|
+
rails-observers (0.1.1)
|
43
|
+
railties (~> 4.0.0.beta)
|
44
|
+
railties (4.0.0.beta1)
|
45
|
+
actionpack (= 4.0.0.beta1)
|
46
|
+
activesupport (= 4.0.0.beta1)
|
47
|
+
rake (>= 0.8.7)
|
48
|
+
rdoc (~> 3.4)
|
49
|
+
thor (>= 0.17.0, < 2.0)
|
50
|
+
rake (10.0.3)
|
51
|
+
rdoc (3.12.1)
|
52
|
+
json (~> 1.4)
|
53
|
+
rspec (2.13.0)
|
54
|
+
rspec-core (~> 2.13.0)
|
55
|
+
rspec-expectations (~> 2.13.0)
|
56
|
+
rspec-mocks (~> 2.13.0)
|
57
|
+
rspec-core (2.13.0)
|
58
|
+
rspec-expectations (2.13.0)
|
59
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
60
|
+
rspec-mocks (2.13.0)
|
61
|
+
slop (3.4.3)
|
62
|
+
thor (0.17.0)
|
63
|
+
thread_safe (0.1.0)
|
64
|
+
atomic
|
65
|
+
tzinfo (0.3.35)
|
66
|
+
vcr (2.3.0)
|
67
|
+
webmock (1.11.0)
|
68
|
+
addressable (>= 2.2.7)
|
69
|
+
crack (>= 0.3.2)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
activeresource (= 4.0.0.beta1)
|
76
|
+
pry
|
77
|
+
rspec
|
78
|
+
vcr
|
79
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Grant Ammons
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# PipelineDeals API gem
|
2
|
+
|
3
|
+
The PipelineDeals API gem is a nice ruby wrapper around the PipelineDeals API. It will allow you full CRUD access to all of the core PipelieDeals components in a very easy-to-use library.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'pipeline_deals'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install pipeline_deals
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First and foremost, register your api key:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
PipelineDeals.api_key = 'abcd1234'
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
### Getting a single deal, person, or company:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
deal = Deal.find(1234) # find the deal
|
32
|
+
deal.name = 'blah2' # change an attribute
|
33
|
+
deal.save # re-save the deal to the site
|
34
|
+
deal.people # associations are respected
|
35
|
+
deal.people.first.id
|
36
|
+
deal.person_ids
|
37
|
+
```
|
38
|
+
|
39
|
+
### Fetching collections of deals, people, or companies
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
deals = Deal.find(:all)
|
43
|
+
deals = Deal.find(:all, params: {per_page: 5, page: 2})
|
44
|
+
deals = Deal.find(:all, params: {conditions: {deal_name: 'blah'}})
|
45
|
+
deals = Deal.where(conditions: {deal_name: 'blah'})
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
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
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/a_spike.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_resource'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class PldCollection < ActiveResource::Collection
|
6
|
+
attr_accessor :pagination
|
7
|
+
def initialize(parsed = {})
|
8
|
+
@pagination = parsed['pagination']
|
9
|
+
@elements = parsed['entries']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class PldResource < ActiveResource::Base
|
14
|
+
self.site = "http://localhost:3000/api/v3"
|
15
|
+
self.collection_parser = PldCollection
|
16
|
+
|
17
|
+
def self.find(*arguments)
|
18
|
+
scope = arguments.slice!(0)
|
19
|
+
options = arguments.slice!(0) || {}
|
20
|
+
|
21
|
+
if options[:params]
|
22
|
+
options[:params].merge!({api_key: 'n8PJJWRsx0MxgOEwGk7'})
|
23
|
+
else
|
24
|
+
options.merge!({params: {api_key: 'n8PJJWRsx0MxgOEwGk7'}})
|
25
|
+
end
|
26
|
+
|
27
|
+
super(scope, options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def save
|
31
|
+
prefix_options[:api_key] = 'n8PJJWRsx0MxgOEwGk7'
|
32
|
+
self.include_root_in_json = true
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Person < PldResource
|
38
|
+
end
|
39
|
+
|
40
|
+
class Deal < PldResource
|
41
|
+
has_many :people
|
42
|
+
end
|
43
|
+
|
44
|
+
#################################o
|
45
|
+
# Finding a single and putting
|
46
|
+
#################################o
|
47
|
+
|
48
|
+
# deal = Deal.find(1)
|
49
|
+
# $stdout << "found, deal = #{deal.inspect}\n"
|
50
|
+
# deal.name = 'blah2'
|
51
|
+
# $stdout << "About to save name:\n"
|
52
|
+
# deal.people
|
53
|
+
# deal.person_ids
|
54
|
+
# deal.custom_fields.custom_label_29 = 345
|
55
|
+
#deal.save
|
56
|
+
|
57
|
+
#################################o
|
58
|
+
# fetching collections
|
59
|
+
#################################o
|
60
|
+
|
61
|
+
# deals = Deal.find(:all)
|
62
|
+
# deals = Deal.find(:all, params: {per_page: 5, page: 2})
|
63
|
+
# deals = Deal.find(:all, params: {conditions: {deal_name: 'blah'}})
|
64
|
+
# deals = Deal.where(conditions: {deal_name: 'blah'})
|
65
|
+
|
66
|
+
|
67
|
+
#################################o
|
68
|
+
# creating
|
69
|
+
#################################o
|
70
|
+
|
71
|
+
deal = Deal.new(name: 'yeah2')
|
72
|
+
20.times {deal.save }
|
data/lib/collection.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_resource'
|
3
|
+
require_relative 'collection'
|
4
|
+
require_relative 'resource'
|
5
|
+
require_relative 'resources/definitions.rb'
|
6
|
+
require_relative 'version'
|
7
|
+
|
8
|
+
Dir[File.dirname(__FILE__) + '/resources/*.rb'].each {|file| require file }
|
9
|
+
|
10
|
+
module PipelineDeals
|
11
|
+
def self.api_key
|
12
|
+
@api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.api_key=(key)
|
16
|
+
@api_key = key
|
17
|
+
end
|
18
|
+
end
|
data/lib/resource.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module PipelineDeals
|
2
|
+
class Resource < ActiveResource::Base
|
3
|
+
self.site = "https://api.pipelinedeals.com/api/v3"
|
4
|
+
self.collection_parser = PipelineDeals::Collection
|
5
|
+
|
6
|
+
def self.find(*arguments)
|
7
|
+
scope = arguments.slice!(0)
|
8
|
+
options = arguments.slice!(0) || {}
|
9
|
+
|
10
|
+
if options[:params]
|
11
|
+
options[:params].merge!({api_key: PipelineDeals.api_key})
|
12
|
+
else
|
13
|
+
options.merge!({params: {api_key: PipelineDeals.api_key}})
|
14
|
+
end
|
15
|
+
|
16
|
+
super(scope, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def save
|
20
|
+
prefix_options[:api_key] = PipelineDeals.api_key
|
21
|
+
self.include_root_in_json = true
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module PipelineDeals
|
2
|
+
class Deal < PipelineDeals::Resource
|
3
|
+
has_many :people, :class_name => PipelineDeals::Person
|
4
|
+
has_one :primary_contact, :class_name => PipelineDeals::Person
|
5
|
+
has_one :company, :class_name => PipelineDeals::Company
|
6
|
+
belongs_to :user, :class_name => PipelineDeals::User
|
7
|
+
|
8
|
+
# {"summary"=>nil,
|
9
|
+
# "primary_contact_id"=>24,
|
10
|
+
# "expected_close_date"=>nil,
|
11
|
+
# "deal_stage_id"=>nil, "name"=>"blah2",
|
12
|
+
# "primary_contact"=>
|
13
|
+
# #<PipelineDeals::Deal::PrimaryContact:0x007f92c396b100
|
14
|
+
# @attributes={"id"=>24, "last_name"=>"buttface", "first_name"=>"Jo"},
|
15
|
+
# @persisted=true,
|
16
|
+
# @prefix_options={}>,
|
17
|
+
# "user_id"=>1,
|
18
|
+
# "company_id"=>nil,
|
19
|
+
# "source_id"=>nil,
|
20
|
+
# "is_example"=>nil,
|
21
|
+
# "created_at"=>"2013/04/16 10:09:41 -0400",
|
22
|
+
# "company"=>nil,
|
23
|
+
# "person_ids"=>[24, 25],
|
24
|
+
# "collaborators"=>[],
|
25
|
+
# "people"=>
|
26
|
+
# [#<PipelineDeals::Person:0x007f92c3969a30
|
27
|
+
# @attributes={"id"=>24, "last_name"=>"buttface", "first_name"=>"Jo"},
|
28
|
+
# @persisted=true,
|
29
|
+
# @prefix_options={}>, #<PipelineDeals::Person:0x007f92c39684a0
|
30
|
+
# @attributes={"id"=>25, "last_name"=>"O'Kon", "first_name"=>"Sherman"}, @persisted=true, @prefix_options={}>],
|
31
|
+
# "status"=>2,
|
32
|
+
# "custom_fields"=>
|
33
|
+
# #<PipelineDeals::Deal::CustomFields:0x007f92c396d928
|
34
|
+
# @attributes=
|
35
|
+
# {"custom_label_29"=>54321,
|
36
|
+
# "custom_label_27"=>nil,
|
37
|
+
# "custom_label_26"=>nil,
|
38
|
+
# "custom_label_25"=>nil},
|
39
|
+
# @persisted=true,
|
40
|
+
# @prefix_options={}>,
|
41
|
+
# "probability"=>99,
|
42
|
+
# "is_archived"=>false,
|
43
|
+
# "closed_time"=>nil,
|
44
|
+
# "deal_stage"=>nil,
|
45
|
+
# "id"=>1,
|
46
|
+
# "user"=>
|
47
|
+
# #<PipelineDeals::Deal::User:0x007f92c3976f00
|
48
|
+
# @attributes={"id"=>1, "last_name"=>"hoboson", "first_name"=>"hobo"},
|
49
|
+
# @persisted=true,
|
50
|
+
# @prefix_options={}>,
|
51
|
+
# "value_in_cents"=>5588600,
|
52
|
+
# "import_id"=>nil,
|
53
|
+
# "updated_at"=>"2013/04/19 18:18:36 -0400",
|
54
|
+
# "expected_close_date_event_id"=>nil},
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module PipelineDeals
|
2
|
+
class Deal < PipelineDeals::Resource; end
|
3
|
+
class Person < PipelineDeals::Resource; end
|
4
|
+
class Company < PipelineDeals::Resource; end
|
5
|
+
class Activity < PipelineDeals::Resource; end
|
6
|
+
class CalendarTask < PipelineDeals::Resource; end
|
7
|
+
class CalendarEvent < PipelineDeals::Resource; end
|
8
|
+
class Document < PipelineDeals::Resource; end
|
9
|
+
class User < PipelineDeals::Resource; end
|
10
|
+
end
|
data/lib/version.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require './lib/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "pipeline_deals"
|
8
|
+
gem.version = PipelineDeals::VERSION
|
9
|
+
gem.authors = ["Grant Ammons"]
|
10
|
+
gem.email = ["gammons@gmail.com"]
|
11
|
+
gem.description = %q{The pipeline_deals gem is a nice ruby wrapper around the PipelineDeals API.}
|
12
|
+
gem.summary = %q{The pipeline_deals gem is a nice ruby wrapper around the PipelineDeals API.}
|
13
|
+
gem.homepage = "https://github.com/PipelineDeals/pipelinedeals_api"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency('activeresource', '4.0.0.beta1')
|
20
|
+
end
|