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.
@@ -139,6 +139,50 @@ class MessageApiTest < Test::Unit::TestCase
139
139
 
140
140
  end
141
141
 
142
+ context "send message" do
143
+
144
+ should "be able to send message to user id" do
145
+
146
+ @freelancer.expects(:api_get).with("/Message/sendMessage.json", { :projectid => 1, :messagetext => "Test", :userid => 1 })
147
+ @freelancer.send_message(:project_id => 1, :text => "Test", :user_id => 1)
148
+
149
+ end
150
+
151
+ should "be able to send message to username" do
152
+
153
+ @freelancer.expects(:api_get).with("/Message/sendMessage.json", { :projectid => 1, :messagetext => "Test", :username => "test" })
154
+ @freelancer.send_message(:project_id => 1, :text => "Test", :username => "test")
155
+
156
+ end
157
+
158
+ should "parse response into a status confirmation model" do
159
+
160
+ stub_api_get("/Message/sendMessage.json", "status_confirmation.json")
161
+ status = @freelancer.send_message
162
+ status.success?.should == true
163
+
164
+ end
165
+
166
+ end
167
+
168
+ context "mark message read" do
169
+
170
+ should "be able to send request" do
171
+
172
+ @freelancer.expects(:api_get).with("/Message/markMessageAsRead.json", { :id => 1 })
173
+ @freelancer.mark_message_as_read(:message_id => 1)
174
+
175
+ end
176
+
177
+ should "parse response into a status confirmation model" do
178
+
179
+ stub_api_get("/Message/markMessageAsRead.json", "status_confirmation.json")
180
+ status = @freelancer.mark_message_as_read
181
+ status.success?.should == true
182
+
183
+ end
184
+
185
+ end
142
186
  end
143
187
 
144
188
  end
@@ -220,6 +220,174 @@ class PaymentApiTest < Test::Unit::TestCase
220
220
 
221
221
  end
222
222
 
