Created
July 31, 2018 02:25
-
-
Save Woody88/dca0f790f26e102b92f98f00303f6211 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.mkClient = function(){ | |
| var jsforce = require('jsforce'); | |
| return new jsforce.Client(); | |
| } | |
| exports.getConnection = function(client, loginProps, connectionCancel, connectionError, left, right){ | |
| return function(onError, onSuccess) { | |
| function loginHandler(err, result){ | |
| if (err != null) | |
| return left( connectionError( err.message ) ); | |
| if (result === 'cancel') | |
| return left( connectionCancel ); | |
| if (result === 'connect') | |
| return right( right( client ) ); | |
| } | |
| client.login(loginProps, loginHandler); | |
| return function(cancelError, onCancelerError, onCancelerSuccess) { | |
| onCancelerSuccess(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Client where | |
| import Data.Either (Either(..)) | |
| import Data.Function.Uncurried | |
| import Effect.Aff.Compat | |
| import Types | |
| data ConnectionError = ConnectionCancel | ConnectionError String | |
| type BrowserProps | |
| = { width :: Int | |
| , height :: Int | |
| } | |
| type LoginProps | |
| = { browserProps :: BrowserProps | |
| , scope :: Int | |
| } | |
| foreign import mkClient :: Client | |
| foreign import getConnection :: Fn6 Client LoginProps ConnectionError (String -> ConnectionError) (ConnectionError -> Either ConnectionError Connection) (Connection -> Either ConnectionError Connection) (EffectFnAff (Either ConnectionError Connection)) -> EffectFnAff (Either ConnectionError Connection) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment