@@ -26,9 +26,7 @@ module Network.Google.Prelude
26import Control.Applicative as Export (pure, (<$>), (<*>))
26import Control.Applicative as Export (pure, (<$>), (<*>))
27import Control.Lens as Export (Lens', lens, mapping,
27import Control.Lens as Export (Lens', lens, mapping,
28 (^.), _Just)
28 (^.), _Just)
29−import Control.Lens hiding (coerce)
29+import Control.Lens
30−import Control.Monad.Trans.Either as Export (EitherT)
32import Data.Data as Export (Data, Typeable)
30import Data.Data as Export (Data, Typeable)
33import Data.Hashable as Export
31import Data.Hashable as Export
34import Data.Int as Export (Int32, Int64)
32import Data.Int as Export (Int32, Int64)
@@ -41,108 +39,40 @@ import Data.Time as Export
41import Data.Word as Export (Word32, Word64, Word8)
39import Data.Word as Export (Word32, Word64, Word8)
42import GHC.Generics as Export (Generic)
40import GHC.Generics as Export (Generic)
43import GHC.TypeLits
41import GHC.TypeLits
42+import Network.Google.Client as Export
44import Network.Google.Data.JSON as Export
43import Network.Google.Data.JSON as Export
45import Network.Google.Data.Numeric as Export
44import Network.Google.Data.Numeric as Export
46import Network.Google.Data.Time as Export
45import Network.Google.Data.Time as Export
47−-- import Network.HTTP.Media
46+import Network.Google.Types as Export
48import Numeric.Natural as Export (Natural)
47import Numeric.Natural as Export (Natural)
49import Prelude as Export hiding (product)
48import Prelude as Export hiding (product)
50−import Servant.API as Export
49+import Servant.API as Export hiding (getResponse)
51−import Servant.Client as Export
50+-- import Servant.Client as Export
52−import Servant.Common.Req as Export (Req, defReq)
51+-- import Servant.Common.Req as Export (Req, defReq)
53−import Servant.Common.Req (appendToPath)
52+-- import Servant.Common.Req (appendToPath)
54import Servant.Utils.Links as Export hiding (Link)
53import Servant.Utils.Links as Export hiding (Link)
56−_Coerce :: (Coercible a b, Coercible b a) => Iso' a b
55+-- data Body = Body -- MediaType
57−_Coerce = iso coerce coerce
56+-- deriving (Eq, Show, Generic, Data, Typeable)
59−-- | Invalid Iso, exists for ease of composition with the current 'Lens . Iso'
58+-- -- data ReqStream
60−-- chaining to hide internal types from the user.
59+-- -- data ResStream
61−_Default :: Monoid a => Iso' (Maybe a) a
60+-- -- type API = ReqBody '[JSON] Request :> Post '[JSON] Response
62−_Default = iso f Just
61+-- -- type API = MultipartRelated '[JSON] Meta '[JSON] Media :> Post '[JSON] Response
67−data AltJSON = AltJSON
63+-- instance MimeRender OctetStream Body
68− deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
64+-- instance MimeUnrender OctetStream Body
70−instance ToText AltJSON where
66+-- data MultipartRelated (metatypes :: [*]) meta media
71− toText = const "json"
67+-- deriving (Typeable)
73−data AltMedia = AltMedia
69+-- instance (MimeUnrender ct a, HasClient sublayout)
74− deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
70+-- => HasClient (MultipartRelated (ct ': cts) a b :> sublayout) where
76−instance ToText AltMedia where
72+-- type Client (MultipartRelated (ct ': cts) a b :> sublayout) =
77− toText = const "media"
73+-- a -> b -> Client sublayout
79−class GoogleRequest a where
82− requestWithRoute :: Req -> BaseUrl -> a -> EitherT ServantError IO (Rs a)
83− request :: a -> EitherT ServantError IO (Rs a)
85−newtype AuthKey = AuthKey Text
86− deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
88−newtype OAuthToken = OAuthToken Text
89− deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
91−class GoogleAuth a where
92− authKey :: Traversal' a AuthKey
93− authToken :: Traversal' a OAuthToken
94− -- ^ only set if unset semantics?
96−newtype MediaDownload a = MediaDownload a
98−_MediaDownload :: Iso' (MediaDownload a) a
99−_MediaDownload = iso (\(MediaDownload x) -> x) MediaDownload
101−instance GoogleAuth a => GoogleAuth (MediaDownload a) where
102− authKey = _MediaDownload . authKey
103− authToken = _MediaDownload . authToken
105−data Body = Body -- MediaType
106− deriving (Eq, Show, Generic, Data, Typeable)
108−data Captures (capture :: Symbol) a
111−instance (KnownSymbol capture, ToText a, HasClient sublayout)
112− => HasClient (Captures capture a :> sublayout) where
113− type Client (Captures capture a :> sublayout) = [a] -> Client sublayout
115− clientWithRoute Proxy req baseUrl xs =
116− clientWithRoute (Proxy :: Proxy sublayout) (appendToPath vs req) baseUrl
118− vs = Text.unpack $ Text.intercalate "/" (map toText xs)
120−data CaptureMode (capture :: Symbol) (mode :: Symbol) a
123−instance (KnownSymbol capture, KnownSymbol mode, ToText a, HasClient sublayout)
124− => HasClient (CaptureMode capture mode a :> sublayout) where
125− type Client (CaptureMode capture mode a :> sublayout) = a -> Client sublayout
127− clientWithRoute Proxy req baseUrl val =
128− clientWithRoute (Proxy :: Proxy sublayout) (appendToPath p req) baseUrl
130− p = Text.unpack (toText val) <> m
131− m = symbolVal (Proxy :: Proxy mode)
133−instance MimeRender OctetStream Body
134−instance MimeUnrender OctetStream Body
136−data MultipartRelated (metatypes :: [*]) meta media
139−instance (MimeUnrender ct a, HasClient sublayout)
140− => HasClient (MultipartRelated (ct ': cts) a b :> sublayout) where
142− type Client (MultipartRelated (ct ': cts) a b :> sublayout) =
143− a -> b -> Client sublayout
145− clientWithRoute Proxy req baseurl meta media = undefined
75+-- clientWithRoute Proxy req baseurl meta media = undefined
147 -- clientWithRoute (Proxy :: Proxy sublayout)
77 -- clientWithRoute (Proxy :: Proxy sublayout)
148 -- (let ctProxy = Proxy :: Proxy ct
78 -- (let ctProxy = Proxy :: Proxy ct