Explorar o código

API now exposes functions that return JSON values

jherve hai 1 ano
pai
achega
124de9f91a
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  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