Class: Sovren::Client
- Inherits:
-
Object
- Object
- Sovren::Client
- Defined in:
- lib/sovren/client.rb
Instance Method Summary collapse
- #all ⇒ Object
- #educations ⇒ Object
- #employments ⇒ Object
-
#initialize(file, options = {}) ⇒ Client
constructor
A new instance of Client.
- #internships ⇒ Object
- #positions(type) ⇒ Object
- #to_xml ⇒ Object
- #user_info ⇒ Object
Constructor Details
#initialize(file, options = {}) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sovren/client.rb', line 3 def initialize file, ={} @client = Savon.client(wsdl:"https://services.resumeparsing.com/ParsingService.asmx?WSDL", :log => false) @response = @client.call(:parse_resume, message: { "request" => { "AccountId" => Sovren.configuration.account_id, "ServiceKey" => Sovren.configuration.service_key, "FileBytes" => Base64.encode64(file.read), "OutputHtml" => true, "Configuration" => nil, "RevisionDate" => nil, } }) @result = @response.to_hash[:parse_resume_response][:parse_resume_result] @doc = Nokogiri::XML(@result[:xml]).remove_namespaces! end |
Instance Method Details
#all ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/sovren/client.rb', line 20 def all { user: user_info, educations: educations, internships: internships, employments: employments, } end |
#educations ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sovren/client.rb', line 56 def educations @doc.css('SchoolOrInstitution').map do |edu| { degreeType: edu.at_css('Degree').attr('degreeType'), degree: edu.at_css('Degree DegreeName'), started_on: edu.at_css('Degree DatesOfAttendance StartDate AnyDate'), ended_on: edu.at_css('Degree DatesOfAttendance EndDate AnyDate'), major: edu.at_css('Degree DegreeMajor'), minor: edu.at_css('Degree DegreeMinor'), name: edu.at_css('School SchoolName') } end.map do |hsh| format_hash hsh end end |
#employments ⇒ Object
76 77 78 |
# File 'lib/sovren/client.rb', line 76 def employments positions 'directHire' end |
#internships ⇒ Object
72 73 74 |
# File 'lib/sovren/client.rb', line 72 def internships positions 'internship' end |
#positions(type) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/sovren/client.rb', line 80 def positions type @doc.css('PositionHistory').select do |emp| emp.attr('positionType') == type end.map do |emp| { "company": emp.at_css('OrgName OrganizationName'), "description": emp.at_css('Description'), "ended_on": emp.at_css('EndDate AnyDate'), "started_on": emp.at_css('StartDate AnyDate'), "title": emp.at_css('Title'), "current_employer": emp.attr('currentEmployer') == 'true' ? true : false, } end.map do |hsh| format_hash hsh end end |
#to_xml ⇒ Object
97 98 99 |
# File 'lib/sovren/client.rb', line 97 def to_xml @result[:xml] end |
#user_info ⇒ Object
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 |
# File 'lib/sovren/client.rb', line 29 def user_info majors = {} educations.each do |edu| type = edu[:degreeType] major = edu[:major] if type && major if majors[type] majors[type] << major else majors[type] = [major] end end end hsh = { first_name: @doc.at_css('PersonName GivenName'), last_name: @doc.at_css('PersonName FamilyName'), name: @doc.at_css('PersonName FormattedName'), phone: @doc.at_css('Telephone FormattedNumber') || @doc.at_css('Mobile FormattedNumber'), email: @doc.at_css('InternetEmailAddress'), majors: majors } format_hash hsh end |