2014-04-23 14:25:36 -04:00
|
|
|
CocoClass = require 'lib/CocoClass'
|
|
|
|
{me} = require 'lib/auth'
|
|
|
|
{backboneFailure} = require 'lib/errors'
|
|
|
|
storage = require 'lib/storage'
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
|
|
|
|
constructor: ->
|
|
|
|
super()
|
2014-04-25 13:46:43 -04:00
|
|
|
|
2014-04-23 14:25:36 -04:00
|
|
|
subscriptions:
|
2014-04-25 13:46:43 -04:00
|
|
|
'linkedin-loaded': 'onLinkedInLoaded'
|
|
|
|
|
|
|
|
onLinkedInLoaded: (e) ->
|
2014-06-30 22:16:26 -04:00
|
|
|
IN.Event.on IN, 'auth', @onLinkedInAuth
|
2014-04-23 14:25:36 -04:00
|
|
|
|
2014-06-30 22:16:26 -04:00
|
|
|
onLinkedInAuth: (e) => console.log 'Authorized with LinkedIn'
|
2014-04-25 13:46:43 -04:00
|
|
|
|
2014-04-24 20:36:07 -04:00
|
|
|
constructEmployerAgreementObject: (cb) =>
|
2014-06-30 22:16:26 -04:00
|
|
|
IN.API.Profile('me')
|
|
|
|
.fields(['positions', 'public-profile-url', 'id', 'first-name', 'last-name', 'email-address'])
|
2014-04-24 20:36:07 -04:00
|
|
|
.error(cb)
|
|
|
|
.result (profiles) =>
|
|
|
|
cb null, profiles.values[0]
|
2014-06-30 22:16:26 -04:00
|
|
|
|
2014-06-07 14:45:49 -04:00
|
|
|
getProfileData: (cb) =>
|
2014-06-30 22:16:26 -04:00
|
|
|
IN.API.Profile('me')
|
|
|
|
.fields(['formatted-name', 'educations', 'skills', 'headline', 'summary', 'positions', 'public-profile-url'])
|
2014-06-07 14:45:49 -04:00
|
|
|
.error(cb)
|
|
|
|
.result (profiles) =>
|
|
|
|
cb null, profiles.values[0]
|
2014-04-25 13:46:43 -04:00
|
|
|
|
2014-04-23 14:25:36 -04:00
|
|
|
destroy: ->
|
|
|
|
super()
|