Skip to content

Instantly share code, notes, and snippets.

@roberthopman
Created January 4, 2017 20:20
Show Gist options
  • Save roberthopman/13b04378e87acae93ea7842a8f98f5e9 to your computer and use it in GitHub Desktop.
Save roberthopman/13b04378e87acae93ea7842a8f98f5e9 to your computer and use it in GitHub Desktop.
require 'pp'
require 'upwork/api'
# require 'upwork/api/routers/auth'
# require 'upwork/api/routers/organization/users'
require 'upwork/api/routers/jobs/search'
# step 1
config = Upwork::Api::Config.new({
'consumer_key' => 'x',
'consumer_secret' => 'x',
})
# step 2
# setup client
client = Upwork::Api::Client.new(config)
authz_url = client.get_authorization_url
puts "Visit the authorization url and enter the oauth_verifier for further authorization:"
puts authz_url
verifier = gets.strip
puts "\n"
# step 3
access_token = client.get_access_token(verifier)
#shows the content of the access_token
# puts access_token.inspect
# puts "\n"
# show info about authenticated user:
# auth = Upwork::Api::Routers::Auth.new(client)
# auth.get_user_info
# user = auth.get_user_info
# puts user
# puts "\n"
# if organization has > 1 user:
# users = Upwork::Api::Routers::Organization::Users.new(client)
# users.get_my_info
#
# user = users.get_my_info
# puts user
# puts "\n"
# prints jobs with q as query
jobs = Upwork::Api::Routers::Jobs::Search.new(client)
params = {
'q' => 'RoR',
}
jobs.find(params)
job_results = jobs.find(params)
pp job_results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment