OK, thank you,
here what I ended with :
data BatchUpdateCommand = BatchUpdateCommand SpreadsheetId
instance ToHttpApiData BatchUpdateCommand where
toUrlPiece (BUC sid) = pack sid <> ":batchUpdate"
type API = "spreadsheets"
:> Capture "spreadsheetId" BatchUpdateCommand
:> ReqBody '[JSON] BatchUpdate
:> Post '[JSON] BatchUpdateResult
batchUpdate' :: BatchUpdateCommand -> BatchUpdate -> ClientM BatchUpdateResult
batchUpdate' = client api
batchUpdate :: SpreadsheetId -> BatchUpdate -> ClientM BatchUpdateResult
batchUpdate sid = batchUpdate' (BUC sid)
Le lundi 22 mai 2017 10:23:39 UTC+2, Alp Mestanogullari a écrit :
Hello Frédéric,
I would probably pick the second option, it's the simplest one by far and will get the job done without (to me) feeling like a hack. In case you need to support different "keywords" (i.e not just `batchUpdate`), you could even have something like:
newtype Spreadsheet (action :: Symbol) a = Spreadsheet a
where the 'action' bit would be "batchUpdate" or any other string that you need it to be. This might be overkill for now though if you only need to handle "batchUpdate". Then the logic of extracting the spreadsheetId and checking that it is followed by ":batchUpdate" or more generally by ":" and the keyword specified by "action" with my newtype above, could all be handled as part of the instance for
FromHttpApiData
Hi guys,
I'm writing a client to some Google APIs, including Google Sheets API.
This action here is causing me some troubles:
As you can see, they capture the id of the object in the URL as usual, but the custom action batchUpdate is specified after a semi-colon that I can't modelize properly with the :> combinator.
As was thinking of either :
- writing my custom variant of the :> for this case
- write a custom type to wrap the id and let it be suffixed by some keyword, in this case ':batchUpdate'
Do you have any advice ?
Frédéric
--
You received this message because you are subscribed to the Google Groups "haskell-servant" group.