223
- end
223
+ context "request fund withdrawal" do
224
+
225
+ should "be able to send request" do
226
+
227
+ @freelancer.expects(:api_get).with("/Payment/requestWithdrawal.json", { :amount => 100, :method => "paypal", :paypalemail => "test@test.com" })
228
+ @freelancer.request_withdrawal(:amount => 100, :method => "paypal", :paypal_email => "test@test.com")
229
+
230
+ end
231
+
232
+ should "parse response into a status confirmation model" do
233
+
234
+ stub_api_get("/Payment/requestWithdrawal.json", "payment/request_withdrawal.json")
235
+ status = @freelancer.request_withdrawal
236
+ status.success?.should == true
237
+ status.status.should == "Delayed"
238
+ status.charges.should == 1
239
+
240
+ end
241
+
242
+ end
243
+
244
+ context "create milestone payment" do
245
+
246
+ should "create milestone payment by user id" do
247
+
248
+ @freelancer.expects(:api_get).with("/Payment/createMilestonePayment.json", { :projectid => 1, :amount => 100, :touserid => 1, :reasontext => "Test", :reasontype => "partial" })
249
+ @freelancer.create_milestone_payment(:project_id => 1, :amount => 100, :user_id => 1, :comment => "Test", :type => "partial")
250
+
251
+ end
252
+
253
+ should "create milestone payment by username" do
254
+
255
+ @freelancer.expects(:api_get).with("/Payment/createMilestonePayment.json", { :projectid => 1, :amount => 100, :tousername => "test", :reasontext => "Test", :reasontype => "partial" })
256
+ @freelancer.create_milestone_payment(:project_id => 1, :amount => 100, :username => "test", :comment => "Test", :type => "partial")
257
+
258
+ end
259
+
260
+ should "parse response into a status confirmation model" do
261
+
262
+ stub_api_get("/Payment/createMilestonePayment.json", "status_confirmation.json")
263
+ status = @freelancer.create_milestone_payment
264
+ status.success?.should == true
265
+
266
+ end
267
+
268
+ end
269
+
270
+ context "transfer money" do
271
+
272
+ should "transfer money by user id" do
273
+
274
+ @freelancer.expects(:api_get).with("/Payment/transferMoney.json", { :projectid => 1, :amount => 100, :touserid => 1, :reasontext => "Test", :reasontype => "partial" })
275
+ @freelancer.transfer_money(:project_id => 1, :amount => 100, :user_id => 1, :comment => "Test", :type => "partial")
276
+
277
+ end
278
+
279
+ should "transfer money by username" do
280
+
281
+ @freelancer.expects(:api_get).with("/Payment/transferMoney.json", { :projectid => 1, :amount => 100, :tousername => "test", :reasontext => "Test", :reasontype => "partial" })
282
+ @freelancer.transfer_money(:project_id => 1, :amount => 100, :username => "test", :comment => "Test", :type => "partial")
283
+
284
+ end
285
+
286
+ should "parse response into a status confirmation model" do
287
+
288
+ stub_api_get("/Payment/transferMoney.json", "status_confirmation.json")
289
+ status = @freelancer.transfer_money
290
+ status.success?.should == true
291
+
292
+ end
293
+
294
+ end
295
+
296
+ context "cancel withdrawal request" do
297
+
298
+ should "be able to send request" do
299
+
300
+ @freelancer.expects(:api_get).with("/Payment/requestCancelWithdrawal.json", { :withdrawalid => 1 })
301
+ @freelancer.cancel_withdrawal(:withdrawal_id => 1)
302
+
303
+ end
304
+
305
+ should "parse response into a status confirmation model" do
306
+
307
+ stub_api_get("/Payment/requestCancelWithdrawal.json", "status_confirmation.json")
308
+ status = @freelancer.cancel_withdrawal
309
+ status.success?.should == true
310
+
311
+ end
312
+
313
+ end
314
+
315
+ context "cancel milestone payment" do
316
+
317
+ should "be able to send request" do
318
+
319
+ @freelancer.expects(:api_get).with("/Payment/cancelMilestone.json", { :transactionid => 1 })
320
+ @freelancer.cancel_milestone(:transaction_id => 1)
321
+
322
+ end
323
+
324
+ should "parse response into a status confirmation model" do
325
+
326
+ stub_api_get("/Payment/cancelMilestone.json", "status_confirmation.json")
327
+ status = @freelancer.cancel_milestone
328
+ status.success?.should == true
329
+
330
+ end
331
+
332
+ end
333
+
334
+ context "request milestone release" do
335
+
336
+ should "be able to send request" do
337
+
338
+ @freelancer.expects(:api_get).with("/Payment/requestReleaseMilestone.json", { :transactionid => 1 })
339
+ @freelancer.request_release_milestone(:transaction_id => 1)
340
+
341
+ end
342
+
343
+ should "parse response into a status confirmation model" do
344
+
345
+ stub_api_get("/Payment/requestReleaseMilestone.json", "status_confirmation.json")
346
+ status = @freelancer.request_release_milestone
347
+ status.success?.should == true
348
+
349
+ end
350
+
351
+ end
352
+
353
+ context "release milestone" do
354
+
355
+ should "be able to send request" do
356
+
357
+ @freelancer.expects(:api_get).with("/Payment/releaseMilestone.json", { :transactionid => 1, :fullname => "Test Name" })
358
+ @freelancer.release_milestone(:transaction_id => 1, :full_name => "Test Name")
359
+
360
+ end
361
+
362
+ should "parse response into a status confirmation model" do
363
+
364
+ stub_api_get("/Payment/releaseMilestone.json", "status_confirmation.json")
365
+ status = @freelancer.release_milestone
366
+ status.success?.should == true
367
+
368
+ end
369
+
370
+ end
371
+
372
+ context "prepare transfer" do
373
+
374
+ should "be able to send request" do
375
+
376
+ @freelancer.expects(:api_get).with("/Payment/prepareTransfer.json", { :projectid => 1, :amount => 100, :touserid => 1, :reasontype => "partial" })
377
+ @freelancer.prepare_transfer(:project_id => 1, :amount => 100, :user_id => 1, :type => "partial")
378
+
379
+ end
380
+
381
+ should "parse response into a status confirmation model" do
382
+
383
+ stub_api_get("/Payment/prepareTransfer.json", "status_confirmation.json")
384
+ status = @freelancer.prepare_transfer
385
+ status.success?.should == true
386
+
387
+ end
388
+
389
+ end
390
+
391
+ end
224
392
 
