Selaa lähdekoodia

API now exposes functions that return JSON values

jherve 1 vuosi sitten
vanhempi
commit
124de9f91a
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7 1
      src/LinkedIn.purs

+ 7 - 1
src/LinkedIn.purs

@@ -1,4 +1,4 @@
-module LinkedIn (APIError(..), encodeToJson, getContext, extractFromDocument, forceExtract) where
+module LinkedIn (APIError(..), encodeToJson, getContext, getContextJson, extractFromDocument, extractFromDocumentJson, forceExtract) where
 
 import Prelude
 
@@ -37,6 +37,9 @@ instance EncodeJson APIError where
 getContext ∷ Document → Effect (Either APIError PageUrl)
 getContext = runExceptT <<< getContext'
 
+getContextJson ∷ Document → Effect Json
+getContextJson d = getContext d >>= (pure <<< encodeJson)
+
 getContext' ∷ Document → ExceptT APIError Effect PageUrl
 getContext' dom = do
   u <- lift $ url dom
@@ -49,6 +52,9 @@ getContext' dom = do
 extractFromDocument :: Document -> Effect (Either APIError Output)
 extractFromDocument = runExceptT <<< extractFromDocument'
 
+extractFromDocumentJson ∷ Document → Effect Json
+extractFromDocumentJson d = extractFromDocument d >>= (pure <<< encodeJson)
+
 extractFromDocument' ∷ Document → ExceptT APIError Effect Output
 extractFromDocument' dom = do
   ctx <- getContext' dom