B:BD[
6.3943] → [
2.12805:12931]
updateCache (CreateSubscription _ _) = error "Not implemented"
updateCache (CreatePaymentRequest _) = error "Not implemented"
updateCache dbop @ (CreateSubscription uid bid) = do
eventId <- requireEventId dbop
pinsert BI.SubscriptionId
"INSERT INTO subscriptions \
\(user_id, billable_id, event_id) \
\VALUES (?, ?, ?) RETURNING id"
(uid ^. _UserId, bid ^. BI._BillableId, eventId ^. _EventId)
updateCache dbop @ (CreatePaymentRequest req) = do
eventId <- requireEventId dbop
pinsert PaymentRequestId
"INSERT INTO payment_requests \
\(subscription_id, event_id, request_data) \
\VALUES (?, ?, ?) RETURNING id"
( req ^. (subscription . BI._SubscriptionId)
, eventId ^. _EventId
, req ^. (paymentRequest . to (runPut . encodeMessage))
)