Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
crawlers
hal
Commits
c72b9184
Commit
c72b9184
authored
Mar 07, 2019
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] Done sort & fl
parent
2b64e9d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
Main.hs
app/Main.hs
+3
-1
Client.hs
src/HAL/Client.hs
+19
-8
No files found.
app/Main.hs
View file @
c72b9184
{-# LANGUAGE OverloadedStrings #-}
module
Main
where
import
Network.HTTP.Client
(
newManager
)
...
...
@@ -10,7 +12,7 @@ main :: IO ()
main
=
do
manager'
<-
newManager
tlsManagerSettings
res
<-
runClientM
(
fl
Nothing
)
(
search
[
"docid"
]
.
Just
$
Desc
"docid"
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.archives-ouvertes.fr"
443
""
)
case
res
of
(
Left
err
)
->
print
err
...
...
src/HAL/Client.hs
View file @
c72b9184
...
...
@@ -13,6 +13,23 @@ import Data.Text
import
Data.Map
import
Data.Aeson
type
HALAPI
=
Search
type
Search
=
"search"
-- fl determine which fields will be returned it can be a list of fields or *
:>
QueryParams
"fl"
Text
-- preatty much clear, (Asc || Desc) + field you want to sort by
:>
QueryParam
"sort"
SortField
:>
Get
'[
J
SON
]
Response
-- Get's argument type
data
SortField
=
Asc
Text
|
Desc
Text
deriving
(
Show
)
instance
ToHttpApiData
SortField
where
toUrlPiece
(
Asc
t
)
=
t
<>
" asc"
toUrlPiece
(
Desc
t
)
=
t
<>
" desc"
-- Response type
data
Response
=
Response
{
numFound
::
Integer
,
...
...
@@ -30,14 +47,8 @@ newtype Doc = Doc (Map Text Value)
deriving
(
Show
,
Generic
)
instance
FromJSON
Doc
type
HALAPI
=
Search
type
Search
=
"search"
-- fl determine which fields will be returned it can be a list of fields or *
:>
QueryParam
"fl"
Text
:>
Get
'[
J
SON
]
Response
halAPI
::
Proxy
HALAPI
halAPI
=
Proxy
fl
::
Maybe
Text
->
ClientM
Response
fl
=
client
halAPI
search
::
[
Text
]
->
Maybe
SortField
->
ClientM
Response
search
=
client
halAPI
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment