freelancer 0.1.0 → 0.1.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 +2 -0
- data/Gemfile +2 -2
- data/README.rdoc +9 -12
- data/Rakefile +55 -12
- data/VERSION +1 -1
- data/freelancer.gemspec +12 -9
- data/lib/freelancer.rb +3 -0
- data/lib/freelancer/api/common.rb +98 -0
- data/lib/freelancer/api/employer.rb +169 -0
- data/lib/freelancer/api/freelancer.rb +85 -0
- data/lib/freelancer/api/message.rb +42 -0
- data/lib/freelancer/api/payment.rb +184 -0
- data/lib/freelancer/api/profile.rb +40 -0
- data/lib/freelancer/api/project.rb +20 -0
- data/lib/freelancer/client.rb +23 -13
- data/lib/freelancer/models/project.rb +6 -0
- data/lib/freelancer/models/status_confirmation.rb +28 -0
- data/test/fixtures/error.json +1 -0
- data/test/fixtures/status_confirmation.json +1 -0
- data/test/freelancer/api/common_api_test.rb +97 -0
- data/test/freelancer/api/employer_api_test.rb +258 -0
- data/test/freelancer/api/freelancer_api_test.rb +76 -0
- data/test/freelancer/api/message_api_test.rb +44 -0
- data/test/freelancer/api/payment_api_test.rb +169 -1
- data/test/freelancer/api/profile_api_test.rb +57 -0
- data/test/freelancer/api/project_api_test.rb +19 -0
- data/test/freelancer/client_test.rb +22 -2
- metadata +15 -10
@@ -62,6 +62,9 @@ module Freelancer
|
|
62
62
|
# The maximum budget for the project
|
63
63
|
json_attribute :maximum_budget, { :budget => :max }, Integer
|
64
64
|
|
65
|
+
# Budget option
|
66
|
+
json_attribute :budget_option, :budgetoption, Integer
|
67
|
+
|
65
68
|
# The number of bids placed on the project
|
66
69
|
#
|
67
70
|
# Provided from:
|
@@ -92,6 +95,9 @@ module Freelancer
|
|
92
95
|
# The time left before the project ends
|
93
96
|
json_attribute :time_left, :timeleft, String
|
94
97
|
|
98
|
+
# The project duration
|
99
|
+
json_attribute :duration, String
|
100
|
+
|
95
101
|
# The buyer that created the project
|
96
102
|
json_attribute :buyer, User
|
97
103
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Freelancer
|
2
|
+
module Models
|
3
|
+
class StatusConfirmation
|
4
|
+
|
5
|
+
include JSONMapper
|
6
|
+
|
7
|
+
# Status confirmation value
|
8
|
+
json_attribute :success, :statusconfirmation, Boolean
|
9
|
+
|
10
|
+
def success?; return self.success; end
|
11
|
+
|
12
|
+
# Method missing method for handling additional data on a
|
13
|
+
# status confirmation transparently. This will check the JSON model
|
14
|
+
# associated with the current status confirmation and see if the
|
15
|
+
# missing method name is available as a key at the root level of the
|
16
|
+
# JSON model.
|
17
|
+
def method_missing(id, *args)
|
18
|
+
|
19
|
+
if !json_data.nil? && json_data.key?(id.to_sym)
|
20
|
+
return json_data[id.to_sym]
|
21
|
+
end
|
22
|
+
raise NoMethodError
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"errors":{"error":{"code":"5003","msg":"General Token Authorization Error","longmsg":"Operation not authorized."}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"json-result":{"statusconfirmation":1}}
|
@@ -77,6 +77,103 @@ class CommonApiTest < Test::Unit::TestCase
|
|
77
77
|
|
78
78
|
end
|
79
79
|
|
80
|
+
context "request cancel project" do
|
81
|
+
|
82
|
+
should "be able to send request" do
|
83
|
+
|
84
|
+
@freelancer.expects(:api_get).with("/Common/requestCancelProject.json", { :projectid => 1, :selectedwinner => 1, :commenttext => "Test" })
|
85
|
+
@freelancer.request_cancel_project(:project_id => 1, :selected_winner => 1, :comment => "Test")
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
should "parse response into a status confirmation model" do
|
90
|
+
|
91
|
+
stub_api_get("/Common/requestCancelProject.json", "status_confirmation.json")
|
92
|
+
status = @freelancer.request_cancel_project
|
93
|
+
status.success?.should == true
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
context "post feedback" do
|
100
|
+
|
101
|
+
should "be able to push feedback to user id" do
|
102
|
+
|
103
|
+
@freelancer.expects(:api_get).with("/Common/postFeedback.json", { :projectid => 1, :userid => 1, :feedbacktext => "Test", :rating => 5 })
|
104
|
+
@freelancer.post_feedback(:project_id => 1, :user_id => 1, :comment => "Test", :rating => 5)
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
should "be able to push feedback to username" do
|
109
|
+
|
110
|
+
@freelancer.expects(:api_get).with("/Common/postFeedback.json", { :projectid => 1, :username => "test", :feedbacktext => "Test", :rating => 5 })
|
111
|
+
@freelancer.post_feedback(:project_id => 1, :username => "test", :comment => "Test", :rating => 5)
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
should "parse response into a status confirmation model" do
|
116
|
+
|
117
|
+
stub_api_get("/Common/postFeedback.json", "status_confirmation.json")
|
118
|
+
status = @freelancer.post_feedback
|
119
|
+
status.success?.should == true
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
context "post reply to feedback" do
|
126
|
+
|
127
|
+
should "be able to push feedback reply to user id" do
|
128
|
+
|
129
|
+
@freelancer.expects(:api_get).with("/Common/postReplyForFeedback.json", { :projectid => 1, :userid => 1, :feedbacktext => "Test" })
|
130
|
+
@freelancer.post_feedback_reply(:project_id => 1, :user_id => 1, :comment => "Test")
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
should "be able to push feedback reply to username" do
|
135
|
+
|
136
|
+
@freelancer.expects(:api_get).with("/Common/postReplyForFeedback.json", { :projectid => 1, :username => "test", :feedbacktext => "Test" })
|
137
|
+
@freelancer.post_feedback_reply(:project_id => 1, :username => "test", :comment => "Test")
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
should "parse response into a status confirmation model" do
|
142
|
+
|
143
|
+
stub_api_get("/Common/postReplyForFeedback.json", "status_confirmation.json")
|
144
|
+
status = @freelancer.post_feedback_reply
|
145
|
+
status.success?.should == true
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
context "request withdraw feedback" do
|
152
|
+
|
153
|
+
should "be able to push request by user id" do
|
154
|
+
|
155
|
+
@freelancer.expects(:api_get).with("/Common/requestWithdrawFeedback.json", { :projectid => 1, :userid => 1 })
|
156
|
+
@freelancer.request_withdraw_feedback(:project_id => 1, :user_id => 1)
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
should "be able to push request by username" do
|
161
|
+
|
162
|
+
@freelancer.expects(:api_get).with("/Common/requestWithdrawFeedback.json", { :projectid => 1, :username => "test" })
|
163
|
+
@freelancer.request_withdraw_feedback(:project_id => 1, :username => "test")
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
should "parse response into a status confirmation model" do
|
168
|
+
|
169
|
+
stub_api_get("/Common/requestWithdrawFeedback.json", "status_confirmation.json")
|
170
|
+
status = @freelancer.request_withdraw_feedback
|
171
|
+
status.success?.should == true
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
80
177
|
end
|
81
178
|
|
82
179
|
end
|
@@ -100,6 +100,264 @@ class EmployerApiTest < Test::Unit::TestCase
|
|
100
100
|
|
101
101
|
end
|
102
102
|
|
103
|
+
context "post new project" do
|
104
|
+
|
105
|
+
setup do
|
106
|
+
|
107
|
+
@project = Freelancer::Models::Project.new
|
108
|
+
@project.jobs = [ "Ruby", ".NET" ]
|
109
|
+
@project.budget_option = 1
|
110
|
+
@project.options = Freelancer::Models::ProjectOptions.new
|
111
|
+
|
112
|
+
@expected_params = {
|
113
|
+
:duration => nil,
|
114
|
+
:budgetoption => 1,
|
115
|
+
:projectname => nil,
|
116
|
+
:jobtypecsv => 'Ruby,.NET',
|
117
|
+
:projectdesc => nil
|
118
|
+
}
|
119
|
+
|
120
|
+
@expected_query_string = "budgetoption=1&projectname=&jobtypecsv=Ruby,.NET&projectdesc=&duration="
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
should "be able to push project" do
|
125
|
+
|
126
|
+
@freelancer.expects(:api_get).with("/Employer/postNewProject.json", @expected_params)
|
127
|
+
@freelancer.new_project(@project)
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
should "parse response into a project model" do
|
132
|
+
|
133
|
+
stub_api_get("/Employer/postNewProject.json?#{@expected_query_string}", "employer/post_new_project.json")
|
134
|
+
project = @freelancer.new_project(@project)
|
135
|
+
project.id.should > 0
|
136
|
+
project.url.length.should > 0
|
137
|
+
project.posted_at.should_not == nil
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
context "post new draft project" do
|
144
|
+
|
145
|
+
setup do
|
146
|
+
|
147
|
+
@project = Freelancer::Models::Project.new
|
148
|
+
@project.jobs = [ "Ruby", ".NET" ]
|
149
|
+
@project.budget_option = 1
|
150
|
+
@project.options = Freelancer::Models::ProjectOptions.new
|
151
|
+
|
152
|
+
@expected_params = {
|
153
|
+
:duration => nil,
|
154
|
+
:budgetoption => 1,
|
155
|
+
:projectname => nil,
|
156
|
+
:jobtypecsv => 'Ruby,.NET',
|
157
|
+
:projectdesc => nil
|
158
|
+
}
|
159
|
+
|
160
|
+
@expected_query_string = "budgetoption=1&projectname=&jobtypecsv=Ruby,.NET&projectdesc=&duration="
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
should "be able to push project" do
|
165
|
+
|
166
|
+
@freelancer.expects(:api_get).with("/Employer/postNewDraftProject.json", @expected_params)
|
167
|
+
@freelancer.new_project_draft(@project)
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
should "parse response into a project model" do
|
172
|
+
|
173
|
+
stub_api_get("/Employer/postNewDraftProject.json?#{@expected_query_string}", "employer/post_new_draft_project.json")
|
174
|
+
project = @freelancer.new_project_draft(@project)
|
175
|
+
project.id.should > 0
|
176
|
+
project.url.length.should > 0
|
177
|
+
project.posted_at.should_not == nil
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
context "post new trial project" do
|
184
|
+
|
185
|
+
setup do
|
186
|
+
|
187
|
+
@project = Freelancer::Models::Project.new
|
188
|
+
@project.jobs = [ "Ruby", ".NET" ]
|
189
|
+
@project.budget_option = 1
|
190
|
+
@project.options = Freelancer::Models::ProjectOptions.new
|
191
|
+
|
192
|
+
@expected_params = {
|
193
|
+
:duration => nil,
|
194
|
+
:budgetoption => 1,
|
195
|
+
:projectname => nil,
|
196
|
+
:jobtypecsv => 'Ruby,.NET',
|
197
|
+
:projectdesc => nil
|
198
|
+
}
|
199
|
+
|
200
|
+
@expected_query_string = "budgetoption=1&projectname=&jobtypecsv=Ruby,.NET&projectdesc=&duration="
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
should "be able to push project" do
|
205
|
+
|
206
|
+
@freelancer.expects(:api_get).with("/Employer/postNewTrialProject.json", @expected_params)
|
207
|
+
@freelancer.new_trial_project(@project)
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
should "parse response into a project model" do
|
212
|
+
|
213
|
+
stub_api_get("/Employer/postNewTrialProject.json?#{@expected_query_string}", "employer/post_new_trial_project.json")
|
214
|
+
project = @freelancer.new_trial_project(@project)
|
215
|
+
project.id.should > 0
|
216
|
+
project.url.length.should > 0
|
217
|
+
project.posted_at.should_not == nil
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
context "update project details" do
|
224
|
+
|
225
|
+
setup do
|
226
|
+
|
227
|
+
@project = Freelancer::Models::Project.new
|
228
|
+
@project.jobs = [ "Ruby", ".NET" ]
|
229
|
+
|
230
|
+
@expected_params = {
|
231
|
+
:projectid => nil,
|
232
|
+
:jobtypecsv => 'Ruby,.NET',
|
233
|
+
:projectdesc => nil
|
234
|
+
}
|
235
|
+
|
236
|
+
@expected_query_string = "projectid=&jobtypecsv=Ruby,.NET&projectdesc="
|
237
|
+
|
238
|
+
end
|
239
|
+
|
240
|
+
should "be able to push update" do
|
241
|
+
|
242
|
+
@freelancer.expects(:api_get).with("/Employer/updateProjectDetails.json", @expected_params)
|
243
|
+
@freelancer.update_project(@project)
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
should "parse response into a status confirmation model" do
|
248
|
+
|
249
|
+
stub_api_get("/Employer/updateProjectDetails.json?#{@expected_query_string}", "status_confirmation.json")
|
250
|
+
status = @freelancer.update_project(@project)
|
251
|
+
status.success?.should == true
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
context "choose winner for project" do
|
258
|
+
|
259
|
+
should "be able to choose a winner" do
|
260
|
+
|
261
|
+
@freelancer.expects(:api_get).with("/Employer/chooseWinnerForProject.json", { :projectid => 1, :useridcsv => "1" })
|
262
|
+
@freelancer.choose_winner_for_project(:project_id => 1, :user_id => 1)
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
should "be able to choose multiple winners" do
|
267
|
+
|
268
|
+
@freelancer.expects(:api_get).with("/Employer/chooseWinnerForProject.json", { :projectid => 1, :useridcsv => "1,2,3" })
|
269
|
+
@freelancer.choose_winner_for_project(:project_id => 1, :user_id => [ 1, 2, 3 ])
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
should "parse response into a status confirmation model" do
|
274
|
+
|
275
|
+
stub_api_get("/Employer/chooseWinnerForProject.json?projectid=1&useridcsv=1", "status_confirmation.json")
|
276
|
+
status = @freelancer.choose_winner_for_project(:project_id => 1, :user_id => 1)
|
277
|
+
status.success?.should == true
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
context "invite user to project" do
|
284
|
+
|
285
|
+
should "be able to invite a user by user id" do
|
286
|
+
|
287
|
+
@freelancer.expects(:api_get).with("/Employer/inviteUserForProject.json", { :projectid => 1, :useridcsv => "1" })
|
288
|
+
@freelancer.invite_user_to_project(:project_id => 1, :user_id => 1)
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
should "be able to invite multiple users by user id" do
|
293
|
+
|
294
|
+
@freelancer.expects(:api_get).with("/Employer/inviteUserForProject.json", { :projectid => 1, :useridcsv => "1,2,3" })
|
295
|
+
@freelancer.invite_user_to_project(:project_id => 1, :user_id => [ 1, 2, 3 ])
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
should "be able to invite a user by username" do
|
300
|
+
|
301
|
+
@freelancer.expects(:api_get).with("/Employer/inviteUserForProject.json", { :projectid => 1, :usernamecsv => "test" })
|
302
|
+
@freelancer.invite_user_to_project(:project_id => 1, :username => "test")
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
should "be able to invite multiple users by username" do
|
307
|
+
|
308
|
+
@freelancer.expects(:api_get).with("/Employer/inviteUserForProject.json", { :projectid => 1, :usernamecsv => "test,user" })
|
309
|
+
@freelancer.invite_user_to_project(:project_id => 1, :username => [ "test", "user" ])
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
should "parse response into a status confirmation model" do
|
314
|
+
|
315
|
+
stub_api_get("/Employer/inviteUserForProject.json?projectid=1&useridcsv=1", "status_confirmation.json")
|
316
|
+
status = @freelancer.invite_user_to_project(:project_id => 1, :user_id => 1)
|
317
|
+
status.success?.should == true
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
context "upgrade a trial project" do
|
324
|
+
|
325
|
+
should "be able to push update" do
|
326
|
+
|
327
|
+
@freelancer.expects(:api_get).with("/Employer/upgradeTrialProject.json", { :projectid => 1 })
|
328
|
+
@freelancer.upgrade_trial_project(:project_id => 1)
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
should "parse response into a status confirmation model" do
|
333
|
+
|
334
|
+
stub_api_get("/Employer/upgradeTrialProject.json?projectid=1", "status_confirmation.json")
|
335
|
+
status = @freelancer.upgrade_trial_project(:project_id => 1)
|
336
|
+
status.success?.should == true
|
337
|
+
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
context "delete a draft project" do
|
343
|
+
|
344
|
+
should "be able to push update" do
|
345
|
+
|
346
|
+
@freelancer.expects(:api_get).with("/Employer/deleteDraftProject.json", { :projectid => 1 })
|
347
|
+
@freelancer.delete_draft_project(:project_id => 1)
|
348
|
+
|
349
|
+
end
|
350
|
+
|
351
|
+
should "parse response into a status confirmation model" do
|
352
|
+
|
353
|
+
stub_api_get("/Employer/deleteDraftProject.json?projectid=1", "status_confirmation.json")
|
354
|
+
status = @freelancer.delete_draft_project(:project_id => 1)
|
355
|
+
status.success?.should == true
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
|
103
361
|
end
|
104
362
|
|
105
363
|
end
|
@@ -67,6 +67,82 @@ class FreelancerApiTest < Test::Unit::TestCase
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
+
context "bid on a project" do
|
71
|
+
|
72
|
+
should "be able to push bid" do
|
73
|
+
|
74
|
+
@freelancer.expects(:api_get).with("/Freelancer/placeBidOnProject.json", { :projectid => 1, :amount => 100, :days => 10, :description => "Test" })
|
75
|
+
@freelancer.bid_on_project(:project_id => 1, :amount => 100, :days => 10, :description => "Test")
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
should "parse response into a status confirmation model" do
|
80
|
+
|
81
|
+
stub_api_get("/Freelancer/placeBidOnProject.json", "status_confirmation.json")
|
82
|
+
status = @freelancer.bid_on_project
|
83
|
+
status.success?.should == true
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context "retract bid from project" do
|
90
|
+
|
91
|
+
should "be able to retract bid" do
|
92
|
+
|
93
|
+
@freelancer.expects(:api_get).with("/Freelancer/retractBidFromProject.json", { :projectid => 1 })
|
94
|
+
@freelancer.retract_bid_from_project(:project_id => 1)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
should "parse response into a status confirmation model" do
|
99
|
+
|
100
|
+
stub_api_get("/Freelancer/retractBidFromProject.json", "status_confirmation.json")
|
101
|
+
status = @freelancer.retract_bid_from_project
|
102
|
+
status.success?.should == true
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
context "accept won project" do
|
109
|
+
|
110
|
+
should "be able to accept project" do
|
111
|
+
|
112
|
+
@freelancer.expects(:api_get).with("/Freelancer/acceptBidWon.json", { :projectid => 1 })
|
113
|
+
@freelancer.accept_won_bid(:project_id => 1)
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
should "parse response into a status confirmation model" do
|
118
|
+
|
119
|
+
stub_api_get("/Freelancer/acceptBidWon.json", "status_confirmation.json")
|
120
|
+
status = @freelancer.accept_won_bid
|
121
|
+
status.success?.should == true
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
context "reject won project" do
|
128
|
+
|
129
|
+
should "be able to reject project" do
|
130
|
+
|
131
|
+
@freelancer.expects(:api_get).with("/Freelancer/acceptBidWon.json", { :projectid => 1, :state => 0 })
|
132
|
+
@freelancer.reject_won_bid(:project_id => 1)
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
should "parse response into a status confirmation model" do
|
137
|
+
|
138
|
+
stub_api_get("/Freelancer/acceptBidWon.json?state=0", "status_confirmation.json")
|
139
|
+
status = @freelancer.reject_won_bid
|
140
|
+
status.success?.should == true
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
70
146
|
end
|
71
147
|
|
72
148
|
end
|