Module: Freelancer::API::Common::InstanceMethods
- Defined in:
- lib/freelancer/api/common.rb
Instance Method Summary collapse
-
#config_version(*args) ⇒ Object
Get the configuration version of a specific service function.
-
#pending_feedback(*args) ⇒ Object
Get a list of projects that are pending feedback.
-
#post_feedback(*args) ⇒ Object
Post feedback for a user.
-
#post_feedback_reply(*args) ⇒ Object
Post reply to a feedback given to you.
-
#request_cancel_project(*args) ⇒ Object
Request to cancel an awarded project.
-
#request_withdraw_feedback(*args) ⇒ Object
Request that posted feedback is withdrawn.
-
#terms ⇒ Object
Returns the current Terms and Conditions from the site.
Instance Method Details
#config_version(*args) ⇒ Object
Get the configuration version of a specific service function
Valid parameters are:
- function: the function to look up config version for
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/freelancer/api/common.rb', line 28 def config_version(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/getConfigVersion.json", build_api_params({ :function => params[:function] })) # Parse and return the response ::Freelancer::Models::ConfigVersion.parse(result, :shift => :"json-result") end |
#pending_feedback(*args) ⇒ Object
Get a list of projects that are pending feedback
Valid parameters are:
- type: the type of projects to list ("P" or "B" (default))
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/freelancer/api/common.rb', line 10 def pending_feedback(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/getPendingFeedback.json", build_api_params({ :type => params[:type] })) # Parse and return the response ::Freelancer::Models::Project.parse_collection(result, :shift => [ :"json-result", :items ]) end |
#post_feedback(*args) ⇒ Object
Post feedback for a user
Valid parameters are:
- project_id: the project id related to the feedback
- user_id: the id of the user to rate
- username: the username of the user to rate
- comment: the feedback comment
- rating: the feedback rating
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/freelancer/api/common.rb', line 89 def post_feedback(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/postFeedback.json", build_api_params({ :projectid => params[:project_id], :userid => params[:user_id], :username => params[:username], :feedbacktext => params[:comment], :rating => params[:rating] })) # Parse and return the response ::Freelancer::Models::StatusConfirmation.parse(result, :shift => :"json-result") end |
#post_feedback_reply(*args) ⇒ Object
Post reply to a feedback given to you
Valid parameters are:
- project_id: the id of the project related to the feedback
- user_id: the id of the user to reply to
- username: the username of the user to reply to
- comment: the feedback comment
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/freelancer/api/common.rb', line 114 def post_feedback_reply(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/postReplyForFeedback.json", build_api_params({ :projectid => params[:project_id], :userid => params[:user_id], :username => params[:username], :feedbacktext => params[:comment] })) # Parse and return the response ::Freelancer::Models::StatusConfirmation.parse(result, :shift => :"json-result") end |
#request_cancel_project(*args) ⇒ Object
Request to cancel an awarded project
Valid parameters are:
- project_id: the id of the project to cancel
- selected_winner: the id of the selected winner of the project
- comment: the comment for the cancellation request
- reason: the reason for cancelling the project
- followed_guidelines: if the guidelines for cancelling the project has been followed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/freelancer/api/common.rb', line 63 def request_cancel_project(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/requestCancelProject.json", build_api_params({ :projectid => params[:project_id], :selectedwinner => params[:selected_winner], :commenttext => params[:comment], :reasoncancellation => params[:reason], :followedguidelinesstatus => params[:followed_guidelines] })) # Parse and return the response ::Freelancer::Models::StatusConfirmation.parse(result, :shift => :"json-result") end |
#request_withdraw_feedback(*args) ⇒ Object
Request that posted feedback is withdrawn
Valid parameters are:
- project_id: the id of the project related to feedback
- user_id: the user id the feedback is posted to
- username: the username the feedback is posted to
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/freelancer/api/common.rb', line 137 def request_withdraw_feedback(*args) params = extract_params(args) # Execute the service call result = api_get("/Common/requestWithdrawFeedback.json", build_api_params({ :projectid => params[:project_id], :userid => params[:user_id], :username => params[:username] })) # Parse and return the response ::Freelancer::Models::StatusConfirmation.parse(result, :shift => :"json-result") end |
#terms ⇒ Object
Returns the current Terms and Conditions from the site
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/freelancer/api/common.rb', line 43 def terms result = api_get("/Common/getTerms.json") json = JSONMapper::Parser.parse(result) if !json.nil? && json.key?(:"json-result") return json[:"json-result"][:terms] end return nil end |