Add billing create API call.
[?]
Feb 2, 2021, 4:55 AM
27H4DECZW4CEDSV5XYJQA5HOMUW73K5G2DBQNLQB7AFZXXVXCFCACDependencies
- [2]
VTZT2ILUWire up billing navigation. - [3]
IPG33FAWAdd billing daemon - [4]
IR75ZMX3Return actual events for interval ends, not just timestamps. - [5]
ANDJ6GEYAdd billing component skeleton.
Change contents
- replacement in client/src/Aftok/Api/Billing.purs at line 4
import Control.Monad.Except.Trans (ExceptT, runExceptT)import Control.Monad.Error.Class (throwError)import Control.Monad.Except.Trans (runExceptT, except, withExceptT) - replacement in client/src/Aftok/Api/Billing.purs at line 8
-- import Data.Argonaut.Core (Json)import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:))import Data.Argonaut.Core (Json)import Data.Argonaut.Decode (class DecodeJson, decodeJson)import Data.Argonaut.Encode (encodeJson)import Data.BigInt (toNumber) - replacement in client/src/Aftok/Api/Billing.purs at line 19
import Data.Maybe (Maybe)import Data.Maybe (Maybe(..)) - replacement in client/src/Aftok/Api/Billing.purs at line 23
import Data.Tuple (Tuple(..))import Data.Tuple (Tuple) - replacement in client/src/Aftok/Api/Billing.purs at line 30
-- import Affjax (get)-- import Affjax.ResponseFormat as RFimport Affjax (post, printError)import Affjax.RequestBody as RBimport Affjax.ResponseFormat as RFimport Affjax.StatusCode (StatusCode(..)) - replacement in client/src/Aftok/Api/Billing.purs at line 35
( ProjectId )( ProjectId, pidStr ) - replacement in client/src/Aftok/Api/Billing.purs at line 67
newtype Billable' t = BillablerecurrenceJSON :: Recurrence -> JsonrecurrenceJSON = case _ ofAnnually -> encodeJson $ { annually: {} }Monthly i -> encodeJson $ { monthly: i }Weekly i -> encodeJson $ { weekly: i }OneTime -> encodeJson $ { onetime: {} }type Billable = - edit in client/src/Aftok/Api/Billing.purs at line 77
, message :: String - replacement in client/src/Aftok/Api/Billing.purs at line 84
type Billable = Billable' DateTimebillableJSON :: Billable -> JsonbillableJSON b = encodeJson ${ name: b.name, description: b.description, message: b.message, recurrence: recurrenceJSON b.recurrence, currency: "ZEC", amount: toNumber (unwrap b.amount)} - replacement in client/src/Aftok/Api/Billing.purs at line 116
createBillable pid bid = pure $ Left ForbiddencreateBillable pid billable = dolet body = RB.json $ billableJSON billableresponse <- post RF.json ("/api/projects/" <> pidStr pid <> "/billables") (Just body)runExceptT $ case response ofLeft err -> throwError $ Error { status: Nothing, message: printError err }Right r -> case r.status ofStatusCode 403 -> throwError $ ForbiddenStatusCode 200 -> withExceptT (ParseFailure r.body) <<< except $ decodeJson r.bodyother -> throwError $ Error { status: Just other, message: r.statusText } - replacement in client/src/Aftok/Zcash.purs at line 3
newtype Zatoshi = Zatoshi Int[2.656]import Preludeimport Data.Newtype (class Newtype)import Data.BigInt (BigInt)import Data.Fixed (Fixed, P1000000, TenTimes)newtype Zatoshi = Zatoshi (BigInt)derive instance zatoshiEq :: Eq Zatoshiderive instance zatoshiOrd :: Ord Zatoshiderive instance zatoshiNewtype :: Newtype Zatoshi _type ZPrec = TenTimes (TenTimes P1000000)newtype ZEC = ZEC (Fixed ZPrec)derive instance zecEq :: Eq ZECderive instance zecOrd :: Ord ZECderive instance zecNewtype :: Newtype ZEC _ - replacement in server/Aftok/Snaplet/Billing.hs at line 104
parseOneTime o' = const (pure B.OneTime) <$> O.lookup "one-time" o'parseOneTime o' = const (pure B.OneTime) <$> O.lookup "onetime" o'