forked from haskell-github/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch.hs
More file actions
51 lines (43 loc) · 1.43 KB
/
Search.hs
File metadata and controls
51 lines (43 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-----------------------------------------------------------------------------
-- |
-- License : BSD-3-Clause
-- Maintainer : Oleg Grenrus <oleg.grenrus@iki.fi>
--
module GitHub.Data.Search where
import GitHub.Data.Repos (Repo)
import GitHub.Data.URL (URL)
import GitHub.Internal.Prelude
import Prelude ()
import qualified Data.Vector as V
data SearchResult entity = SearchResult
{ searchResultTotalCount :: !Int
, searchResultResults :: !(Vector entity)
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData entity => NFData (SearchResult entity) where rnf = genericRnf
instance Binary entity => Binary (SearchResult entity)
instance FromJSON entity => FromJSON (SearchResult entity) where
parseJSON = withObject "SearchResult" $ \o -> SearchResult
<$> o .: "total_count"
<*> o .:? "items" .!= V.empty
data Code = Code
{ codeName :: !Text
, codePath :: !Text
, codeSha :: !Text
, codeUrl :: !URL
, codeGitUrl :: !URL
, codeHtmlUrl :: !URL
, codeRepo :: !Repo
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData Code where rnf = genericRnf
instance Binary Code
instance FromJSON Code where
parseJSON = withObject "Code" $ \o -> Code
<$> o .: "name"
<*> o .: "path"
<*> o .: "sha"
<*> o .: "url"
<*> o .: "git_url"
<*> o .: "html_url"
<*> o .: "repository"