225
393
  end
@@ -49,6 +49,63 @@ class ProfileApiTest < Test::Unit::TestCase
49
49
 
50
50
  end
51
51
 
52
+ context "update account details" do
53
+
54
+ setup do
55
+
56
+ @user = Freelancer::Models::User.new
57
+ @user.address = Freelancer::Models::Address.new
58
+ @user.notifications = Freelancer::Models::NotificationStatus.new
59
+ @user.qualifications = [ "Ruby", ".NET" ]
60
+ @user.skills = [ "Programming" ]
61
+
62
+ @expected_params = {
63
+ :profiletext => nil,
64
+ :receivenewsstatus => nil,
65
+ :city => nil,
66
+ :addressline2 => nil,
67
+ :bidwonnotificationstatus => nil,
68
+ :postalcode => nil,
69
+ :state => nil,
70
+ :skills => 'Programming',
71
+ :bidplacednotificationstatus => nil,
72
+ :company_name => nil,
73
+ :fullname => nil,
74
+ :hourlyrate => nil,
75
+ :newprivatemessagestatus => nil,
76
+ :vision => nil,
77
+ :notificationformat => nil,
78
+ :phone => nil,
79
+ :country => nil,
80
+ :type_of_work => nil,
81
+ :keywords => nil,
82
+ :emailnotificationstatus => nil,
83
+ :fax => nil,
84
+ :addressline1 => nil,
85
+ :qualificationcsv => 'Ruby,.NET'
86
+ }
87
+
88
+ @expected_query_string = "phone=&city=&qualificationcsv=Ruby,.NET&fullname=&state=&addressline2=&type_of_work=&skills=Programming&hourlyrate=&keywords=&bidwonnotificationstatus=&newprivatemessagestatus=&emailnotificationstatus=&postalcode=&vision=&profiletext=&country=&bidplacednotificationstatus=&fax=&receivenewsstatus=&notificationformat=&addressline1=&company_name="
89
+
90
+ end
91
+
92
+ should "be able to push update" do
93
+
94
+ @freelancer.expects(:api_get).with("/Profile/setProfileInfo.json", @expected_params)
95
+ @freelancer.update_account_details(@user)
96
+
97
+ end
98
+
99
+ should "parse response into a status confirmation model" do
100
+
101
+ stub_api_get("/Profile/setProfileInfo.json?#{@expected_query_string}", "status_confirmation.json")
102
+ status = @freelancer.update_account_details(@user)
103
+ status.success?.should == true
104
+
105
+ end
106
+
107
+ end
108
+
52
109
  end
53
110
 
54
111
  end
@@ -224,6 +224,25 @@ class ProjectApiTest < Test::Unit::TestCase
224
224
 
225
225
  end
226
226
 
227
+ context "post public message" do
228
+
229
+ should "be able to send request" do
230
+
231
+ @freelancer.expects(:api_get).with("/Project/postPublicMessage.json", { :projectid => 1, :messagetext => "Test" })
232
+ @freelancer.post_public_project_message(:project_id => 1, :message => "Test")
233
+
234
+ end
235
+
236
+ should "parse response into a status confirmation model" do
237
+
238
+ stub_api_get("/Project/postPublicMessage.json", "status_confirmation.json")
239
+ status = @freelancer.post_public_project_message
240
+ status.success?.should == true
241
+
242
+ end
243
+
244
+ end
245
+
227
246
  end
