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,213 +1,213 @@
|
|
1
1
|
module Pipejump
|
2
|
-
|
2
|
+
|
3
3
|
# A Deal is represented by an instance of Pipejump::Deal.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# *Note*: To access any deals, 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::Deal instances, call
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @session.deals
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# @session.deals
|
15
15
|
# # => #<Pipejump::Collection resource: Pipejump::Deal>
|
16
|
-
#
|
17
|
-
#
|
16
|
+
#
|
17
|
+
#
|
18
18
|
# This returns a Pipejump::Collection instance. To retrieve an array of Pipejump::Deal instances, call the _all_ method on the collection:
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# @session.deals.all
|
22
|
-
# # => [#<Pipejump::Deal name: "Good Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "1">,
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# @session.deals.all
|
22
|
+
# # => [#<Pipejump::Deal name: "Good Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "1">,
|
23
23
|
# # #<Pipejump::Deal name: "Ok Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "2">]
|
24
|
-
#
|
25
|
-
#
|
24
|
+
#
|
25
|
+
#
|
26
26
|
# 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:
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# * first
|
29
29
|
# * last
|
30
30
|
# * each
|
31
31
|
# * size
|
32
32
|
# * collect
|
33
33
|
# * reject
|
34
|
-
#
|
34
|
+
#
|
35
35
|
# *Examples*:
|
36
|
-
#
|
37
|
-
# @session.deals.first
|
36
|
+
#
|
37
|
+
# @session.deals.first
|
38
38
|
# # => #<Pipejump::Deal name: "Good Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "1">
|
39
|
-
# @session.deals.last
|
39
|
+
# @session.deals.last
|
40
40
|
# # => #<Pipejump::Deal name: "Ok Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "2">
|
41
41
|
# @session.deals.size
|
42
42
|
# # => 2
|
43
|
-
# @session.deals.each { |deal| puts deal.name }
|
43
|
+
# @session.deals.each { |deal| puts deal.name }
|
44
44
|
# # Prints out "Good Deal" and "Ok Deal"
|
45
|
-
# @session.deals.collect { |deal| deal.name }
|
45
|
+
# @session.deals.collect { |deal| deal.name }
|
46
46
|
# # => ["Good Deal", "Ok Deal"]
|
47
|
-
# @session.deals.reject { |deal| deal.name == 'Good Deal' }
|
47
|
+
# @session.deals.reject { |deal| deal.name == 'Good Deal' }
|
48
48
|
# # => ["Ok Deal"]
|
49
|
-
#
|
50
|
-
#
|
49
|
+
#
|
50
|
+
#
|
51
51
|
# === Resource
|
52
|
-
#
|
52
|
+
#
|
53
53
|
# To fetch a single deal, call the _find_ method with the deal id as an argument:
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# @session.deals.find(1)
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# @session.deals.find(1)
|
57
57
|
# # => #<Pipejump::Deal name: "Good Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "1">
|
58
|
-
#
|
59
|
-
#
|
58
|
+
#
|
59
|
+
#
|
60
60
|
# == Creation
|
61
|
-
#
|
61
|
+
#
|
62
62
|
# *Note*: Deals require the following fields in the hash of attributes:
|
63
|
-
#
|
63
|
+
#
|
64
64
|
# * _name_: a valid name
|
65
|
-
# * _client_id_: a valid a Client id
|
66
|
-
#
|
67
|
-
# To create a new deal, call the _create_ method on the Deal Pipejump::Collection with a hash of attributes as an argument.
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
65
|
+
# * _client_id_: a valid a Client id
|
66
|
+
#
|
67
|
+
# To create a new deal, call the _create_ method on the Deal Pipejump::Collection with a hash of attributes as an argument.
|
68
|
+
#
|
69
|
+
#
|
70
|
+
# @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
71
71
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
72
|
-
#
|
73
|
-
#
|
72
|
+
#
|
73
|
+
#
|
74
74
|
# If the deal was created properly, it will be returned with a id assigned to it. You can check it by calling the created? method
|
75
|
-
#
|
76
|
-
#
|
77
|
-
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
75
|
+
#
|
76
|
+
#
|
77
|
+
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
78
78
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
79
|
-
# deal.created?
|
79
|
+
# deal.created?
|
80
80
|
# # => true
|
81
|
-
# deal = @session.deals.create(:name => '')
|
81
|
+
# deal = @session.deals.create(:name => '')
|
82
82
|
# # => #<Pipejump::Deal name: "">
|
83
|
-
# deal.created?
|
83
|
+
# deal.created?
|
84
84
|
# # => false
|
85
|
-
#
|
86
|
-
#
|
85
|
+
#
|
86
|
+
#
|
87
87
|
# You can access validation/creation errors by calling the _errors_ method on the instance returned by _create_:
|
88
|
-
#
|
89
|
-
#
|
90
|
-
# deal = @session.deals.create(:name => '')
|
88
|
+
#
|
89
|
+
#
|
90
|
+
# deal = @session.deals.create(:name => '')
|
91
91
|
# # => #<Pipejump::Deal name: "">
|
92
|
-
# deal.created?
|
92
|
+
# deal.created?
|
93
93
|
# # => false
|
94
|
-
# deal.errors
|
95
|
-
# # => {"deal"=>[{"error"=>{"code"=>"E0001", "field"=>"name", "description"=>"Please enter a deal name"}},
|
94
|
+
# deal.errors
|
95
|
+
# # => {"deal"=>[{"error"=>{"code"=>"E0001", "field"=>"name", "description"=>"Please enter a deal name"}},
|
96
96
|
# # {"error"=>{"code"=>"E0001", "field"=>"client", "description"=>"Please enter a valid client id"}}]}
|
97
|
-
#
|
98
|
-
#
|
97
|
+
#
|
98
|
+
#
|
99
99
|
# == Update
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# To update a deal, change the attributes and call the _save_ method.
|
102
|
-
#
|
102
|
+
#
|
103
103
|
# === Changing attributes
|
104
|
-
#
|
104
|
+
#
|
105
105
|
# Each attribute has an accessor which you can use to change the values:
|
106
|
-
#
|
107
|
-
#
|
108
|
-
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
106
|
+
#
|
107
|
+
#
|
108
|
+
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
109
109
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
110
|
-
# deal.name
|
110
|
+
# deal.name
|
111
111
|
# # => 'Great Deal'
|
112
|
-
# deal.name = 'Super Deal'
|
112
|
+
# deal.name = 'Super Deal'
|
113
113
|
# # => 'Super Deal'
|
114
|
-
# deal.name
|
114
|
+
# deal.name
|
115
115
|
# # => 'Super Deal'
|
116
|
-
#
|
117
|
-
#
|
116
|
+
#
|
117
|
+
#
|
118
118
|
# === Saving
|
119
|
-
#
|
119
|
+
#
|
120
120
|
# Once you've changed the attributes, call the _save_ method on the deal instance:
|
121
|
-
#
|
122
|
-
#
|
123
|
-
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
121
|
+
#
|
122
|
+
#
|
123
|
+
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
124
124
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
125
|
-
# deal.name = 'Super Deal'
|
125
|
+
# deal.name = 'Super Deal'
|
126
126
|
# # => 'Super Deal'
|
127
127
|
# deal.save
|
128
128
|
# # => true
|
129
|
-
#
|
130
|
-
#
|
129
|
+
#
|
130
|
+
#
|
131
131
|
# _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:
|
132
|
-
#
|
133
|
-
#
|
134
|
-
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
132
|
+
#
|
133
|
+
#
|
134
|
+
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
135
135
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
136
136
|
# deal.name = 'Super Deal'
|
137
137
|
# # => 'Super Deal'
|
138
|
-
# deal.save
|
138
|
+
# deal.save
|
139
139
|
# # => true
|
140
|
-
# deal.name = ''
|
140
|
+
# deal.name = ''
|
141
141
|
# # => ''
|
142
|
-
# deal.save
|
142
|
+
# deal.save
|
143
143
|
# # => false
|
144
|
-
# deal.errors
|
144
|
+
# deal.errors
|
145
145
|
# # => {"deal"=>[{"error"=>{"code"=>"E0001", "field"=>"name", "description"=>"Please enter a deal name"}} ]}
|
146
|
-
#
|
147
|
-
#
|
146
|
+
#
|
147
|
+
#
|
148
148
|
# == Removal
|
149
|
-
#
|
149
|
+
#
|
150
150
|
# You cannot remove a deal, you can move it between stages
|
151
|
-
#
|
151
|
+
#
|
152
152
|
# == Changing stages
|
153
|
-
#
|
153
|
+
#
|
154
154
|
# To change a Deal stage, change the value of the _stage_name_ attribute to one of the following:
|
155
|
-
#
|
155
|
+
#
|
156
156
|
# * incoming
|
157
157
|
# * qualified
|
158
158
|
# * quote
|
159
159
|
# * closure
|
160
160
|
# * won
|
161
161
|
# * lost
|
162
|
-
# * unqualified
|
163
|
-
#
|
162
|
+
# * unqualified
|
163
|
+
#
|
164
164
|
# Afterwards, save the deal to update the Deal stage.
|
165
|
-
#
|
166
|
-
#
|
167
|
-
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
165
|
+
#
|
166
|
+
#
|
167
|
+
# deal = @session.deals.create(:name => 'Great Deal', :client_id => 1)
|
168
168
|
# # => #<Pipejump::Deal name: "Great Deal", scope: "0", hot: "false", stage_name: "incoming", deal_tags: "", id: "3">
|
169
169
|
# deal.stage_name = 'qualified'
|
170
170
|
# # => 'qualified'
|
171
171
|
# deal.save
|
172
172
|
# # => true
|
173
|
-
#
|
174
|
-
#
|
173
|
+
#
|
174
|
+
#
|
175
175
|
# == Contacts
|
176
|
-
#
|
176
|
+
#
|
177
177
|
# You can access Deal Contacts assigned to a deal by calling _contacts_ on an instance of a Deal:
|
178
|
-
#
|
179
|
-
#
|
178
|
+
#
|
179
|
+
#
|
180
180
|
# @deal.contacts
|
181
|
-
#
|
182
|
-
#
|
181
|
+
#
|
182
|
+
#
|
183
183
|
# For more information, consult the Deal Contacts page.
|
184
|
-
#
|
184
|
+
#
|
185
185
|
# == Notes
|
186
|
-
#
|
186
|
+
#
|
187
187
|
# You can access Notes of a specific deal by calling _notes_ on an instance of a Deal:
|
188
|
-
#
|
189
|
-
#
|
188
|
+
#
|
189
|
+
#
|
190
190
|
# @deal.notes
|
191
|
-
#
|
192
|
-
#
|
191
|
+
#
|
192
|
+
#
|
193
193
|
# For more information, consult the Notes page.
|
194
|
-
#
|
194
|
+
#
|
195
195
|
# == Reminders
|
196
|
-
#
|
196
|
+
#
|
197
197
|
# You can access Reminders of a specific deal by calling _reminders_ on an instance of a Deal:
|
198
|
-
#
|
199
|
-
#
|
198
|
+
#
|
199
|
+
#
|
200
200
|
# @deal.reminders
|
201
|
-
#
|
202
|
-
#
|
201
|
+
#
|
202
|
+
#
|
203
203
|
# For more information, consult the Reminders page.
|
204
|
-
class Deal < Resource
|
205
|
-
belongs_to :
|
204
|
+
class Deal < Resource
|
205
|
+
belongs_to :entity, :class_name => 'Contact'
|
206
206
|
has_many :contacts do
|
207
207
|
disable :find, :create
|
208
208
|
|
209
209
|
# Updates the Contact resources assigned to a deal
|
210
|
-
#
|
210
|
+
#
|
211
211
|
# Accepts the following arguments:
|
212
212
|
# * String:
|
213
213
|
# @deal.contacts.update('1, 2')
|
@@ -219,8 +219,8 @@ module Pipejump
|
|
219
219
|
# @deal.contacts.update([1, @contact2])
|
220
220
|
def update(ids) #:nodoc:
|
221
221
|
if ids.is_a?(Array)
|
222
|
-
ids = ids.collect { |element|
|
223
|
-
if element.is_a?(Pipejump::Resource)
|
222
|
+
ids = ids.collect { |element|
|
223
|
+
if element.is_a?(Pipejump::Resource)
|
224
224
|
element.id
|
225
225
|
elsif element.is_a?(Fixnum)
|
226
226
|
element
|
@@ -233,14 +233,14 @@ module Pipejump
|
|
233
233
|
end
|
234
234
|
|
235
235
|
end
|
236
|
-
|
236
|
+
|
237
237
|
has_many :notes
|
238
238
|
has_many :reminders
|
239
|
-
|
239
|
+
|
240
240
|
def to_query #:nodoc:
|
241
241
|
@attributes.collect { |pair| pair[0] = "#{pair[0]}"; pair.join('=') }.join('&')
|
242
242
|
end
|
243
|
-
|
243
|
+
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
end
|
@@ -1,171 +1,174 @@
|
|
1
1
|
module Pipejump
|
2
|
-
|
2
|
+
|
3
3
|
# The Reminders resource is represented by an instance of Pipejump::Reminder.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# *Reminder*: To access any Reminders, you need a valid Deal instance, referred to as @deal in the following examples. Reminders belong to a deal, so you can only access them via @deal, not the session.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# == Access
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# === Collection
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# To fetch a collection of Pipejump::Reminder instances, call
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @deal.reminders
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# @deal.reminders
|
15
15
|
# # => #<Pipejump::Collection resource: Pipejump::Reminder, owner: #<Pipejump::Deal name: "My Deal", scope: "0", hot: "false", stage_name: "incoming", id: "1", deal_tags: "">>
|
16
|
-
#
|
17
|
-
#
|
16
|
+
#
|
17
|
+
#
|
18
18
|
# This returns a Pipejump::Collection instance. To retrieve an array of Pipejump::Reminder instances, call the _all_ method on the collection:
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# @deal.reminders.all
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# @deal.reminders.all
|
22
22
|
# # => [#<Pipejump::Reminder done: "false", time: "14:00", id: "1", date: "2010-11-11", content: "My Reminder">,
|
23
23
|
# # #<Pipejump::Reminder done: "false", time: "16:00", id: "2", date: "2010-11-11", content: "Another Reminder">]
|
24
|
-
#
|
25
|
-
#
|
24
|
+
#
|
25
|
+
#
|
26
26
|
# 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:
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# * first
|
29
29
|
# * last
|
30
30
|
# * each
|
31
31
|
# * size
|
32
32
|
# * collect
|
33
33
|
# * reject
|
34
|
-
#
|
34
|
+
#
|
35
35
|
# *Examples*:
|
36
|
-
#
|
37
|
-
# @deal.reminders.first
|
36
|
+
#
|
37
|
+
# @deal.reminders.first
|
38
38
|
# # => #<Pipejump::Reminder done: "false", time: "14:00", id: "1", date: "2010-11-11", content: "My Reminder">
|
39
|
-
# @deal.reminders.last
|
39
|
+
# @deal.reminders.last
|
40
40
|
# # => #<Pipejump::Reminder done: "false", time: "16:00", id: "2", date: "2010-11-11", content: "Another Reminder">
|
41
41
|
# @deal.reminders.size
|
42
42
|
# # => 2
|
43
|
-
# @deal.reminders.each { |reminder| puts reminder.content }
|
43
|
+
# @deal.reminders.each { |reminder| puts reminder.content }
|
44
44
|
# # Prints out "My Reminder" and "Another Reminder"
|
45
|
-
# @deal.reminders.collect { |reminder| reminder.content }
|
45
|
+
# @deal.reminders.collect { |reminder| reminder.content }
|
46
46
|
# # => ["My Reminder", "Another Reminder"]
|
47
|
-
# @deal.reminders.reject { |reminder| reminder.content == 'My Reminder' }
|
47
|
+
# @deal.reminders.reject { |reminder| reminder.content == 'My Reminder' }
|
48
48
|
# # => ["Another Reminder"]
|
49
|
-
#
|
50
|
-
#
|
49
|
+
#
|
50
|
+
#
|
51
51
|
# === Resource
|
52
|
-
#
|
52
|
+
#
|
53
53
|
# To fetch a single resource, call the _find_ method with the resource id as an argument:
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# @deal.reminders.find(1)
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# @deal.reminders.find(1)
|
57
57
|
# # => #<Pipejump::Reminder done: "false", time: "14:00", id: "1", date: "2010-11-11", content: "My Reminder">
|
58
|
-
#
|
59
|
-
#
|
58
|
+
#
|
59
|
+
#
|
60
60
|
# == Creation
|
61
|
-
#
|
61
|
+
#
|
62
62
|
# *Reminder*: Reminders require the following fields in the hash of attributes:
|
63
|
-
#
|
63
|
+
#
|
64
64
|
# * _content_: Reminder content
|
65
65
|
# * _date_: Date for the Reminder (ex. 2010-11-11)
|
66
66
|
# * _time_: Time for the Reminder (ex. 14:00)
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# To create a new reminder, call the _create_ method on the Reminder Pipejump::Collection with a hash of attributes as an argument:
|
69
|
-
#
|
70
|
-
#
|
71
|
-
# @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
72
72
|
# # => #<Pipejump::Reminder done: "false", time: "19:00", id: "3", date: "2010-11-11", content: "Third Reminder">
|
73
|
-
#
|
74
|
-
#
|
73
|
+
#
|
74
|
+
#
|
75
75
|
# If the resource was created properly, it will be returned with a id assigned to it. You can check it by calling the created? method
|
76
|
-
#
|
77
|
-
#
|
78
|
-
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
76
|
+
#
|
77
|
+
#
|
78
|
+
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
79
79
|
# # => #<Pipejump::Reminder done: "false", time: "19:00", id: "3", date: "2010-11-11", content: "Third Reminder">
|
80
|
-
# reminder.created?
|
80
|
+
# reminder.created?
|
81
81
|
# # => true
|
82
|
-
# reminder = @deal.reminders.create(:content => '')
|
82
|
+
# reminder = @deal.reminders.create(:content => '')
|
83
83
|
# # => #<Pipejump::Reminder content: "">
|
84
|
-
# reminder.created?
|
84
|
+
# reminder.created?
|
85
85
|
# # => false
|
86
|
-
#
|
87
|
-
#
|
86
|
+
#
|
87
|
+
#
|
88
88
|
# You can access validation/creation errors by calling the _errors_ method on the instance returned by _create_:
|
89
|
-
#
|
90
|
-
#
|
91
|
-
# reminder = @deal.reminders.create(:content => '')
|
89
|
+
#
|
90
|
+
#
|
91
|
+
# reminder = @deal.reminders.create(:content => '')
|
92
92
|
# # => #<Pipejump::Reminder content: "">
|
93
|
-
# reminder.created?
|
93
|
+
# reminder.created?
|
94
94
|
# # => false
|
95
|
-
# reminder.errors
|
96
|
-
# # => {"reminder"=>[{"error"=>{"code"=>"E0000", "field"=>"time", "description"=>"The time and date must be in the future"}},
|
97
|
-
# # {"error"=>{"code"=>"E0001", "field"=>"date", "description"=>"The time and date must be in the future"}},
|
95
|
+
# reminder.errors
|
96
|
+
# # => {"reminder"=>[{"error"=>{"code"=>"E0000", "field"=>"time", "description"=>"The time and date must be in the future"}},
|
97
|
+
# # {"error"=>{"code"=>"E0001", "field"=>"date", "description"=>"The time and date must be in the future"}},
|
98
98
|
# # {"error"=>{"code"=>"E0001", "field"=>"content", "description"=>"can't be blank"}}]}
|
99
|
-
#
|
100
|
-
#
|
99
|
+
#
|
100
|
+
#
|
101
101
|
# == Update
|
102
|
-
#
|
102
|
+
#
|
103
103
|
# To update a resource, change the attributes and call the _save_ method.
|
104
|
-
#
|
104
|
+
#
|
105
105
|
# === Changing attributes
|
106
|
-
#
|
106
|
+
#
|
107
107
|
# Each attribute has an accessor which you can use to change the values:
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
108
|
+
#
|
109
|
+
#
|
110
|
+
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
111
111
|
# # => #<Pipejump::Reminder done: "false", time: "19:00", id: "3", date: "2010-11-11", content: "Third Reminder">
|
112
|
-
# reminder.content
|
112
|
+
# reminder.content
|
113
113
|
# # => 'Third Reminder'
|
114
|
-
# reminder.content = 'Super Reminder'
|
114
|
+
# reminder.content = 'Super Reminder'
|
115
115
|
# # => 'Super Reminder'
|
116
|
-
# reminder.content
|
116
|
+
# reminder.content
|
117
117
|
# # => 'Super Reminder'
|
118
|
-
#
|
119
|
-
#
|
118
|
+
#
|
119
|
+
#
|
120
120
|
# === Saving
|
121
|
-
#
|
121
|
+
#
|
122
122
|
# Once you've changed the attributes, call the _save_ method on the resource instance:
|
123
|
-
#
|
124
|
-
#
|
125
|
-
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
123
|
+
#
|
124
|
+
#
|
125
|
+
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
126
126
|
# # => #<Pipejump::Reminder done: "false", time: "19:00", id: "3", date: "2010-11-11", content: "Third Reminder">
|
127
|
-
# reminder.content
|
127
|
+
# reminder.content
|
128
128
|
# # => 'Third Reminder'
|
129
129
|
# reminder.save
|
130
130
|
# # => true
|
131
|
-
#
|
132
|
-
#
|
131
|
+
#
|
132
|
+
#
|
133
133
|
# _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:
|
134
|
-
#
|
135
|
-
#
|
136
|
-
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
134
|
+
#
|
135
|
+
#
|
136
|
+
# reminder = @deal.reminders.create(:content => 'Third Reminder', :date => '2010-11-11', :time => '19:00'})
|
137
137
|
# # => #<Pipejump::Reminder done: "false", time: "19:00", id: "3", date: "2010-11-11", content: "Third Reminder">
|
138
138
|
# reminder.content = 'Super Reminder'
|
139
139
|
# # => 'Super Reminder'
|
140
|
-
# reminder.save
|
140
|
+
# reminder.save
|
141
141
|
# # => true
|
142
|
-
# reminder.content = ''
|
142
|
+
# reminder.content = ''
|
143
143
|
# # => ''
|
144
|
-
# reminder.save
|
144
|
+
# reminder.save
|
145
145
|
# # => false
|
146
|
-
# reminder.errors
|
146
|
+
# reminder.errors
|
147
147
|
# # => {"reminder"=>[{"error"=>{"code"=>"E0001", "field"=>"content", "description"=>"can't be blank"}}]}
|
148
|
-
#
|
149
|
-
#
|
148
|
+
#
|
149
|
+
#
|
150
150
|
# == Removal
|
151
|
-
#
|
151
|
+
#
|
152
152
|
# To remove a resource, call the _destroy_ method on the instance:
|
153
|
-
#
|
154
|
-
#
|
155
|
-
# reminder = @deal.reminders.find(1)
|
153
|
+
#
|
154
|
+
#
|
155
|
+
# reminder = @deal.reminders.find(1)
|
156
156
|
# # => #<Pipejump::Reminder content: "My Reminder", id: "1">
|
157
|
-
# reminder.destroy
|
157
|
+
# reminder.destroy
|
158
158
|
# # => true
|
159
|
-
#
|
159
|
+
#
|
160
|
+
|
161
|
+
class Reminder < Resource
|
160
162
|
|
161
|
-
class Reminder < Resource
|
162
|
-
|
163
163
|
def before_save #:nodoc:
|
164
|
+
# Make sure this attribute is not sent
|
165
|
+
@attributes.delete('send_time_display')
|
166
|
+
@attributes.delete('related_to')
|
164
167
|
if @attributes['date'].is_a?(Time)
|
165
|
-
@attributes['date'] = @attributes['date'].strftime('%Y-%m-%d')
|
168
|
+
@attributes['date'] = @attributes['date'].strftime('%Y-%m-%d')
|
166
169
|
end
|
167
170
|
end
|
168
|
-
|
171
|
+
|
169
172
|
end
|
170
|
-
|
173
|
+
|
171
174
|
end
|
data/lib/pipejump.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'net/http'
|
3
3
|
require 'net/https'
|
4
|
-
module Pipejump #:nodoc:
|
4
|
+
module Pipejump #:nodoc:
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'pipejump/base/collection'
|
@@ -15,5 +15,4 @@ require 'pipejump/resources/deal'
|
|
15
15
|
require 'pipejump/resources/note'
|
16
16
|
require 'pipejump/resources/reminder'
|
17
17
|
require 'pipejump/resources/source'
|
18
|
-
require 'pipejump/resources/client'
|
19
18
|
require 'pipejump/resources/contact'
|
data/pipejump.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "pipejump/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "pipejump"
|
7
|
+
s.version = Pipejump::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Marcin Bunsch"]
|
10
|
+
s.email = %q{marcin@futuresimple.com}
|
11
|
+
s.homepage = "http://pipejump.com/api"
|
12
|
+
s.description = %q{Pipejump API Ruby client}
|
13
|
+
s.summary = %q{Pipejump API Ruby client}
|
14
|
+
|
15
|
+
s.rubyforge_project = "pipejump"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|