class Linkedin2CV::Converter
Constants
- API_KEY
- API_SECRET
Public Class Methods
new(token = nil)
click to toggle source
# File lib/linkedin2cv/converter.rb, line 20 def initialize(token = nil) @display_fields = ["company", "publication", "patent", "language", "skills", "certification", "education", "course", "volunteer", "recommendations"] @profile_fields = ["projects:(start-date,end-date,description,id,name,url),main-address,phone-numbers,email-address,first-name,last-name,maiden-name,formatted-name,phonetic-first-name,phonetic-last-name,formatted-phonetic-name,headline,location:(name,country:(code)),industry,current-status,current-share,num-connections,num-connections-capped,summary,specialties,positions,picture-url,api-standard-profile-request:(url,headers),public-profile-url,last-modified-timestamp,proposal-comments,associations,interests,publications:(id,title,publisher:(name),authors:(id,name,person),date,url,summary),patents,languages:(id,language:(name),proficiency:(level,name)),skills:(id,skill:(name)),certifications:(id,name,authority:(name),number,start-date,end-date),educations:(id,school-name,field-of-study,start-date,end-date,degree,activities,notes),courses:(id,name,number),three-current-positions:(id,title,summary,start-date,end-date,is-current,company),three-past-positions:(id,title,summary,start-date,end-date,is-current,company),num-recommenders,recommendations-received:(id,recommendation-type,recommendation-text,recommender),mfeed-rss-url,following,job-bookmarks,suggestions,date-of-birth,member-url-resources:(url,name),related-profile-views,honors-awards"] @token = token # Confirm API keys setup raise StandardError, "API_KEY not set" unless !API_KEY.nil? raise StandardError, "API_SECRET not set" unless !API_SECRET.nil? # Setup default options to be merged with supplied ones end
Public Instance Methods
auth()
click to toggle source
Public: Authenticate & Authorize the end user (via OAuth2) and fetch access token
# File lib/linkedin2cv/converter.rb, line 58 def auth if @token.nil? # If in CLI Mode, spawn a thread, run the API and open a browser window thread = nil if !File.exists?('.token') auth_thread = prompt_user_authorisation puts "Waiting to retrieve LinkedIn OAuth token" sleep 1 until auth_thread.thread_variable?('access_token') end # Get Token from environment @token = fetch_token_from_tempfile puts "I have a token for you: #{@token}" end @token end
create_resume(options = {})
click to toggle source
Public: Create a resume given a LinkedIn Profile
Takes
# File lib/linkedin2cv/converter.rb, line 36 def create_resume(options = {}) # Get Profile profile = get_profile # Find stylist (LaTeX / Asciidoc etc.) # Find output factory/plugin (fetch from Github?) case options['format'] when 'latex' require 'linkedin2cv/renderer/latex_renderer' # Currently only supports one LaTeX template renderer = Linkedin2CV::LatexRenderer.new renderer.render(profile, options) else puts "Sorry mate, I don't yet support the '#{options['format']}' format'" end end
fetch_token_from_tempfile()
click to toggle source
Public: Fetch the token from a temporary oauth token file.
# File lib/linkedin2cv/converter.rb, line 112 def fetch_token_from_tempfile # Store in env for command line! file = File.new('.token', 'r') token = file.read file.close token end
get_profile()
click to toggle source
Public: Fetch Profile Data
# File lib/linkedin2cv/converter.rb, line 81 def get_profile # Auth token = auth # Get Client info based on fields provided client = LinkedIn::Client.new(API_KEY, API_SECRET, token) client.profile(:fields => @profile_fields) end