1{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE RecordWildCards #-}
4
5{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
7
8module Compare.BufferBuilder () where
9
10import Prelude.Compat hiding ((<>))
11
12import Data.BufferBuilder.Json
13import Data.Int (Int64)
14import Data.Monoid ((<>))
15import Twitter
16import qualified Data.BufferBuilder.Utf8 as UB
17
18instance (ToJson a, ToJson b) => ToJson (a,b) where
19  toJson (a,b) = array [toJson a, toJson b]
20
21instance ToJson Int64 where
22    toJson a = unsafeValueUtf8Builder $
23               UB.appendDecimalSignedInt (fromIntegral a)
24    {-# INLINE toJson #-}
25
26instance ToJson Metadata where
27  toJson Metadata{..} = toJson $
28    "result_type" .= result_type
29
30instance ToJson Geo where
31  toJson Geo{..} = toJson $
32       "type_"       .= type_
33    <> "coordinates" .= coordinates
34
35instance ToJson Story where
36  toJson Story{..} = toJson $
37       "from_user_id_str"  .= from_user_id_str
38    <> "profile_image_url" .= profile_image_url
39    <> "created_at"        .= created_at
40    <> "from_user"         .= from_user
41    <> "id_str"            .= id_str
42    <> "metadata"          .= metadata
43    <> "to_user_id"        .= to_user_id
44    <> "text"              .= text
45    <> "id"                .= id_
46    <> "from_user_id"      .= from_user_id
47    <> "geo"               .= geo
48    <> "iso_language_code" .= iso_language_code
49    <> "to_user_id_str"    .= to_user_id_str
50    <> "source"            .= source
51
52instance ToJson Result where
53  toJson Result{..} = toJson $
54       "results" .= results
55    <> "max_id" .= max_id
56    <> "since_id" .= since_id
57    <> "refresh_url" .= refresh_url
58    <> "next_page" .= next_page
59    <> "results_per_page" .= results_per_page
60    <> "page" .= page
61    <> "completed_in" .= completed_in
62    <> "since_id_str" .= since_id_str
63    <> "max_id_str" .= max_id_str
64    <> "query" .= query
65