228
247
 
229
248
  end
@@ -1,5 +1,25 @@
1
1
  require "test_helper"
2
2
 
3
- ##class ClientTest < Test::Unit::TestCase
3
+ class ClientTest < Test::Unit::TestCase
4
+
5
+ context "client" do
6
+
7
+ setup do
8
+ @freelancer = Freelancer::Client.new("consumer_token", "consumer_secret")
9
+ consumer = OAuth::Consumer.new("consumer_token", "consumer_secret", { :site => "http://api.sandbox.freelancer.com" })
10
+ @freelancer.stubs(:consumer).returns(consumer)
11
+ @freelancer.authorize_from_access("access_token", "access_secret")
12
+ end
13
+
14
+ should "raise an error when a service call returns an error" do
15
+
16
+ stub_api_get("/Project/getProjectFees.json", "error.json")
17
+ assert_raise Freelancer::FreelancerResponseError do
18
+ @freelancer.project_fees
19
+ end
20
+
21
+ end
22
+
23
+ end
4
24
 
5
- ##end
25
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freelancer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Trond Arve Nordheim
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-09 00:00:00 +02:00
18
+ date: 2010-08-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -58,12 +58,12 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: 23
61
+ hash: 21
62
62
  segments:
63
63
  - 0
64
64
  - 2
65
- - 0
66
- version: 0.2.0
65
+ - 1
66
+ version: 0.2.1
67
67
  requirement: *id003
68
68
  type: :runtime
69
69
  - !ruby/object:Gem::Dependency
@@ -74,10 +74,12 @@ dependencies:
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- hash: 3
77
+ hash: 7
78
78
  segments:
79
+ - 1
80
+ - 4
79
81
  - 0
80
- version: "0"
82
+ version: 1.4.0
81
83
  requirement: *id004
82
84
  type: :development
83
85
  - !ruby/object:Gem::Dependency
@@ -194,6 +196,7 @@ files:
194
196
  - lib/freelancer/models/project_options.rb
195
197
  - lib/freelancer/models/rating.rb
196
198
  - lib/freelancer/models/review.rb
199
+ - lib/freelancer/models/status_confirmation.rb
197
200
  - lib/freelancer/models/transaction.rb
198
201
  - lib/freelancer/models/user.rb
199
202
  - lib/freelancer/models/withdrawal.rb
@@ -235,6 +238,7 @@ files:
235
238
  - test/fixtures/employer/update_project_details.xml
236
239
  - test/fixtures/employer/upgrade_trial_project.json
237
240
  - test/fixtures/employer/upgrade_trial_project.xml
241
+ - test/fixtures/error.json
238
242
  - test/fixtures/freelancer/accept_bid_won.json
239
243
  - test/fixtures/freelancer/accept_bid_won.xml
240
244
  - test/fixtures/freelancer/get_project_list_for_placed_bids.json
@@ -320,6 +324,7 @@ files:
320
324
  - test/fixtures/project/search_projects.json
321
325
  - test/fixtures/project/search_projects.xml
322
326
  - test/fixtures/project/send_message.xml
327
+ - test/fixtures/status_confirmation.json
323
328
  - test/fixtures/user/get_user_details.json
324
329
  - test/fixtures/user/get_user_details.xml
325
330
  - test/fixtures/user/get_user_feedback.json
@@ -359,7 +364,7 @@ files:
359
364
  - test/freelancer_test.rb
360
365
  - test/test_helper.rb
361
366
  has_rdoc: true
362
- homepage: http://github.com/tanordheim/freelancer
367
+ homepage: http://github.com/tanordheim/freelancer-ruby
363
368
  licenses: []
364
369
 
365
370
  post_install_message: