27H4DECZW4CEDSV5XYJQA5HOMUW73K5G2DBQNLQB7AFZXXVXCFCAC
newtype Billable' t = Billable
recurrenceJSON :: Recurrence -> Json
recurrenceJSON = case _ of
Annually -> encodeJson $ { annually: {} }
Monthly i -> encodeJson $ { monthly: i }
Weekly i -> encodeJson $ { weekly: i }
OneTime -> encodeJson $ { onetime: {} }
type Billable =
type Billable = Billable' DateTime
billableJSON :: Billable -> Json
billableJSON b = encodeJson $
{ name: b.name
, description: b.description
, message: b.message
, recurrence: recurrenceJSON b.recurrence
, currency: "ZEC"
, amount: toNumber (unwrap b.amount)
}
createBillable pid bid = pure $ Left Forbidden
createBillable pid billable = do
let body = RB.json $ billableJSON billable
response <- post RF.json ("/api/projects/" <> pidStr pid <> "/billables") (Just body)
runExceptT $ case response of
Left err -> throwError $ Error { status: Nothing, message: printError err }
Right r -> case r.status of
StatusCode 403 -> throwError $ Forbidden
StatusCode 200 -> withExceptT (ParseFailure r.body) <<< except $ decodeJson r.body
other -> throwError $ Error { status: Just other, message: r.statusText }
newtype Zatoshi = Zatoshi Int
import Prelude
import Data.Newtype (class Newtype)
import Data.BigInt (BigInt)
import Data.Fixed (Fixed, P1000000, TenTimes)
newtype Zatoshi = Zatoshi (BigInt)
derive instance zatoshiEq :: Eq Zatoshi
derive instance zatoshiOrd :: Ord Zatoshi
derive instance zatoshiNewtype :: Newtype Zatoshi _
type ZPrec = TenTimes (TenTimes P1000000)
newtype ZEC = ZEC (Fixed ZPrec)
derive instance zecEq :: Eq ZEC
derive instance zecOrd :: Ord ZEC
derive instance zecNewtype :: Newtype ZEC _