freelancer4r 1.0.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/CHANGELOG +6 -0
- data/LICENSE.txt +1 -0
- data/README.rdoc +50 -0
- data/Rakefile.rb +35 -0
- data/lib/freelancer.rb +75 -0
- data/lib/freelancer/api.rb +30 -0
- data/lib/freelancer/authentication.rb +104 -0
- data/lib/freelancer/common.rb +120 -0
- data/lib/freelancer/core.rb +26 -0
- data/lib/freelancer/employer.rb +122 -0
- data/lib/freelancer/freelancer.rb +82 -0
- data/lib/freelancer/job.rb +10 -0
- data/lib/freelancer/message.rb +70 -0
- data/lib/freelancer/notification.rb +17 -0
- data/lib/freelancer/payment.rb +153 -0
- data/lib/freelancer/profile.rb +83 -0
- data/lib/freelancer/project.rb +97 -0
- data/lib/freelancer/user.rb +65 -0
- data/lib/freelancer/util.rb +35 -0
- data/lib/freelancer/widget.rb +176 -0
- metadata +136 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
module Freelancer
|
2
|
+
module Profile
|
3
|
+
#Retrieve the the profile information for the current user.
|
4
|
+
#
|
5
|
+
#http://developer.freelancer.com/GetAccountDetails
|
6
|
+
def getAccountDetails
|
7
|
+
request "/Profile/getAccountDetails.json"
|
8
|
+
end
|
9
|
+
|
10
|
+
#Retrieve the the profile information for the particular user.
|
11
|
+
#
|
12
|
+
#http://developer.freelancer.com/GetProfileInfo
|
13
|
+
#
|
14
|
+
#<b>Required:</b>
|
15
|
+
#:userid => Retrieve the profile information of this user Id.
|
16
|
+
def getProfileInfo *args
|
17
|
+
options=fill_args [:userid],[:userid],*args
|
18
|
+
request "/Profile/getProfileInfo.json",options
|
19
|
+
end
|
20
|
+
|
21
|
+
#Update the account information for the current user.
|
22
|
+
#
|
23
|
+
#http://developer.freelancer.com/SetProfileInfo
|
24
|
+
#
|
25
|
+
#<b>Optional:</b> (minimum one required)
|
26
|
+
#:fullname
|
27
|
+
#:company_name
|
28
|
+
#:type_of_work
|
29
|
+
#:multipartpic
|
30
|
+
#:addressline1
|
31
|
+
#:addressline2
|
32
|
+
#:city
|
33
|
+
#:state
|
34
|
+
#:country
|
35
|
+
#:postalcode
|
36
|
+
#:phone
|
37
|
+
#:fax
|
38
|
+
#:notificationformat
|
39
|
+
#:emailnotificationstatus
|
40
|
+
#:receivenewsstatus
|
41
|
+
#:bidwonnotificationstatus
|
42
|
+
#:bidplacednotificationstatus
|
43
|
+
#:newprivatemessagestatus
|
44
|
+
#:qualificationcsv
|
45
|
+
#:profiletext
|
46
|
+
#:vision
|
47
|
+
#:keywords
|
48
|
+
#:hourlyrate
|
49
|
+
#:skills
|
50
|
+
def setProfileInfo *args
|
51
|
+
options=fill_args [
|
52
|
+
:fullname,
|
53
|
+
:company_name,
|
54
|
+
:type_of_work,
|
55
|
+
:multipartpic,
|
56
|
+
:addressline1,
|
57
|
+
:addressline2,
|
58
|
+
:city,
|
59
|
+
:state,
|
60
|
+
:country,
|
61
|
+
:postalcode,
|
62
|
+
:phone,
|
63
|
+
:fax,
|
64
|
+
:notificationformat,
|
65
|
+
:emailnotificationstatus,
|
66
|
+
:receivenewsstatus,
|
67
|
+
:bidwonnotificationstatus,
|
68
|
+
:bidplacednotificationstatus,
|
69
|
+
:newprivatemessagestatus,
|
70
|
+
:qualificationcsv,
|
71
|
+
:profiletext,
|
72
|
+
:vision,
|
73
|
+
:keywords,
|
74
|
+
:hourlyrate,
|
75
|
+
:skills
|
76
|
+
],[],*args
|
77
|
+
if options.length==0
|
78
|
+
raise "One property requered to change"
|
79
|
+
end
|
80
|
+
request "/Profile/setProfileInfo.json",options
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Freelancer
|
2
|
+
module Project
|
3
|
+
#Search Projects
|
4
|
+
#
|
5
|
+
#http://developer.freelancer.com/SearchProjects
|
6
|
+
#
|
7
|
+
#<b>Optional:</b>
|
8
|
+
#:isfeatured => boolean
|
9
|
+
#:isnonpublic => boolean
|
10
|
+
#:searchkeyword => string
|
11
|
+
#:searchjobtypecsv => coma separated job types [ PHP, .NET ]
|
12
|
+
#:status => string [ Open | Frozen | Closed| ClosedAwarded| ClosedCanceled ]
|
13
|
+
#:budgetmin => integer or String [ 250 | 750 |1500 |3000 | Any ]
|
14
|
+
#:budgetmax => integer
|
15
|
+
#:isfulltime => boolean
|
16
|
+
#:istrial => boolean
|
17
|
+
#:isgoldmembersonly => boolean
|
18
|
+
#:bidendsduration => string [ submitdate (default) | bid_enddate | id | state ]
|
19
|
+
#:count => number
|
20
|
+
#:page => number
|
21
|
+
#:tags => string
|
22
|
+
#:sort => string
|
23
|
+
def searchProjects *args
|
24
|
+
options=fill_args [
|
25
|
+
:isfeatured,
|
26
|
+
:isnonpublic,
|
27
|
+
:searchkeyword,
|
28
|
+
:searchjobtypecsv,
|
29
|
+
:status,
|
30
|
+
:budgetmin,
|
31
|
+
:budgetmax,
|
32
|
+
:isfulltime,
|
33
|
+
:istrial,
|
34
|
+
:isgoldmembersonly,
|
35
|
+
:bidendsduration,
|
36
|
+
:count,
|
37
|
+
:page,
|
38
|
+
:tags,
|
39
|
+
:sort
|
40
|
+
],[], *args
|
41
|
+
|
42
|
+
request "/Project/searchProjects.json",options
|
43
|
+
end
|
44
|
+
|
45
|
+
#Get the cost all the project posting options.
|
46
|
+
#
|
47
|
+
#http://developer.freelancer.com/GetProjectFees
|
48
|
+
def getProjectFees
|
49
|
+
request "/Project/getProjectFees.json"
|
50
|
+
end
|
51
|
+
|
52
|
+
#Retrieve the details for a particular project
|
53
|
+
#
|
54
|
+
#http://developer.freelancer.com/GetProjectDetails
|
55
|
+
#
|
56
|
+
#<b>Required:</b>
|
57
|
+
#:projectid => project id
|
58
|
+
def getProjectDetails *args
|
59
|
+
options = fill_args [:projectid],[:projectid],*args
|
60
|
+
request "/Project/getProjectDetails.json", options
|
61
|
+
end
|
62
|
+
|
63
|
+
#Get All bids details to the selected project
|
64
|
+
#
|
65
|
+
#http://developer.freelancer.com/GetBidsDetails
|
66
|
+
#
|
67
|
+
#<b>Required:</b>
|
68
|
+
#:projectid => project id
|
69
|
+
def getBidsDetails *args
|
70
|
+
options = fill_args [:projectid],[:projectid],*args
|
71
|
+
request "/Project/getBidsDetails.json",options
|
72
|
+
end
|
73
|
+
|
74
|
+
#Retrieve the public messages posted to a project clarification board.
|
75
|
+
#
|
76
|
+
#http://developer.freelancer.com/GetPublicMessages
|
77
|
+
#
|
78
|
+
#<b>Required:</b>
|
79
|
+
#:projectid => project id
|
80
|
+
def getPublicMessages *args
|
81
|
+
options = fill_args [:projectid],[:projectid],*args
|
82
|
+
request "/Project/getPublicMessages.json",options
|
83
|
+
end
|
84
|
+
|
85
|
+
#Post a public message to project clarification board.
|
86
|
+
#
|
87
|
+
#http://developer.freelancer.com/PostPublicMessage
|
88
|
+
#
|
89
|
+
#<b>Required:</b>
|
90
|
+
#:projectid => Project Id associated with the message
|
91
|
+
#:messagetext => message text
|
92
|
+
def postPublicMessage *args
|
93
|
+
options = fill_args [:projectid,:messagetext],[:projectid,:messagetext],*args
|
94
|
+
request "/Project/postPublicMessage.json",options
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Freelancer
|
2
|
+
module User
|
3
|
+
#Search for users using various search criteria.
|
4
|
+
#
|
5
|
+
#http://developer.freelancer.com/GetUsersBySearch
|
6
|
+
#
|
7
|
+
#<b>Optional:</b>
|
8
|
+
#:username => Username of the person for who you are searching.
|
9
|
+
#:expertise_csv => Comma separated list of job categories, refer to the main page for a list of categories.
|
10
|
+
#:country_csv => Comma separated list of countries
|
11
|
+
#:rating => Minimum rating for the user
|
12
|
+
#:count => (default: 50)
|
13
|
+
#:page => (default: 0)
|
14
|
+
def getUsersBySearch *args
|
15
|
+
options=fill_args [
|
16
|
+
:username,
|
17
|
+
:expertise_csv,
|
18
|
+
:country_csv,
|
19
|
+
:rating,
|
20
|
+
:count,
|
21
|
+
:page
|
22
|
+
],[], *args
|
23
|
+
request "/User/getUsersBySearch.json",options
|
24
|
+
end
|
25
|
+
|
26
|
+
#Get feedback received by a particular user.
|
27
|
+
#
|
28
|
+
#http://developer.freelancer.com/GetUserFeedback
|
29
|
+
#
|
30
|
+
#<b>Required:</b>
|
31
|
+
#:username => Username or userid is required
|
32
|
+
#:userid => Username or userid is required
|
33
|
+
#
|
34
|
+
#<b>Optional:</b>
|
35
|
+
#:type => [P = Provider Only, B = Buyer Only, A = Default, All]
|
36
|
+
def getUsersFeedback *args
|
37
|
+
options=fill_args [:username,:userid,:type],[],*args
|
38
|
+
if options[:username]==nil && options[:userid]==nil
|
39
|
+
raise "Username or userid is required"
|
40
|
+
end
|
41
|
+
if options[:username]!=nil && options[:userid]!=nil
|
42
|
+
raise "Both username and userid is not allowed"
|
43
|
+
end
|
44
|
+
request "/User/getUserFeedback.json",options
|
45
|
+
end
|
46
|
+
|
47
|
+
#Get the profile information for a particular user.
|
48
|
+
#
|
49
|
+
#http://developer.freelancer.com/GetUserDetails
|
50
|
+
#
|
51
|
+
#<b>Required:</b>
|
52
|
+
#:username => Username or userid is required
|
53
|
+
#:userid => Username or userid is required
|
54
|
+
def getUserDetails *args
|
55
|
+
options=fill_args [:username,:userid],[],*args
|
56
|
+
if options[:username]==nil && options[:userid]==nil
|
57
|
+
raise "Username or userid is required"
|
58
|
+
end
|
59
|
+
if options[:username]!=nil && options[:userid]!=nil
|
60
|
+
raise "Both username and userid is not allowed"
|
61
|
+
end
|
62
|
+
request "/User/getUserDetails.json",options
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Freelancer
|
2
|
+
module Util
|
3
|
+
#Convert array parameters to hash, using field list
|
4
|
+
#
|
5
|
+
#def mymethod *args
|
6
|
+
# options = fill_args [:param1,:param2,:param3],[:param1], *args
|
7
|
+
#....
|
8
|
+
#
|
9
|
+
#mymethod 1,2,3 => {:param1=>1,:param2=>2,param3=>3}
|
10
|
+
#mymethod => exception, Required key not found
|
11
|
+
#mymethod 1,"x" => {:param1=>1,:param2=>"x"}
|
12
|
+
#mymethod :param1=>"y" => {:param1=>"y"}
|
13
|
+
#mymethod :param1=>1,:param2=>2 => {:param1=>1,:param2=>2}
|
14
|
+
#
|
15
|
+
#fields Required,the field list
|
16
|
+
#require Required,the required field list (maybe empty array)
|
17
|
+
#arguments
|
18
|
+
def fill_args fields,required, *arguments
|
19
|
+
options={}
|
20
|
+
arguments.each_index do |index|
|
21
|
+
if arguments[index].is_a? Hash
|
22
|
+
options.merge! arguments[index]
|
23
|
+
else
|
24
|
+
options[fields[index]]=arguments[index]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
required.each do |needed|
|
28
|
+
if !options.key? needed
|
29
|
+
raise "Required key not found"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
return options
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Freelancer
|
6
|
+
module Widget
|
7
|
+
def request_widget path, parameters={}
|
8
|
+
params=parameters.map do |k,v|
|
9
|
+
if v.is_a?(TrueClass) || v.is_a?(FalseClass)
|
10
|
+
v = v ? "1" : "0"
|
11
|
+
end
|
12
|
+
if v.is_a?(Array)
|
13
|
+
v.map do |item|
|
14
|
+
"#{CGI.escape(k.to_s)}[]=#{CGI.escape(item.to_s)}"
|
15
|
+
end.join("&")
|
16
|
+
else
|
17
|
+
puts v
|
18
|
+
"#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
|
19
|
+
end
|
20
|
+
end.join("&")
|
21
|
+
url=api_url+path
|
22
|
+
url+="?#{params}" if params.length > 0
|
23
|
+
uri=URI.parse(url)
|
24
|
+
puts uri
|
25
|
+
# response=Net::HTTP.get_response(uri)
|
26
|
+
# puts response.body
|
27
|
+
end
|
28
|
+
|
29
|
+
#= Search projects
|
30
|
+
#
|
31
|
+
#http://www.freelancer.com/affiliate-api.html#ProjectSearch
|
32
|
+
#
|
33
|
+
#== Optional
|
34
|
+
#:keyword
|
35
|
+
# Search keyword
|
36
|
+
#:owner
|
37
|
+
# Username of ID of project owner
|
38
|
+
#:winner
|
39
|
+
# Username of ID of project winner
|
40
|
+
#:jobs[]
|
41
|
+
# Names of job categories from the available list on Freelancer.com (PHP, .NET, AJAX, etc.). This parameter may be repeated more than once
|
42
|
+
#:featured
|
43
|
+
# If 1 - only featured projects, if 0 - only NON-featured projects
|
44
|
+
#:trial
|
45
|
+
# If 1 - only trial projects, if 0 - only NON-trial projects
|
46
|
+
#:for_gold_members
|
47
|
+
# If 1 - only "For gold members" projects, if 0 - only NON "For gold members" projects
|
48
|
+
#:nonpublic
|
49
|
+
# If 1 - only nonpublic projects, if 0 - only public projects
|
50
|
+
#:min_budget
|
51
|
+
# Only projects with budget higher or equal to min_budget
|
52
|
+
#:max_budget
|
53
|
+
# Only projects with budget lower or equal to max_budget
|
54
|
+
#:bidding_ends
|
55
|
+
# Only projects ending sooner than bidding_ends days
|
56
|
+
#:order
|
57
|
+
# How to order projects in the result output. See available project order criteria.
|
58
|
+
# types:
|
59
|
+
# :id - order by project ID
|
60
|
+
# :submitdate - order by date when project was added (default)
|
61
|
+
# :state - order by state of project. Active/open projects will be listed first, next - frozen and then closed.
|
62
|
+
# :bid_count - order by number of bids
|
63
|
+
# :bid_avg - order by average bid
|
64
|
+
# :bid_enddate - order by bidding end time
|
65
|
+
# :buyer - order by buyer's username
|
66
|
+
# :budget - order by budget
|
67
|
+
# :relevance - order by relevance of search by keyword. This criterion should be used with the parameter keyword
|
68
|
+
# :rand - order randomly
|
69
|
+
#:order_dir
|
70
|
+
# Direction of sorting. If the parameter is equal to asc, results are ordered in ascending way, otherwise - descending (desc).
|
71
|
+
#:pg
|
72
|
+
# Page number. Starts from 0. Default page is 0
|
73
|
+
#:count
|
74
|
+
# Number of items on a page
|
75
|
+
#:apikey
|
76
|
+
# API key, paramater is optional.
|
77
|
+
def search *args
|
78
|
+
options=fill_args [
|
79
|
+
:keyword,
|
80
|
+
:owner,
|
81
|
+
:winner,
|
82
|
+
:jobs,
|
83
|
+
:featured,
|
84
|
+
:trial,
|
85
|
+
:for_gold_members,
|
86
|
+
:nonpublic,
|
87
|
+
:min_budget,
|
88
|
+
:max_budget,
|
89
|
+
:bidding_ends,
|
90
|
+
:order,
|
91
|
+
:order_dir,
|
92
|
+
:pg,
|
93
|
+
:count,
|
94
|
+
:apikey
|
95
|
+
],[],*args
|
96
|
+
|
97
|
+
request_widget("/Project/Search.json",options)
|
98
|
+
end
|
99
|
+
|
100
|
+
#= Get the project details
|
101
|
+
#
|
102
|
+
#http://www.freelancer.com/affiliate-api.html#ProjectProperties
|
103
|
+
#
|
104
|
+
#== Required
|
105
|
+
#:id
|
106
|
+
# the project id
|
107
|
+
#
|
108
|
+
#== Optional
|
109
|
+
#:apikey
|
110
|
+
# API key, paramater is optional.
|
111
|
+
def projectDetails *args
|
112
|
+
options=fill_args [:id,:apikey],[:id],*args
|
113
|
+
request_widget("/Project/Properties.json",options)
|
114
|
+
end
|
115
|
+
|
116
|
+
#Get the project details
|
117
|
+
#
|
118
|
+
#http://www.freelancer.com/affiliate-api.html#UserProperties
|
119
|
+
#
|
120
|
+
#== Required
|
121
|
+
#:id
|
122
|
+
# the user id
|
123
|
+
#
|
124
|
+
#== Optional
|
125
|
+
#:apikey
|
126
|
+
# API key
|
127
|
+
def userDetails *args
|
128
|
+
options=fill_args [:id,:apikey],[:id],*args
|
129
|
+
request_widget("/User/Properties.json",options)
|
130
|
+
end
|
131
|
+
|
132
|
+
#= Feedback search
|
133
|
+
#
|
134
|
+
#http://www.freelancer.com/affiliate-api.html#FeedbackSearch
|
135
|
+
#
|
136
|
+
#== Required
|
137
|
+
#:user
|
138
|
+
# ID or username of a feedback receiver
|
139
|
+
#
|
140
|
+
#== Optional
|
141
|
+
#:project_id
|
142
|
+
# ID of project for which the feedback was made
|
143
|
+
#:type
|
144
|
+
# Type of the feedback. S - service provider's (seller's) feedbacks, B - buyer's feedbacks. By default provider's feedbacks are returned
|
145
|
+
#:positive
|
146
|
+
# if positive equals to 1, only feedbacks with rating higher than average will be returned
|
147
|
+
#:order
|
148
|
+
# How to order feedbacks in result output. Types:
|
149
|
+
# :active_date - order by date when feedback was activated (default)
|
150
|
+
# :rand - order randomly
|
151
|
+
#
|
152
|
+
#:order_dir
|
153
|
+
# Direction of sorting. If the parameter is equal to asc, results are ordered in ascending way, otherwise - descending ('desc').
|
154
|
+
#:pg
|
155
|
+
# Page number. Starts from 0. Default page is 0
|
156
|
+
#:count
|
157
|
+
# Number of items on a page
|
158
|
+
#:apikey
|
159
|
+
# API key
|
160
|
+
def feedbackSearch
|
161
|
+
options=fill_args [
|
162
|
+
:user,
|
163
|
+
:project_id,
|
164
|
+
:type,
|
165
|
+
:positive,
|
166
|
+
:order,
|
167
|
+
:order_dir,
|
168
|
+
:pg,
|
169
|
+
:count,
|
170
|
+
:apikey
|
171
|
+
],[:user],*args
|
172
|
+
|
173
|
+
request_widget("/Feedback/Search.json",options)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|