on develop help sign in
Adding GoogleAuth and Download instances
ec605e4Brendan Hay
gen/src/Gen/AST/Render.hs+2−1
@@ -124,10 +124,11 @@ renderMethod s root suf m@Method {..} = do
124 x@Solved {..} <- getSolved typ
124 x@Solved {..} <- getSolved typ
125 Just d <- renderSchema x
125 Just d <- renderSchema x
126
126
127+ a <- pp Print $ authDecl _unique _prefix (props _schema)
127 i <- pp Print $ requestDecl _unique _prefix alias url (props _schema) m
128 i <- pp Print $ requestDecl _unique _prefix alias url (props _schema) m
128 dl <- pp Print $ downloadDecl _unique _prefix alias url (props _schema) m
129 dl <- pp Print $ downloadDecl _unique _prefix alias url (props _schema) m
129
130
130− let is = i : [dl | _mSupportsMediaDownload]
131+ let is = a : i : [dl | _mSupportsMediaDownload]
131
132
132 Action _mId _unique (root <> mkNS ns) _mDescription alias
133 Action _mId _unique (root <> mkNS ns) _mDescription alias
133 <$> pp Print (verbAlias alias m)
134 <$> pp Print (verbAlias alias m)
gen/src/Gen/Syntax.hs+10
@@ -194,6 +194,16 @@ googleRequestDecl g n assoc alt p api url fs m =
194 pats = [pvar "r", pvar "u", prec]
194 pats = [pvar "r", pvar "u", prec]
195 prec = PRec (UnQual (dname g)) [PFieldWildcard]
195 prec = PRec (UnQual (dname g)) [PFieldWildcard]
196
196
197+authDecl :: Global -> Prefix -> [Local] -> Decl
198+authDecl g p fs = InstDecl noLoc Nothing [] [] (unqual "GoogleAuth") [tycon g]
199+ [ method "authKey" "key"
200+ , method "authToken" "oauth_token"
201+ ]
202+ where
203+ method l f
204+ | f `elem` fs = funD l (var (lname p f))
205+ | otherwise = funD l (app (var "const") (var "pure"))
206+
197jsonDecls :: Global -> Prefix -> Map Local Solved -> [Decl]
207jsonDecls :: Global -> Prefix -> Map Local Solved -> [Decl]
198jsonDecls g p (Map.toList -> rs) = [from, to]
208jsonDecls g p (Map.toList -> rs) = [from, to]
199 where
209 where