pipejump 0.2.0 → 0.3.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.
- data/.gitignore +4 -1
- data/.rspec +1 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +20 -15
- data/Rakefile +4 -31
- data/VERSION +1 -1
- data/lib/pipejump/base/collection.rb +15 -15
- data/lib/pipejump/base/connection.rb +14 -14
- data/lib/pipejump/base/resource.rb +49 -41
- data/lib/pipejump/base/session.rb +81 -69
- data/lib/pipejump/resources/contact.rb +131 -121
- data/lib/pipejump/resources/deal.rb +122 -122
- data/lib/pipejump/resources/reminder.rb +97 -94
- data/lib/pipejump/version.rb +3 -0
- data/lib/pipejump.rb +1 -2
- data/pipejump.gemspec +21 -0
- data/spec/pipejump/resources/contact/note_spec.rb +100 -0
- data/spec/pipejump/resources/contact/reminder_spec.rb +128 -0
- data/spec/pipejump/resources/contact_spec.rb +45 -37
- data/spec/pipejump/resources/{note_spec.rb → deal/note_spec.rb} +29 -28
- data/spec/pipejump/resources/{reminder_spec.rb → deal/reminder_spec.rb} +43 -35
- data/spec/pipejump/resources/deal_spec.rb +45 -39
- data/spec/pipejump/resources/source_spec.rb +29 -26
- data/spec/pipejump/session_spec.rb +12 -13
- data/spec/spec_helper.rb +17 -2
- metadata +25 -45
- data/lib/pipejump/resources/client.rb +0 -162
- data/spec/pipejump/resources/client_spec.rb +0 -119
@@ -1,99 +1,103 @@
|
|
1
1
|
module Pipejump
|
2
|
-
|
2
|
+
|
3
3
|
# The Pipejump::Session instance represents an active Session with the Pipejump API
|
4
|
-
#
|
5
|
-
# Any access to the Pipejump API requires authentication, which means you need to initialize a
|
4
|
+
#
|
5
|
+
# Any access to the Pipejump API requires authentication, which means you need to initialize a
|
6
6
|
# Pipejump::Session instance before calling any other methods
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# == Authentication
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# To authenticate, simply call Pipejump::Session.new with a argument hash with the following keys:
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# * _email_ - your Pipejump user account email
|
13
13
|
# * _password_ - your Pipejump user account password
|
14
|
-
# * _endpoint_ - (optional) Default is
|
15
|
-
#
|
14
|
+
# * _endpoint_ - (optional) Default is https://sales.futuresimple.com, however you can override it (for example for development)
|
15
|
+
#
|
16
16
|
# You can perform later actions either on a instance returned by the canstructor or within a supplied block
|
17
|
-
#
|
18
|
-
#
|
17
|
+
#
|
18
|
+
#
|
19
19
|
# @session = Pipejump::Session.new(:email => EMAIL, :password => PASSWORD)
|
20
20
|
# @session.account
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# or
|
24
|
-
#
|
25
|
-
#
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# or
|
24
|
+
#
|
25
|
+
#
|
26
26
|
# Pipejump::Session.new(:email => EMAIL, :password => PASSWORD) do |session|
|
27
27
|
# session.account
|
28
28
|
# end
|
29
29
|
#
|
30
30
|
# As of version 0.1.1 you can use the token which is fetched when authenticating using the email and password. So once you get the token, you can use it for future initialization of the Session and not send the username and password, which is a more secure.
|
31
|
-
#
|
31
|
+
#
|
32
32
|
# @session = Pipejump::Session.new(:token => 'your_token')
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# Also, as of version 0.1.1 connection is performed over SSL.
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
35
|
+
#
|
36
|
+
#
|
37
|
+
#
|
38
|
+
#
|
39
39
|
# == Account
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# To access the Account instance, call the account method
|
42
|
-
#
|
43
|
-
#
|
42
|
+
#
|
43
|
+
#
|
44
44
|
# @session.account # => #<Pipejump::Account name: "myaccount", id: "1", currency_name: "$">
|
45
|
-
#
|
46
|
-
#
|
45
|
+
#
|
46
|
+
#
|
47
47
|
# == Deals
|
48
|
-
#
|
49
|
-
# You can access your deals by calling
|
50
|
-
#
|
51
|
-
#
|
48
|
+
#
|
49
|
+
# You can access your deals by calling
|
50
|
+
#
|
51
|
+
#
|
52
52
|
# @session.deals
|
53
|
-
#
|
54
|
-
#
|
53
|
+
#
|
54
|
+
#
|
55
55
|
# With Deals you get access to Notes, Reminders and Deal Contacts.
|
56
|
-
#
|
56
|
+
#
|
57
57
|
# For more information, consult the Deals page.
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# == Clients
|
60
|
-
#
|
61
|
-
# You can access your clients by calling
|
62
|
-
#
|
63
|
-
#
|
60
|
+
#
|
61
|
+
# You can access your clients by calling
|
62
|
+
#
|
63
|
+
#
|
64
64
|
# @session.clients
|
65
|
-
#
|
66
|
-
#
|
65
|
+
#
|
66
|
+
#
|
67
67
|
# For more information, consult the Clients page.
|
68
|
-
#
|
68
|
+
#
|
69
69
|
# == Contacts
|
70
|
-
#
|
71
|
-
# You can access your contacts by calling
|
72
|
-
#
|
73
|
-
#
|
70
|
+
#
|
71
|
+
# You can access your contacts by calling
|
72
|
+
#
|
73
|
+
#
|
74
74
|
# @session.contacts
|
75
|
-
#
|
76
|
-
#
|
75
|
+
#
|
76
|
+
#
|
77
77
|
# For more information, consult the Contacts page.
|
78
|
-
#
|
78
|
+
#
|
79
79
|
# == Sources
|
80
|
-
#
|
81
|
-
# You can access your sources by calling
|
82
|
-
#
|
83
|
-
#
|
80
|
+
#
|
81
|
+
# You can access your sources by calling
|
82
|
+
#
|
83
|
+
#
|
84
84
|
# @session.sources
|
85
|
-
#
|
86
|
-
#
|
85
|
+
#
|
86
|
+
#
|
87
87
|
# For more information, consult the Sources page.
|
88
|
-
#
|
88
|
+
#
|
89
89
|
class Session
|
90
|
-
|
91
|
-
attr_accessor :token
|
92
|
-
|
93
|
-
def initialize(params, &block)
|
90
|
+
|
91
|
+
attr_accessor :token, :version
|
92
|
+
|
93
|
+
def initialize(params, &block)
|
94
94
|
if endpoint = params.delete("endpoint") or endpoint = params.delete(:endpoint)
|
95
95
|
connection(endpoint)
|
96
96
|
end
|
97
|
+
|
98
|
+
if version = params.delete('version') or version = params.delete(:version)
|
99
|
+
self.version = "v#{version}"
|
100
|
+
end
|
97
101
|
# If user supplies token, do not connect for authentication
|
98
102
|
if token = params.delete('token') or token = params.delete(:token)
|
99
103
|
self.token = token
|
@@ -102,18 +106,26 @@ module Pipejump
|
|
102
106
|
end
|
103
107
|
yield(self) if block_given?
|
104
108
|
end
|
105
|
-
|
109
|
+
|
110
|
+
def version_prefix(url)
|
111
|
+
if self.version and !url.match(/^\/api\/#{self.version}/)
|
112
|
+
"/api/#{self.version}#{url}"
|
113
|
+
else
|
114
|
+
url
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
106
118
|
def authenticate(params) #:nodoc:
|
107
|
-
response = connection.post('/authentication', params.collect { |pair| pair.join('=') }.join('&'))
|
119
|
+
response = connection.post(version_prefix('/authentication.json'), params.collect { |pair| pair.join('=') }.join('&'))
|
108
120
|
data = JSON.parse(response.body)
|
109
121
|
self.token = data['authentication']['token']
|
110
122
|
raise AuthenticationFailed if response.code == '401'
|
111
123
|
end
|
112
|
-
|
124
|
+
|
113
125
|
def connection(endpoint = nil) #:nodoc:
|
114
126
|
@connection ||= Connection.new(self, endpoint)
|
115
127
|
end
|
116
|
-
|
128
|
+
|
117
129
|
def get(url) #:nodoc:
|
118
130
|
response = connection.get(url)
|
119
131
|
data = (response.code.to_i == 200 and url.match('.json')) ? JSON.parse(response.body) : ''
|
@@ -131,22 +143,22 @@ module Pipejump
|
|
131
143
|
data = url.match('.json') ? JSON.parse(response.body) : response.body
|
132
144
|
[response.code.to_i, data]
|
133
145
|
end
|
134
|
-
|
146
|
+
|
135
147
|
def delete(url) #:nodoc:
|
136
148
|
response = connection.delete(url)
|
137
149
|
[response.code.to_i, response.body]
|
138
150
|
end
|
139
|
-
|
151
|
+
|
140
152
|
def inspect
|
141
153
|
"#<#{self.class} token: \"#{token}\">"
|
142
154
|
end
|
143
|
-
|
155
|
+
|
144
156
|
# Returns a Pipejump::Account instance of the current account
|
145
157
|
def account
|
146
|
-
code, response = get('/account.json')
|
158
|
+
code, response = get(version_prefix('/account.json'))
|
147
159
|
Account.new(response['account'])
|
148
160
|
end
|
149
|
-
|
161
|
+
|
150
162
|
# Returns a Pipejump::Collection instance of Clients
|
151
163
|
def clients
|
152
164
|
Collection.new(self, Client)
|
@@ -167,6 +179,6 @@ module Pipejump
|
|
167
179
|
Collection.new(self, Deal)
|
168
180
|
end
|
169
181
|
|
170
|
-
|
182
|
+
|
171
183
|
end
|
172
184
|
end
|
@@ -1,225 +1,235 @@
|
|
1
1
|
module Pipejump
|
2
|
-
|
2
|
+
|
3
3
|
# A Contact is represented by an instance of Pipejump::Contact.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# *Note*: To access any contacts, you need a valid Session instance, referred to as @session in the following examples.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# == Access
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# === Collection
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# To fetch a collection of Pipejump::Contact instances, call
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @session.contacts
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# @session.contacts
|
15
15
|
# # => #<Pipejump::Collection recontact: Pipejump::Contact>
|
16
|
-
#
|
17
|
-
#
|
16
|
+
#
|
17
|
+
#
|
18
18
|
# This returns a Pipejump::Collection instance. To retrieve an array of Pipejump::Contact instances, call the _all_ method on the collection:
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# @session.contacts.all
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# @session.contacts.all
|
22
22
|
# # => [#<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">, #<Pipejump::Contact name: "Mike", id: "2", mobile: "321", phone: "654", email: "mike@email.com">]
|
23
|
-
#
|
24
|
-
#
|
23
|
+
#
|
24
|
+
#
|
25
25
|
# Instead of _all_, you can also call a variety of Array methods in the collection which will be delegated to the array returned by _all_, such as:
|
26
|
-
#
|
26
|
+
#
|
27
27
|
# * first
|
28
28
|
# * last
|
29
29
|
# * each
|
30
30
|
# * size
|
31
31
|
# * collect
|
32
32
|
# * reject
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# *Examples*:
|
35
|
-
#
|
36
|
-
# @session.contacts.first
|
35
|
+
#
|
36
|
+
# @session.contacts.first
|
37
37
|
# # => #<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">
|
38
|
-
# @session.contacts.last
|
38
|
+
# @session.contacts.last
|
39
39
|
# # => #<Pipejump::Contact name: "Mike", id: "2", mobile: "321", phone: "654", email: "mike@email.com">
|
40
40
|
# @session.contacts.size
|
41
41
|
# # => 2
|
42
|
-
# @session.contacts.each { |contact| puts contact.name }
|
42
|
+
# @session.contacts.each { |contact| puts contact.name }
|
43
43
|
# # Prints out "Tom" and "Mike"
|
44
|
-
# @session.contacts.collect { |contact| contact.name }
|
44
|
+
# @session.contacts.collect { |contact| contact.name }
|
45
45
|
# # => ["Tom", "Mike"]
|
46
|
-
# @session.contacts.reject { |contact| contact.name == 'Tom' }
|
46
|
+
# @session.contacts.reject { |contact| contact.name == 'Tom' }
|
47
47
|
# # => ["Mike"]
|
48
|
-
#
|
49
|
-
#
|
48
|
+
#
|
49
|
+
#
|
50
50
|
# === Resource
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# To fetch a single contact, call the _find_ method with the contact id as an argument:
|
53
|
-
#
|
54
|
-
#
|
55
|
-
# @session.contacts.find(1)
|
53
|
+
#
|
54
|
+
#
|
55
|
+
# @session.contacts.find(1)
|
56
56
|
# # => #<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">
|
57
|
-
#
|
58
|
-
#
|
57
|
+
#
|
58
|
+
#
|
59
59
|
# == Creation
|
60
|
-
#
|
60
|
+
#
|
61
61
|
# *Note*: Contacts require the following fields in the hash of attributes:
|
62
|
-
#
|
62
|
+
#
|
63
63
|
# * _name_: a valid name
|
64
|
-
# * _client_id_: a valid a Client| id
|
65
|
-
#
|
66
|
-
# To create a new contact, call the _create_ method on the Contact Pipejump::Collection with a hash of attributes as an argument.
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
64
|
+
# * _client_id_: a valid a Client| id
|
65
|
+
#
|
66
|
+
# To create a new contact, call the _create_ method on the Contact Pipejump::Collection with a hash of attributes as an argument.
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
70
70
|
# # => #<Pipejump::Contact name: "Jerry", id: "3", mobile: "", client_id: "1", phone: "", email: "">
|
71
|
-
#
|
72
|
-
#
|
71
|
+
#
|
72
|
+
#
|
73
73
|
# If the contact was created properly, it will be returned with a id assigned to it. You can check it by calling the created? method
|
74
|
-
#
|
75
|
-
#
|
76
|
-
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
74
|
+
#
|
75
|
+
#
|
76
|
+
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
77
77
|
# # => #<Pipejump::Contact name: "Jerry", id: "3", mobile: "", client_id: "1", phone: "", email: "">
|
78
|
-
# contact.created?
|
78
|
+
# contact.created?
|
79
79
|
# # => true
|
80
|
-
# contact = @session.contacts.create(:name => '')
|
80
|
+
# contact = @session.contacts.create(:name => '')
|
81
81
|
# # => #<Pipejump::Contact name: "">
|
82
|
-
# contact.created?
|
82
|
+
# contact.created?
|
83
83
|
# # => false
|
84
|
-
#
|
85
|
-
#
|
84
|
+
#
|
85
|
+
#
|
86
86
|
# You can access validation/creation errors by calling the _errors_ method on the instance returned by _create_:
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# contact = @session.contacts.create(:name => '')
|
87
|
+
#
|
88
|
+
#
|
89
|
+
# contact = @session.contacts.create(:name => '')
|
90
90
|
# # => #<Pipejump::Contact name: "">
|
91
|
-
# contact.created?
|
91
|
+
# contact.created?
|
92
92
|
# # => false
|
93
|
-
# contact.errors
|
93
|
+
# contact.errors
|
94
94
|
# # => "contact"=>[{"error"=>{"code"=>"E0001", "field"=>"name", "description"=>"Well... we need a name."}}, {"error"=>{"code"=>"E0001", "field"=>"client", "description"=>"can't be blank"}}]}
|
95
|
-
#
|
96
|
-
#
|
95
|
+
#
|
96
|
+
#
|
97
97
|
# == Update
|
98
|
-
#
|
98
|
+
#
|
99
99
|
# To update a contact, change the attributes and call the _save_ method.
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# === Changing attributes
|
102
|
-
#
|
102
|
+
#
|
103
103
|
# Each attribute has an accessor which you can use to change the values:
|
104
|
-
#
|
105
|
-
#
|
106
|
-
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
104
|
+
#
|
105
|
+
#
|
106
|
+
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
107
107
|
# # => #<Pipejump::Contact name: "Jerry", id: "3", mobile: "", client_id: "1", phone: "", email: "">
|
108
|
-
# contact.name
|
108
|
+
# contact.name
|
109
109
|
# # => 'Jerry'
|
110
|
-
# contact.name = 'Wally'
|
110
|
+
# contact.name = 'Wally'
|
111
111
|
# # => 'Wally'
|
112
|
-
# contact.name
|
112
|
+
# contact.name
|
113
113
|
# # => 'Wally'
|
114
|
-
#
|
115
|
-
#
|
114
|
+
#
|
115
|
+
#
|
116
116
|
# === Saving
|
117
|
-
#
|
117
|
+
#
|
118
118
|
# Once you've changed the attributes, call the _save_ method on the contact instance:
|
119
|
-
#
|
120
|
-
#
|
121
|
-
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
119
|
+
#
|
120
|
+
#
|
121
|
+
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
122
122
|
# # => #<Pipejump::Contact name: "Jerry", id: "3", mobile: "", client_id: "1", phone: "", email: "">
|
123
|
-
# contact.name = 'Wally'
|
123
|
+
# contact.name = 'Wally'
|
124
124
|
# # => 'Wally'
|
125
125
|
# contact.save
|
126
126
|
# # => true
|
127
|
-
#
|
128
|
-
#
|
127
|
+
#
|
128
|
+
#
|
129
129
|
# _save_ returns _true_ if save was successful and _false_ if it failed. In the latter scenario, you can access the errors via the _errors_ method:
|
130
|
-
#
|
131
|
-
#
|
132
|
-
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
130
|
+
#
|
131
|
+
#
|
132
|
+
# contact = @session.contacts.create(:name => 'Jerry', :client_id => 1)
|
133
133
|
# # => #<Pipejump::Contact name: "Jerry", id: "3", mobile: "", client_id: "1", phone: "", email: "">
|
134
134
|
# contact.name = 'Wally'
|
135
135
|
# # => 'Wally'
|
136
|
-
# contact.save
|
136
|
+
# contact.save
|
137
137
|
# # => true
|
138
|
-
# contact.name = ''
|
138
|
+
# contact.name = ''
|
139
139
|
# # => ''
|
140
|
-
# contact.save
|
140
|
+
# contact.save
|
141
141
|
# # => false
|
142
|
-
# contact.errors
|
142
|
+
# contact.errors
|
143
143
|
# # => "contact"=>[{"error"=>{"code"=>"E0001", "field"=>"name", "description"=>"Well... we need a name."}}, {"error"=>{"code"=>"E0001", "field"=>"client", "description"=>"can't be blank"}}]}
|
144
|
-
#
|
145
|
-
#
|
144
|
+
#
|
145
|
+
#
|
146
146
|
# == Removal
|
147
|
-
#
|
147
|
+
#
|
148
148
|
# To remove a contact, call the _destroy_ method on the instance:
|
149
|
-
#
|
150
|
-
#
|
151
|
-
# contact = @session.contacts.find(1)
|
149
|
+
#
|
150
|
+
#
|
151
|
+
# contact = @session.contacts.find(1)
|
152
152
|
# # => #<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">
|
153
|
-
# contact.destroy
|
153
|
+
# contact.destroy
|
154
154
|
# # => true
|
155
|
-
#
|
155
|
+
#
|
156
156
|
#
|
157
157
|
# = Contacts within a Deal
|
158
|
-
#
|
158
|
+
#
|
159
159
|
# A Contact is represented by an instance of Pipejump::Contact. Deal Contacts, however, can only be accessed from a specific deal.
|
160
160
|
#
|
161
161
|
# *Note*: To access any Deal Contacts, you need a valid Deal| instance, referred to as @deal in the following examples. Deal Contacts belong to a deal, so you can only access them via @deal, not the session.
|
162
|
-
#
|
162
|
+
#
|
163
163
|
# == Access
|
164
|
-
#
|
164
|
+
#
|
165
165
|
# === Collection
|
166
|
-
#
|
166
|
+
#
|
167
167
|
# To fetch a collection of Pipejump::Contact instances belonging to a specific Deal, call
|
168
|
-
#
|
169
|
-
#
|
170
|
-
# @deal.contacts
|
168
|
+
#
|
169
|
+
#
|
170
|
+
# @deal.contacts
|
171
171
|
# # => #<Pipejump::Collection resource: Pipejump::Contact, owner: #<Pipejump::Deal name: "My Deal", scope: "0", hot: "false", stage_name: "incoming", id: "1", deal_tags: "">>
|
172
|
-
#
|
173
|
-
#
|
172
|
+
#
|
173
|
+
#
|
174
174
|
# This returns a Pipejump::Collection instance. To retrieve an array of Pipejump::Contact instances belonging to a specific Deal, call the _all_ method on the collection:
|
175
|
-
#
|
176
|
-
#
|
177
|
-
# @deal.contacts.all
|
178
|
-
# # => [#<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">,
|
175
|
+
#
|
176
|
+
#
|
177
|
+
# @deal.contacts.all
|
178
|
+
# # => [#<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">,
|
179
179
|
# # #<Pipejump::Contact name: "Mike", id: "2", mobile: "321", phone: "654", email: "mike@email.com">]
|
180
|
-
#
|
181
|
-
#
|
180
|
+
#
|
181
|
+
#
|
182
182
|
# Instead of _all_, you can also call a variety of Array methods in the collection which will be delegated to the array returned by _all_, such as:
|
183
|
-
#
|
183
|
+
#
|
184
184
|
# * first
|
185
185
|
# * last
|
186
186
|
# * each
|
187
187
|
# * size
|
188
188
|
# * collect
|
189
189
|
# * reject
|
190
|
-
#
|
190
|
+
#
|
191
191
|
# *Examples*:
|
192
|
-
#
|
193
|
-
# @deal.contacts.first
|
192
|
+
#
|
193
|
+
# @deal.contacts.first
|
194
194
|
# # => #<Pipejump::Contact name: "Tom", id: "1", mobile: "123", phone: "456", email: "tom@email.com">
|
195
|
-
# @deal.contacts.last
|
195
|
+
# @deal.contacts.last
|
196
196
|
# # => #<Pipejump::Contact name: "Mike", id: "2", mobile: "321", phone: "654", email: "mike@email.com">
|
197
197
|
# @deal.contacts.size
|
198
198
|
# # => 2
|
199
|
-
# @deal.contacts.each { |contact| puts contact.name }
|
199
|
+
# @deal.contacts.each { |contact| puts contact.name }
|
200
200
|
# # Prints out "Tom" and "Mike"
|
201
|
-
# @deal.contacts.collect { |contact| contact.name }
|
201
|
+
# @deal.contacts.collect { |contact| contact.name }
|
202
202
|
# # => ["Tom", "Mike"]
|
203
|
-
# @deal.contacts.reject { |contact| contact.name == 'Tom' }
|
203
|
+
# @deal.contacts.reject { |contact| contact.name == 'Tom' }
|
204
204
|
# # => ["Mike"]
|
205
|
-
#
|
206
|
-
#
|
205
|
+
#
|
206
|
+
#
|
207
207
|
# == Updating
|
208
|
-
#
|
208
|
+
#
|
209
209
|
# To update the Contacts that are assigned to a Deal|, call the _update_ method on the Contacts collection:
|
210
|
-
#
|
211
|
-
#
|
210
|
+
#
|
211
|
+
#
|
212
212
|
# @deal.contacts.collect(&:id)
|
213
213
|
# # => ['1', '2', '3']
|
214
214
|
# @deal.contacts.update('1,2')
|
215
215
|
# # => true
|
216
216
|
# @deal.contacts.collect(&:id)
|
217
217
|
# # => ['1', '2']
|
218
|
-
#
|
219
|
-
#
|
218
|
+
#
|
219
|
+
#
|
220
220
|
# *Note*: The Contacts must have the same Client as the Deal or update will return _false_
|
221
221
|
class Contact < Resource
|
222
|
-
belongs_to :
|
222
|
+
belongs_to :organisation, :class_name => 'Contact'
|
223
|
+
|
224
|
+
has_many :notes
|
225
|
+
has_many :reminders
|
226
|
+
|
227
|
+
def before_save
|
228
|
+
@attributes.delete('organisation')
|
229
|
+
@attributes.delete('linkedin_display')
|
230
|
+
@attributes.delete('tags_joined_by_comma')
|
231
|
+
end
|
232
|
+
|
223
233
|
end
|
224
|
-
|
234
|
+
|
225
235
|
end
|