Module: Freelancer::API::Project::InstanceMethods

Defined in:
lib/freelancer/api/project.rb

Instance Method Summary collapse

Instance Method Details

#post_public_project_message(*args) ⇒ Object

Post a public message for a project

Valid parameters are:

- project_id: the id of the project to post the message to
- message: the message to post


134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/freelancer/api/project.rb', line 134

def post_public_project_message(*args)

  params = extract_params(args)

  # Execute the service call
  result = api_get("/Project/postPublicMessage.json", build_api_params({
    :projectid => params[:project_id],
    :messagetext => params[:message]
  }))

  # Parse and return the response
  ::Freelancer::Models::StatusConfirmation.parse(result, :shift => :"json-result")
  
end

#project_bids(*args) ⇒ Object

Retrieve the bids for a project

Valid parameters are:

- project_id: the id of the project to retrieve bids for


89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/freelancer/api/project.rb', line 89

def project_bids(*args)

  params = extract_params(args)

  # Execute the service call
  result = api_get("/Project/getBidsDetails.json", build_api_params({
    :projectid => params[:project_id]
  }))

  # Parse and return the response
  ::Freelancer::Models::Bid.parse_collection(result, :shift => [ :"json-result", :items ])
  
end

#project_budgetsObject

Retrieve the project budget configurations



122
123
124
125
126
127
# File 'lib/freelancer/api/project.rb', line 122

def project_budgets

  result = api_get("/Project/getProjectBudgetConfig.json")
  ::Freelancer::Models::ProjectBudget.parse_collection(result, :shift => [ :"json-result", :items ])
  
end

#project_details(*args) ⇒ Object

Retrieve information about a project

Valid parameters are:

- project_id: the id of the project to retrieve


71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/freelancer/api/project.rb', line 71

def project_details(*args)

  params = extract_params(args)

  # Execute the service call
  result = api_get("/Project/getProjectDetails.json", build_api_params({
    :projectid => params[:project_id]
  }))

  # Parse and return the response
  ::Freelancer::Models::Project.parse(result, :shift => :"json-result")
  
end

#project_feesObject

Retrieve the available project type fees



60
61
62
63
64
65
# File 'lib/freelancer/api/project.rb', line 60

def project_fees

  result = api_get("/Project/getProjectFees.json")
  ::Freelancer::Models::ProjectFee.parse_collection(result, :shift => [ :"json-result", :items ])

end

#project_search(*args) ⇒ Object

Search for projects using a specified set of criterias.

Valid parameters are:

- featured: if only featured projects should be returned
- non_public: if only non-public projects should be returned
- keyword: the keyword to use for searching
- job: a specific job type, or an array of job types, to search for
- status: the project status to filter projects by
- minimum_budget: the minimum budget to return projects by
- maximum_budget: the maximum budget to return projects by
- full_time: if only full time projects should be returned
- trial: if only trial projects should be returned
- gold_members_only: if only gold member only-projects should be returned
- duration: the bid end duration for the project (submitdate (default), bid_enddate, id or state)
- count: the number of results to return (defaults to 50)
- page: the page to retrieve (defaults to 0)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/freelancer/api/project.rb', line 22

def project_search(*args)

  params = extract_params(args)

  # Handle the job attribute, make sure it's an array and not set to nil to
  # simplify the handling below.
  params[:job] ||= []
  params[:job] = params[:job].to_a unless params[:job].is_a?(Array)

  # Delete some boolean data from the params if the values are set to fault,
  # since that's the default already
  [ :featured, :non_public, :full_time, :trial, :gold_members_only ].each do |k|
    params.delete(k) if params.key?(k) && params[k] == false
  end

  # Execute the service call
  result = api_get("/Project/searchProjects.json", build_api_params({
    :isfeatured => params[:featured],
    :isnonpublic => params[:non_public],
    :searchkeyword => params[:keyword],
    :searchjobtypecsv => params[:job].join(","),
    :status => params[:status],
    :budgetmin => params[:minimum_budget],
    :budgetmax => params[:maximum_budget],
    :isfulltime => params[:full_time],
    :istrial => params[:trial],
    :isgoldmembersonly => params[:gold_members_only],
    :bidendsduration => params[:duration],
    :count => params[:count],
    :page => params[:page]
  }))

  # Parse and return the response
  ::Freelancer::Models::Project.parse_collection(result, :shift => [ :"json-result", :items ])
  
end

#public_messages(*args) ⇒ Object

Retrieve the public messages for a project

Valid parameters are:

- project_id: the id of the project to retrieve bids for


107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/freelancer/api/project.rb', line 107

def public_messages(*args)

  params = extract_params(args)

  # Execute the service call
  result = api_get("/Project/getPublicMessages.json", build_api_params({
    :projectid => params[:project_id]
  }))

  # Parse and return the response
  ::Freelancer::Models::Message.parse_collection(result, :shift => [ :"json-result", :items ])

end