RandomDotOrg 0.2.1 → 1.0
raw patch · 20 files changed
+3907/−125 lines, 20 filesdep +RandomDotOrgdep +aesondep +binarydep −HTTP-Simpledep −networkdep ~basesetup-changednew-component:exe:RandomDotOrg-examplenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: RandomDotOrg, aeson, binary, bytestring, http-client, http-client-tls, http-media, servant, servant-client, servant-client-core, servant-jsonrpc, servant-jsonrpc-client, text, time, unordered-containers, uuid-types
Dependencies removed: HTTP-Simple, network
Dependency ranges changed: base
API changes (from Hackage documentation)
- System.Random.Atmosphere: getQuota :: IO (Either String Int)
- System.Random.Atmosphere: getRandomNumbers :: Int -> Int -> Int -> IO (Either String [Int])
- System.Random.Atmosphere: getRandomSequence :: Int -> Int -> IO (Either String [Int])
- System.Random.Atmosphere: getRandomStrings :: Int -> Int -> Bool -> Bool -> Bool -> Bool -> IO (Either String [String])
+ System.Random.Atmospheric.Api: ApiKey :: Key -> ApiKey
+ System.Random.Atmospheric.Api: BTC :: Currency
+ System.Random.Atmospheric.Api: Base64 :: BlobFormat
+ System.Random.Atmospheric.Api: Blob :: ByteString -> Blob
+ System.Random.Atmospheric.Api: Blobs :: SignedRandomResponse [Blob] GenBlobsParams -> GetResultResponse
+ System.Random.Atmospheric.Api: CreateTicketsResponse :: [TicketResponse] -> CreateTicketsResponse
+ System.Random.Atmospheric.Api: CurrencyAmount :: Currency -> Double -> CurrencyAmount
+ System.Random.Atmospheric.Api: DecimalFractions :: SignedRandomResponse [Double] GenDecimalFractionsParams -> GetResultResponse
+ System.Random.Atmospheric.Api: ETH :: Currency
+ System.Random.Atmospheric.Api: EUR :: Currency
+ System.Random.Atmospheric.Api: Fixed :: Int -> Boundary
+ System.Random.Atmospheric.Api: GBP :: Currency
+ System.Random.Atmospheric.Api: Gaussians :: SignedRandomResponse [Double] GenGaussiansParams -> GetResultResponse
+ System.Random.Atmospheric.Api: GenBlobsParams :: ApiKey -> Int -> Int -> BlobFormat -> Maybe Seed -> GenBlobsParams
+ System.Random.Atmospheric.Api: GenDecimalFractionsParams :: ApiKey -> Int -> Int -> Bool -> Maybe Seed -> GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: GenGaussiansParams :: ApiKey -> Int -> Double -> Double -> Int -> Maybe Seed -> GenGaussiansParams
+ System.Random.Atmospheric.Api: GenIntegerSequencesMultiformParams :: ApiKey -> Int -> [Int] -> Boundary -> Boundary -> Bool -> Int -> Maybe Seed -> GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: GenIntegerSequencesParams :: ApiKey -> Int -> Int -> Int -> Int -> Bool -> Int -> Maybe Seed -> GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: GenIntegersParams :: ApiKey -> Int -> Int -> Int -> Bool -> Int -> Maybe Seed -> GenIntegersParams
+ System.Random.Atmospheric.Api: GenStringsParams :: ApiKey -> Int -> Int -> [Char] -> Bool -> Maybe Seed -> GenStringsParams
+ System.Random.Atmospheric.Api: GenUUIDsParams :: ApiKey -> Int -> Maybe Seed -> GenUUIDsParams
+ System.Random.Atmospheric.Api: GenerateSignedBlobs :: Method
+ System.Random.Atmospheric.Api: GenerateSignedDecimalFractions :: Method
+ System.Random.Atmospheric.Api: GenerateSignedGaussians :: Method
+ System.Random.Atmospheric.Api: GenerateSignedIntegerSequences :: Method
+ System.Random.Atmospheric.Api: GenerateSignedIntegers :: Method
+ System.Random.Atmospheric.Api: GenerateSignedStrings :: Method
+ System.Random.Atmospheric.Api: GenerateSignedUUIDs :: Method
+ System.Random.Atmospheric.Api: HashedApiKey :: ByteString -> ApiKey
+ System.Random.Atmospheric.Api: Head :: TicketType
+ System.Random.Atmospheric.Api: Hex :: BlobFormat
+ System.Random.Atmospheric.Api: IntegerSequences :: SignedRandomResponse [[Int]] GenIntegerSequencesParams -> GetResultResponse
+ System.Random.Atmospheric.Api: IntegerSequencesMultiform :: SignedRandomResponse [[Int]] GenIntegerSequencesMultiformParams -> GetResultResponse
+ System.Random.Atmospheric.Api: Integers :: SignedRandomResponse [Int] GenIntegersParams -> GetResultResponse
+ System.Random.Atmospheric.Api: Key :: ByteString -> Key
+ System.Random.Atmospheric.Api: LicenseData :: CurrencyAmount -> LicenseData
+ System.Random.Atmospheric.Api: Multiform :: [Int] -> Boundary
+ System.Random.Atmospheric.Api: RandomResponse :: a -> UTCTime -> Int -> Int -> Int -> Int -> RandomResponse a
+ System.Random.Atmospheric.Api: RevealTicketsResponse :: Int -> RevealTicketsResponse
+ System.Random.Atmospheric.Api: Running :: Status
+ System.Random.Atmospheric.Api: Signature :: ByteString -> Signature
+ System.Random.Atmospheric.Api: SignedRandomResponse :: RandomResponse a -> Method -> b -> Object -> Maybe LicenseData -> Maybe Object -> Maybe TicketData -> Int -> Signature -> CurrencyAmount -> SignedRandomResponse a b
+ System.Random.Atmospheric.Api: Singleton :: TicketType
+ System.Random.Atmospheric.Api: Stopped :: Status
+ System.Random.Atmospheric.Api: Strings :: SignedRandomResponse [Text] GenStringsParams -> GetResultResponse
+ System.Random.Atmospheric.Api: Tail :: TicketType
+ System.Random.Atmospheric.Api: TicketData :: TicketId -> Maybe TicketId -> Maybe TicketId -> TicketData
+ System.Random.Atmospheric.Api: TicketId :: ByteString -> TicketId
+ System.Random.Atmospheric.Api: TicketInfoResponse :: TicketResponse -> ApiKey -> Bool -> Maybe UTCTime -> Maybe UTCTime -> Maybe Int -> TicketInfoResponse
+ System.Random.Atmospheric.Api: TicketResponse :: TicketData -> UTCTime -> TicketResponse
+ System.Random.Atmospheric.Api: USD :: Currency
+ System.Random.Atmospheric.Api: UUIDs :: SignedRandomResponse [UUID] GenUUIDsParams -> GetResultResponse
+ System.Random.Atmospheric.Api: UsageResponse :: Status -> UTCTime -> Int -> Int -> Int -> Int -> UsageResponse
+ System.Random.Atmospheric.Api: VerifySignatureResponse :: Bool -> VerifySignatureResponse
+ System.Random.Atmospheric.Api: [$sel:advisoryDelay:RandomResponse] :: RandomResponse a -> Int
+ System.Random.Atmospheric.Api: [$sel:bitsLeft:RandomResponse] :: RandomResponse a -> Int
+ System.Random.Atmospheric.Api: [$sel:bitsUsed:RandomResponse] :: RandomResponse a -> Int
+ System.Random.Atmospheric.Api: [$sel:ca_amount:CurrencyAmount] :: CurrencyAmount -> Double
+ System.Random.Atmospheric.Api: [$sel:ca_currency:CurrencyAmount] :: CurrencyAmount -> Currency
+ System.Random.Atmospheric.Api: [$sel:completionTime:RandomResponse] :: RandomResponse a -> UTCTime
+ System.Random.Atmospheric.Api: [$sel:cost:SignedRandomResponse] :: SignedRandomResponse a b -> CurrencyAmount
+ System.Random.Atmospheric.Api: [$sel:gbp_apiKey:GenBlobsParams] :: GenBlobsParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gbp_format:GenBlobsParams] :: GenBlobsParams -> BlobFormat
+ System.Random.Atmospheric.Api: [$sel:gbp_n:GenBlobsParams] :: GenBlobsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gbp_pregeneratedRandomization:GenBlobsParams] :: GenBlobsParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gbp_size:GenBlobsParams] :: GenBlobsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gdfp_apiKey:GenDecimalFractionsParams] :: GenDecimalFractionsParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gdfp_decimalPlaces:GenDecimalFractionsParams] :: GenDecimalFractionsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gdfp_n:GenDecimalFractionsParams] :: GenDecimalFractionsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gdfp_pregeneratedRandomization:GenDecimalFractionsParams] :: GenDecimalFractionsParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gdfp_replacement:GenDecimalFractionsParams] :: GenDecimalFractionsParams -> Bool
+ System.Random.Atmospheric.Api: [$sel:ggp_apiKey:GenGaussiansParams] :: GenGaussiansParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:ggp_mean:GenGaussiansParams] :: GenGaussiansParams -> Double
+ System.Random.Atmospheric.Api: [$sel:ggp_n:GenGaussiansParams] :: GenGaussiansParams -> Int
+ System.Random.Atmospheric.Api: [$sel:ggp_pregeneratedRandomization:GenGaussiansParams] :: GenGaussiansParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:ggp_significantDigits:GenGaussiansParams] :: GenGaussiansParams -> Int
+ System.Random.Atmospheric.Api: [$sel:ggp_standardDeviation:GenGaussiansParams] :: GenGaussiansParams -> Double
+ System.Random.Atmospheric.Api: [$sel:gip_apiKey:GenIntegersParams] :: GenIntegersParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gip_base:GenIntegersParams] :: GenIntegersParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gip_max:GenIntegersParams] :: GenIntegersParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gip_min:GenIntegersParams] :: GenIntegersParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gip_n:GenIntegersParams] :: GenIntegersParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gip_pregeneratedRandomization:GenIntegersParams] :: GenIntegersParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gip_replacement:GenIntegersParams] :: GenIntegersParams -> Bool
+ System.Random.Atmospheric.Api: [$sel:gismp_apiKey:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gismp_base:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gismp_length:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> [Int]
+ System.Random.Atmospheric.Api: [$sel:gismp_max:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Boundary
+ System.Random.Atmospheric.Api: [$sel:gismp_min:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Boundary
+ System.Random.Atmospheric.Api: [$sel:gismp_n:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gismp_pregeneratedRandomization:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gismp_replacement:GenIntegerSequencesMultiformParams] :: GenIntegerSequencesMultiformParams -> Bool
+ System.Random.Atmospheric.Api: [$sel:gisp_apiKey:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gisp_base:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gisp_length:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gisp_max:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gisp_min:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gisp_n:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gisp_pregeneratedRandomization:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gisp_replacement:GenIntegerSequencesParams] :: GenIntegerSequencesParams -> Bool
+ System.Random.Atmospheric.Api: [$sel:gsp_apiKey:GenStringsParams] :: GenStringsParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gsp_characters:GenStringsParams] :: GenStringsParams -> [Char]
+ System.Random.Atmospheric.Api: [$sel:gsp_length:GenStringsParams] :: GenStringsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gsp_n:GenStringsParams] :: GenStringsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gsp_pregeneratedRandomization:GenStringsParams] :: GenStringsParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:gsp_replacement:GenStringsParams] :: GenStringsParams -> Bool
+ System.Random.Atmospheric.Api: [$sel:gup_apiKey:GenUUIDsParams] :: GenUUIDsParams -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:gup_n:GenUUIDsParams] :: GenUUIDsParams -> Int
+ System.Random.Atmospheric.Api: [$sel:gup_pregeneratedRandomization:GenUUIDsParams] :: GenUUIDsParams -> Maybe Seed
+ System.Random.Atmospheric.Api: [$sel:ld_maxPayoutValue:LicenseData] :: LicenseData -> CurrencyAmount
+ System.Random.Atmospheric.Api: [$sel:license:SignedRandomResponse] :: SignedRandomResponse a b -> Object
+ System.Random.Atmospheric.Api: [$sel:licenseData:SignedRandomResponse] :: SignedRandomResponse a b -> Maybe LicenseData
+ System.Random.Atmospheric.Api: [$sel:ltr_expirationTime:TicketInfoResponse] :: TicketInfoResponse -> Maybe UTCTime
+ System.Random.Atmospheric.Api: [$sel:ltr_hashedApiKey:TicketInfoResponse] :: TicketInfoResponse -> ApiKey
+ System.Random.Atmospheric.Api: [$sel:ltr_serialNumber:TicketInfoResponse] :: TicketInfoResponse -> Maybe Int
+ System.Random.Atmospheric.Api: [$sel:ltr_showResult:TicketInfoResponse] :: TicketInfoResponse -> Bool
+ System.Random.Atmospheric.Api: [$sel:ltr_ticketResponse:TicketInfoResponse] :: TicketInfoResponse -> TicketResponse
+ System.Random.Atmospheric.Api: [$sel:ltr_usedTime:TicketInfoResponse] :: TicketInfoResponse -> Maybe UTCTime
+ System.Random.Atmospheric.Api: [$sel:method:SignedRandomResponse] :: SignedRandomResponse a b -> Method
+ System.Random.Atmospheric.Api: [$sel:params:SignedRandomResponse] :: SignedRandomResponse a b -> b
+ System.Random.Atmospheric.Api: [$sel:randomData:RandomResponse] :: RandomResponse a -> a
+ System.Random.Atmospheric.Api: [$sel:randomResponse:SignedRandomResponse] :: SignedRandomResponse a b -> RandomResponse a
+ System.Random.Atmospheric.Api: [$sel:requestsLeft:RandomResponse] :: RandomResponse a -> Int
+ System.Random.Atmospheric.Api: [$sel:serialNumber:SignedRandomResponse] :: SignedRandomResponse a b -> Int
+ System.Random.Atmospheric.Api: [$sel:signature:SignedRandomResponse] :: SignedRandomResponse a b -> Signature
+ System.Random.Atmospheric.Api: [$sel:td_nextTicketId:TicketData] :: TicketData -> Maybe TicketId
+ System.Random.Atmospheric.Api: [$sel:td_previousTicketId:TicketData] :: TicketData -> Maybe TicketId
+ System.Random.Atmospheric.Api: [$sel:td_ticketId:TicketData] :: TicketData -> TicketId
+ System.Random.Atmospheric.Api: [$sel:ticketData:SignedRandomResponse] :: SignedRandomResponse a b -> Maybe TicketData
+ System.Random.Atmospheric.Api: [$sel:tr_creationTime:TicketResponse] :: TicketResponse -> UTCTime
+ System.Random.Atmospheric.Api: [$sel:tr_ticketData:TicketResponse] :: TicketResponse -> TicketData
+ System.Random.Atmospheric.Api: [$sel:unBlob:Blob] :: Blob -> ByteString
+ System.Random.Atmospheric.Api: [$sel:unKey:Key] :: Key -> ByteString
+ System.Random.Atmospheric.Api: [$sel:unSignature:Signature] :: Signature -> ByteString
+ System.Random.Atmospheric.Api: [$sel:unTicketId:TicketId] :: TicketId -> ByteString
+ System.Random.Atmospheric.Api: [$sel:ur_bitsLeft:UsageResponse] :: UsageResponse -> Int
+ System.Random.Atmospheric.Api: [$sel:ur_creationTime:UsageResponse] :: UsageResponse -> UTCTime
+ System.Random.Atmospheric.Api: [$sel:ur_requestsLeft:UsageResponse] :: UsageResponse -> Int
+ System.Random.Atmospheric.Api: [$sel:ur_status:UsageResponse] :: UsageResponse -> Status
+ System.Random.Atmospheric.Api: [$sel:ur_totalBits:UsageResponse] :: UsageResponse -> Int
+ System.Random.Atmospheric.Api: [$sel:ur_totalRequests:UsageResponse] :: UsageResponse -> Int
+ System.Random.Atmospheric.Api: [$sel:userData:SignedRandomResponse] :: SignedRandomResponse a b -> Maybe Object
+ System.Random.Atmospheric.Api: [$sel:vsr_authenticity:VerifySignatureResponse] :: VerifySignatureResponse -> Bool
+ System.Random.Atmospheric.Api: createTickets :: Manager -> Key -> Int -> Bool -> IO [TicketResponse]
+ System.Random.Atmospheric.Api: createTickets' :: Manager -> Key -> Int -> Bool -> IO (Either ClientError (JsonRpcResponse Value CreateTicketsResponse))
+ System.Random.Atmospheric.Api: data ApiKey
+ System.Random.Atmospheric.Api: data BlobFormat
+ System.Random.Atmospheric.Api: data Boundary
+ System.Random.Atmospheric.Api: data Currency
+ System.Random.Atmospheric.Api: data CurrencyAmount
+ System.Random.Atmospheric.Api: data GenBlobsParams
+ System.Random.Atmospheric.Api: data GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: data GenGaussiansParams
+ System.Random.Atmospheric.Api: data GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: data GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: data GenIntegersParams
+ System.Random.Atmospheric.Api: data GenStringsParams
+ System.Random.Atmospheric.Api: data GenUUIDsParams
+ System.Random.Atmospheric.Api: data GetResultResponse
+ System.Random.Atmospheric.Api: data Method
+ System.Random.Atmospheric.Api: data MkSeedError
+ System.Random.Atmospheric.Api: data RandomResponse a
+ System.Random.Atmospheric.Api: data Seed
+ System.Random.Atmospheric.Api: data SignedRandomResponse a b
+ System.Random.Atmospheric.Api: data Status
+ System.Random.Atmospheric.Api: data TicketData
+ System.Random.Atmospheric.Api: data TicketInfoResponse
+ System.Random.Atmospheric.Api: data TicketResponse
+ System.Random.Atmospheric.Api: data TicketType
+ System.Random.Atmospheric.Api: data UsageResponse
+ System.Random.Atmospheric.Api: genBlobs :: Manager -> Key -> Int -> Int -> BlobFormat -> IO (Maybe ([Blob], Int))
+ System.Random.Atmospheric.Api: genBlobs' :: Manager -> Key -> Int -> Int -> BlobFormat -> IO (Either ClientError (RndResponse [Blob]))
+ System.Random.Atmospheric.Api: genDecimalFractions :: Manager -> Key -> Bool -> Int -> Int -> IO (Maybe ([Double], Int))
+ System.Random.Atmospheric.Api: genDecimalFractions' :: Manager -> Key -> Bool -> Int -> Int -> IO (Either ClientError (RndResponse [Double]))
+ System.Random.Atmospheric.Api: genGaussians :: Manager -> Key -> Int -> Double -> Double -> Int -> IO (Maybe ([Double], Int))
+ System.Random.Atmospheric.Api: genGaussians' :: Manager -> Key -> Int -> Double -> Double -> Int -> IO (Either ClientError (RndResponse [Double]))
+ System.Random.Atmospheric.Api: genIntegerSequences :: Manager -> Key -> Bool -> Int -> Int -> Int -> Int -> IO (Maybe ([[Int]], Int))
+ System.Random.Atmospheric.Api: genIntegerSequences' :: Manager -> Key -> Bool -> Int -> Int -> Int -> Int -> IO (Either ClientError (RndResponse [[Int]]))
+ System.Random.Atmospheric.Api: genIntegerSequencesMultiform :: Manager -> Key -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (Maybe ([[Int]], Int))
+ System.Random.Atmospheric.Api: genIntegerSequencesMultiform' :: Manager -> Key -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (Either ClientError (RndResponse [[Int]]))
+ System.Random.Atmospheric.Api: genIntegers :: Manager -> Key -> Bool -> Int -> Int -> Int -> IO (Maybe ([Int], Int))
+ System.Random.Atmospheric.Api: genIntegers' :: Manager -> Key -> Bool -> Int -> Int -> Int -> IO (Either ClientError (RndResponse [Int]))
+ System.Random.Atmospheric.Api: genSignedBlobs :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> Int -> BlobFormat -> IO (ClientSigResponse [Blob] GenBlobsParams)
+ System.Random.Atmospheric.Api: genSignedDecimalFractions :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> IO (ClientSigResponse [Double] GenDecimalFractionsParams)
+ System.Random.Atmospheric.Api: genSignedGaussians :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> Double -> Double -> Int -> IO (ClientSigResponse [Double] GenGaussiansParams)
+ System.Random.Atmospheric.Api: genSignedIntegerSequences :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> Int -> Int -> IO (ClientSigResponse [[Int]] GenIntegerSequencesParams)
+ System.Random.Atmospheric.Api: genSignedIntegerSequencesMultiform :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (ClientSigResponse [[Int]] GenIntegerSequencesMultiformParams)
+ System.Random.Atmospheric.Api: genSignedIntegers :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> Int -> IO (ClientSigResponse [Int] GenIntegersParams)
+ System.Random.Atmospheric.Api: genSignedStrings :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> [Char] -> IO (ClientSigResponse [Text] GenStringsParams)
+ System.Random.Atmospheric.Api: genSignedUUIDs :: Manager -> Key -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> IO (ClientSigResponse [UUID] GenUUIDsParams)
+ System.Random.Atmospheric.Api: genStrings :: Manager -> Key -> Bool -> Int -> Int -> [Char] -> IO (Maybe ([Text], Int))
+ System.Random.Atmospheric.Api: genStrings' :: Manager -> Key -> Bool -> Int -> Int -> [Char] -> IO (Either ClientError (RndResponse [Text]))
+ System.Random.Atmospheric.Api: genUUIDs :: Manager -> Key -> Int -> IO (Maybe ([UUID], Int))
+ System.Random.Atmospheric.Api: genUUIDs' :: Manager -> Key -> Int -> IO (Either ClientError (RndResponse [UUID]))
+ System.Random.Atmospheric.Api: genWithSeedBlobs :: Manager -> Key -> Maybe Seed -> Int -> Int -> BlobFormat -> IO (Maybe ([Blob], Int))
+ System.Random.Atmospheric.Api: genWithSeedBlobs' :: Manager -> Key -> Maybe Seed -> Int -> Int -> BlobFormat -> IO (Either ClientError (RndResponse [Blob]))
+ System.Random.Atmospheric.Api: genWithSeedDecimalFractions :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> IO (Maybe ([Double], Int))
+ System.Random.Atmospheric.Api: genWithSeedDecimalFractions' :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> IO (Either ClientError (RndResponse [Double]))
+ System.Random.Atmospheric.Api: genWithSeedGaussians :: Manager -> Key -> Maybe Seed -> Int -> Double -> Double -> Int -> IO (Maybe ([Double], Int))
+ System.Random.Atmospheric.Api: genWithSeedGaussians' :: Manager -> Key -> Maybe Seed -> Int -> Double -> Double -> Int -> IO (Either ClientError (RndResponse [Double]))
+ System.Random.Atmospheric.Api: genWithSeedIntegerSequences :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> Int -> Int -> IO (Maybe ([[Int]], Int))
+ System.Random.Atmospheric.Api: genWithSeedIntegerSequences' :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> Int -> Int -> IO (Either ClientError (RndResponse [[Int]]))
+ System.Random.Atmospheric.Api: genWithSeedIntegerSequencesMultiform :: Manager -> Key -> Maybe Seed -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (Maybe ([[Int]], Int))
+ System.Random.Atmospheric.Api: genWithSeedIntegerSequencesMultiform' :: Manager -> Key -> Maybe Seed -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (Either ClientError (RndResponse [[Int]]))
+ System.Random.Atmospheric.Api: genWithSeedIntegers :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> Int -> IO (Maybe ([Int], Int))
+ System.Random.Atmospheric.Api: genWithSeedIntegers' :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> Int -> IO (Either ClientError (RndResponse [Int]))
+ System.Random.Atmospheric.Api: genWithSeedSignedBlobs :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> Int -> BlobFormat -> IO (ClientSigResponse [Blob] GenBlobsParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedDecimalFractions :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> IO (ClientSigResponse [Double] GenDecimalFractionsParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedGaussians :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> Double -> Double -> Int -> IO (ClientSigResponse [Double] GenGaussiansParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedIntegerSequences :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> Int -> Int -> IO (ClientSigResponse [[Int]] GenIntegerSequencesParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedIntegerSequencesMultiform :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> [Int] -> Boundary -> Boundary -> IO (ClientSigResponse [[Int]] GenIntegerSequencesMultiformParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedIntegers :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> Int -> IO (ClientSigResponse [Int] GenIntegersParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedStrings :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Bool -> Int -> Int -> [Char] -> IO (ClientSigResponse [Text] GenStringsParams)
+ System.Random.Atmospheric.Api: genWithSeedSignedUUIDs :: Manager -> Key -> Maybe Seed -> Maybe LicenseData -> Maybe Object -> Maybe TicketId -> Int -> IO (ClientSigResponse [UUID] GenUUIDsParams)
+ System.Random.Atmospheric.Api: genWithSeedStrings :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> [Char] -> IO (Maybe ([Text], Int))
+ System.Random.Atmospheric.Api: genWithSeedStrings' :: Manager -> Key -> Maybe Seed -> Bool -> Int -> Int -> [Char] -> IO (Either ClientError (RndResponse [Text]))
+ System.Random.Atmospheric.Api: genWithSeedUUIDs :: Manager -> Key -> Maybe Seed -> Int -> IO (Maybe ([UUID], Int))
+ System.Random.Atmospheric.Api: genWithSeedUUIDs' :: Manager -> Key -> Maybe Seed -> Int -> IO (Either ClientError (RndResponse [UUID]))
+ System.Random.Atmospheric.Api: getResult :: Manager -> Key -> Int -> IO (Either ClientError (JsonRpcResponse Value GetResultResponse))
+ System.Random.Atmospheric.Api: getTicket :: Manager -> TicketId -> IO (Maybe TicketInfoResponse)
+ System.Random.Atmospheric.Api: getTicket' :: Manager -> TicketId -> IO (Either ClientError (JsonRpcResponse Value TicketInfoResponse))
+ System.Random.Atmospheric.Api: getUsage :: Manager -> Key -> IO (Maybe UsageResponse)
+ System.Random.Atmospheric.Api: getUsage' :: Manager -> Key -> IO (Either ClientError (JsonRpcResponse Value UsageResponse))
+ System.Random.Atmospheric.Api: instance (Data.Aeson.Types.FromJSON.FromJSON a, Data.Aeson.Types.FromJSON.FromJSON b) => Data.Aeson.Types.FromJSON.FromJSON (System.Random.Atmospheric.Api.SignedRandomResponse a b)
+ System.Random.Atmospheric.Api: instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (System.Random.Atmospheric.Api.SignedRandomResponse a b)
+ System.Random.Atmospheric.Api: instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (System.Random.Atmospheric.Api.SignedRandomResponse a b)
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.ApiKey
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Blob
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.BlobFormat
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Boundary
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.CreateTicketsResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Currency
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.CurrencyAmount
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenBlobsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenGaussiansParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenIntegersParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigBlobsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigGaussiansParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigIntegersParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigStringsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenSigUUIDsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenStringsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GenUUIDsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.GetResultResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Key
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.LicenseData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Method
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.RevealTicketsResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Seed
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Signature
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.SignedData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.Status
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.TicketData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.TicketId
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.TicketInfoResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.TicketResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.UsageResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON System.Random.Atmospheric.Api.VerifySignatureResponse
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (System.Random.Atmospheric.Api.RandomResponse a)
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.ApiKey
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Blob
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.BlobFormat
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Boundary
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.CreateTicketsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Currency
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.CurrencyAmount
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenBlobsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenGaussiansParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenIntegersParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigBlobsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigGaussiansParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigIntegersParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigStringsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenSigUUIDsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenStringsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GenUUIDsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GetResultParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GetTicketParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.GetUsageParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Key
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.LicenseData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.ListTicketsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Method
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.RevealTicketsParams
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Seed
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Signature
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.SignedData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.Status
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.TicketData
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.TicketId
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.TicketType
+ System.Random.Atmospheric.Api: instance Data.Aeson.Types.ToJSON.ToJSON System.Random.Atmospheric.Api.VerifySignatureParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.ApiKey
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Blob
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.BlobFormat
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Boundary
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.CreateTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.CreateTicketsResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Currency
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.CurrencyAmount
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenBlobsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenGaussiansParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenIntegersParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigBlobsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigGaussiansParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigIntegersParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigStringsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenSigUUIDsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenStringsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GenUUIDsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GetResultParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GetResultResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GetTicketParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.GetUsageParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Key
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.LicenseData
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.ListTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Method
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.MkSeedError
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.RevealTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.RevealTicketsResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Seed
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Signature
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.SignedData
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.Status
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.TicketData
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.TicketId
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.TicketInfoResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.TicketResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.TicketType
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.UsageResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.VerifySignatureParams
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq System.Random.Atmospheric.Api.VerifySignatureResponse
+ System.Random.Atmospheric.Api: instance GHC.Classes.Eq a => GHC.Classes.Eq (System.Random.Atmospheric.Api.RandomResponse a)
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Blob
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.BlobFormat
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Boundary
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.CreateTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.CreateTicketsResponse
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Currency
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.CurrencyAmount
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenBlobsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenGaussiansParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenIntegersParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenStringsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GenUUIDsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GetResultParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GetResultResponse
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GetTicketParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.GetUsageParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.LicenseData
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.ListTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Method
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.RevealTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Seed
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.SignedData
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.Status
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.TicketData
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.TicketId
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.TicketType
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.UsageResponse
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.VerifySignatureParams
+ System.Random.Atmospheric.Api: instance GHC.Generics.Generic System.Random.Atmospheric.Api.VerifySignatureResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.ApiKey
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Blob
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.BlobFormat
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Boundary
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.CreateTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.CreateTicketsResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Currency
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.CurrencyAmount
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenBlobsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenGaussiansParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenIntegersParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigBlobsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigDecimalFractionsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigGaussiansParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigIntegerSequencesMultiformParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigIntegerSequencesParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigIntegersParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigStringsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenSigUUIDsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenStringsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GenUUIDsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GetResultParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GetResultResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GetTicketParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.GetUsageParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Key
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.LicenseData
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.ListTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Method
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.MkSeedError
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.RevealTicketsParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.RevealTicketsResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Seed
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Signature
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.SignedData
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.Status
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.TicketData
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.TicketId
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.TicketInfoResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.TicketResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.TicketType
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.UsageResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.VerifySignatureParams
+ System.Random.Atmospheric.Api: instance GHC.Show.Show System.Random.Atmospheric.Api.VerifySignatureResponse
+ System.Random.Atmospheric.Api: instance GHC.Show.Show a => GHC.Show.Show (System.Random.Atmospheric.Api.RandomResponse a)
+ System.Random.Atmospheric.Api: listTickets :: Manager -> Key -> TicketType -> IO [TicketInfoResponse]
+ System.Random.Atmospheric.Api: listTickets' :: Manager -> Key -> TicketType -> IO (Either ClientError (JsonRpcResponse Value [TicketInfoResponse]))
+ System.Random.Atmospheric.Api: mkSeedFromId :: Text -> Either MkSeedError Seed
+ System.Random.Atmospheric.Api: mkSeedfromDate :: Day -> Day -> Either MkSeedError Seed
+ System.Random.Atmospheric.Api: newtype Blob
+ System.Random.Atmospheric.Api: newtype CreateTicketsResponse
+ System.Random.Atmospheric.Api: newtype Key
+ System.Random.Atmospheric.Api: newtype LicenseData
+ System.Random.Atmospheric.Api: newtype RevealTicketsResponse
+ System.Random.Atmospheric.Api: newtype Signature
+ System.Random.Atmospheric.Api: newtype TicketId
+ System.Random.Atmospheric.Api: newtype VerifySignatureResponse
+ System.Random.Atmospheric.Api: revealTickets :: Manager -> Key -> TicketId -> IO (Maybe Int)
+ System.Random.Atmospheric.Api: revealTickets' :: Manager -> Key -> TicketId -> IO (Either ClientError (JsonRpcResponse Value RevealTicketsResponse))
+ System.Random.Atmospheric.Api: type ClientSigResponse a b = Either ClientError (SigRndResponse a b)
+ System.Random.Atmospheric.Api: type RndResponse a = JsonRpcResponse Value (RandomResponse a)
+ System.Random.Atmospheric.Api: type SigRndResponse a b = JsonRpcResponse Value (SignedRandomResponse a b)
+ System.Random.Atmospheric.Api: verifySignedResponse :: (ToJSON a, ToJSON b) => Manager -> SignedRandomResponse a b -> IO (Maybe Bool)
+ System.Random.Atmospheric.Api: verifySignedResponse' :: (ToJSON a, ToJSON b) => Manager -> SignedRandomResponse a b -> IO (Either ClientError (JsonRpcResponse Value VerifySignatureResponse))
Files
- ChangeLog.md +25/−0
- LICENSE +28/−1
- README.md +23/−0
- RandomDotOrg.cabal +105/−18
- Setup.hs +2/−0
- Setup.lhs +0/−3
- System/Random/Atmosphere.hs +0/−103
- example/Main.hs +279/−0
- src/System/Random/Atmospheric/Api.hs +3178/−0
- src/System/Random/Atmospheric/Api/DateTime.hs +188/−0
- stack-ghc-8.10.7.yaml +5/−0
- stack-ghc-8.4.4.yaml +13/−0
- stack-ghc-8.6.5.yaml +5/−0
- stack-ghc-8.8.4.yaml +5/−0
- stack-ghc-9.0.2.yaml +5/−0
- stack-ghc-9.10.1.yaml +26/−0
- stack-ghc-9.2.8.yaml +5/−0
- stack-ghc-9.4.8.yaml +5/−0
- stack-ghc-9.6.6.yaml +5/−0
- stack-ghc-9.8.2.yaml +5/−0
+ ChangeLog.md view
@@ -0,0 +1,25 @@+# Changelog for RandomDotOrg + +## Version 1.0 - 2024-10-12 + +* Initial version providing Haskell bindings to the RANDOM.ORG Core API + (Release 4). See `RandomDotOrg < 1.0` for versions based on the RANDOM.ORG + website. +* Exposes module `System.Random.Atmosphere.Api` + +## Version 0.2.1 - 2008-07-29 + +* Deprecated. +* Improvements to Haddock documentation. + +## Version 0.2 - 2008-07-29 + +* Deprecated. +* Exposes module `System.Random.Atmosphere`. +* Adds `getRandomSequence`, `getRandomStrings` and `getQuota`. + +## Version 0.1 - 2008-07-29 + +* Deprecated. +* Exposes module `RandomDotOrg`. +* Provides `getRandomNumbers`.
LICENSE view
@@ -1,1 +1,28 @@-This work is in the public domain. Use it for whatever you wish.+Copyright Mike Pilgrem (c) 2022-2024 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of Mike Pilgrem nor the names of other contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,23 @@+# RandomDotOrg + +Haskell bindings to the [RANDOM.ORG](https://random.org) Core API (Release 4). +The API provides access to a true random number generator (TRNG) based on +atmospheric noise. + +NB: The use of the API's services is subject to the terms and conditions of +Randomness and Integrity Services Limited. + +An example of use of the library is provided in the `example` folder. + +This package and its repository have no connection with Randomness and Integrity +Services Limited or its affilates or the RANDOM.ORG domain. + +## Alternative packages + +* [`RandomDotOrg < 1.0`](https://hackage.haskell.org/package/RandomDotOrg-0.2.1) + (deprecated): Haskell bindings to the [RANDOM.ORG](https://random.org) + website. Does not require an API key. Quotas are allocated to IP addresses. + +* [`librandomorg`](https://hackage.haskell.org/package/librandomorg) (unrelated + package): Haskell bindings to the [RANDOM.ORG](https://random.org) website. + Does not require an API key. Quotas are allocated to IP addresses.
RandomDotOrg.cabal view
@@ -1,18 +1,105 @@-name: RandomDotOrg-version: 0.2.1-build-type: Simple-Cabal-Version: >= 1.2-synopsis: Interface to random.org-description: Using this package you can generate random numbers,- strings and randomize a sequence of numbers through- the random.org website, which provides randomness- through atmospheric noise rather than a PRNG.-category: Other-license: PublicDomain-license-file: LICENSE-author: Austin Seipp-maintainer: mad.one@gmail.com--library- build-depends: base, HTTP-Simple >= 0.1, network- exposed-modules: System.Random.Atmosphere+cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.37.0. +-- +-- see: https://github.com/sol/hpack + +name: RandomDotOrg +version: 1.0 +synopsis: Haskell bindings to the RANDOM.ORG Core API +description: Haskell bindings to the <https://www.random.org/ RANDOM.ORG> Core API + (Release 4). The API provides access to a true random number generator (TRNG) + based on atmospheric noise. + . + NB: The use of the API's services is subject to the terms and conditions of + Randomness and Integrity Services Limited. + . + An example of use of the library is provided in the @example@ directory. + . + This package and its repository have no connection with Randomness and + Integrity Services Limited or its affilates or the RANDOM.ORG domain. +category: Web +homepage: https://github.com/mpilgrem/RandomDotOrg#readme +bug-reports: https://github.com/mpilgrem/RandomDotOrg/issues +author: Mike Pilgrem +maintainer: public@pilgrem.com +copyright: Copyright 2022-2024 Mike Pilgrem +license: BSD3 +license-file: LICENSE +build-type: Simple +extra-source-files: + README.md + ChangeLog.md + stack-ghc-8.4.4.yaml + stack-ghc-8.6.5.yaml + stack-ghc-8.8.4.yaml + stack-ghc-8.10.7.yaml + stack-ghc-9.0.2.yaml + stack-ghc-9.2.8.yaml + stack-ghc-9.4.8.yaml + stack-ghc-9.6.6.yaml + stack-ghc-9.8.2.yaml + stack-ghc-9.10.1.yaml + +source-repository head + type: git + location: https://github.com/mpilgrem/RandomDotOrg + +flag example + description: Build the example application RandomDotOrg-example. + manual: True + default: False + +library + exposed-modules: + System.Random.Atmospheric.Api + other-modules: + System.Random.Atmospheric.Api.DateTime + hs-source-dirs: + src + ghc-options: -Wall + build-depends: + aeson >=1.4.1.0 + , base >=4.11 && <5 + , binary >=0.8.5.1 + , bytestring >=0.10.8.2 + , http-client >=0.5.12 + , http-client-tls >=0.3.0 + , http-media >=0.7.1.3 + , servant >=0.14 + , servant-client >=0.14 + , servant-client-core >=0.14 + , servant-jsonrpc >=1.2.0 + , servant-jsonrpc-client >=1.2.0 + , text >=1.2.3.0 + , time >=1.8.0.2 + , unordered-containers >=0.2.5.0 + , uuid-types >=1.0.3 + default-language: Haskell2010 + +executable RandomDotOrg-example + main-is: Main.hs + hs-source-dirs: + example + ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N + build-depends: + RandomDotOrg + , aeson >=1.4.1.0 + , base >=4.11 && <5 + , binary >=0.8.5.1 + , bytestring >=0.10.8.2 + , http-client >=0.5.12 + , http-client-tls >=0.3.0 + , http-media >=0.7.1.3 + , servant >=0.14 + , servant-client >=0.14 + , servant-client-core >=0.14 + , servant-jsonrpc >=1.2.0 + , servant-jsonrpc-client >=1.2.0 + , text >=1.2.3.0 + , time >=1.8.0.2 + , unordered-containers >=0.2.5.0 + , uuid-types >=1.0.3 + default-language: Haskell2010 + if !flag(example) + buildable: False
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple +main = defaultMain
− Setup.lhs
@@ -1,3 +0,0 @@-#!/usr/bin/env runhaskell-> import Distribution.Simple-> main = defaultMain
− System/Random/Atmosphere.hs
@@ -1,103 +0,0 @@-module System.Random.Atmosphere (- getRandomNumbers -- :: Int -> Int -> Int -> IO (Either String [Int])-, getRandomSequence -- :: Int -> Int -> IO (Either String [Int])-, getRandomStrings -- :: Int -> Int -> Bool -> Bool -> Bool -> Bool -> IO (Either String [String])-, getQuota -- :: IO (Either String Int)-) where-import Data.Either-import Network.URI-import Network.HTTP.Simple---- URI for integer generation-int_uri num min max - = concat [ "http://random.org/integers/?num=", show num- , "&min=", show min- , "&max=", show max- , "&col=1&base=10&format=plain&rnd=new" ]---- URI for sequence generation-seq_uri min max- = concat [ "http://www.random.org/sequences/?min=", show min- , "&max=", show max- , "&format=plain&rnd=new" ]---- URI for string generation-str_uri num len digits uppercase lowercase unique- = concat [ "http://www.random.org/strings/?num=", show num- , "&len=", show len- , "&digits=", if digits == True then "on" else "off"- , "&upperalpha=", if uppercase == True then "on" else "off"- , "&loweralpha=", if lowercase == True then "on" else "off"- , "&unique=", if unique == True then "on" else "off"- , "&format=plain&rnd=new" ]---- | Used to get a list of random numbers from http://random.org.--- Note: the minimum must be greater than the maximum. The maximum--- amount of numbers you can retrieve is 10,000, and the numbers --- themselves are limited to a range of +/- 1,000,000,000 (inclusive)-getRandomNumbers :: Int -- ^ Number of integers to get- -> Int -- ^ Minimum number- -> Int -- ^ Maximum number- -> IO (Either String [Int]) -- ^ Returns either an error string or the list of integers-getRandomNumbers num min max- | max <= min = return $ Left "err: minimum must be greater than maximum"- | num > 10000 = return $ Left "err: can't retrieve more than 10,000 numbers"- | abs min > 1000000000 = return $ Left "err: min can't be more/less than 1,000,000,000"- | abs max > 1000000000 = return $ Left "err: max can't be more/less than 1,000,000,000"- | otherwise = do let uri' = parseURI (int_uri num min max)- case uri' of- Nothing -> return $ Left "err: parseURI returned Nothing"- Just u -> retrieve u (map read . lines)---- | This is just like 'getRandomNumbers', but instead it will--- randomize a given interval of integers. The limits on the minimum/maximum--- are -1e9 to 1e9, inclusive. The interval itself must be less than 10,000.-getRandomSequence :: Int -- ^ Minimum- -> Int -- ^ Maximum- -> IO (Either String [Int])-getRandomSequence min max- | max <= min = return $ Left "err: max must be greater than min"- | abs max > 1000000000 = return $ Left "err: max can't be greater/less than +/-1e9"- | abs min > 1000000000 = return $ Left "err: min can't be greater/less than +/-1e9"- | (max - min)+1 > 10000 = return $ Left "err: sequence must be smaller than 10,000"- | otherwise = do let uri = parseURI (seq_uri min max)- case uri of- Nothing -> return $ Left "err: parseURI returned Nothing"- Just u -> retrieve u (map read . lines)---- | Generate random strings. NOTE: if you specify to generate unique--- strings, the amount you want to retrieve /must/ be less than or equal to the--- amount of strings that exist within the character set you specify.--- In the future there will be a check for this, but you have to be sure as of--- right now.-getRandomStrings :: Int -- ^ Number of strings requested, max is 10,000- -> Int -- ^ Length of each string, max is 20- -> Bool -- ^ Should digits be allowed?- -> Bool -- ^ Should uppercase be allowed?- -> Bool -- ^ Should lowercase be allowed?- -> Bool -- ^ Should each string be unique?- -> IO (Either String [String])-getRandomStrings num len digits uppercase lowercase unique- | num > 10000 = return $ Left "err: maximum number of strings is 10,000"- | len > 20 = return $ Left "err: maximum str len is 20"- | otherwise = do let uri = parseURI (str_uri num len digits uppercase lowercase unique)- case uri of- Nothing -> return $ Left "err: parseURI returned Nothing"- Just u' -> retrieve u' lines---- | Used to check how much of your random.org quota you have. Please see--- <http://random.org/quota> for more info.-getQuota :: IO (Either String Int)-getQuota = do let uri = parseURI "http://random.org/quota/?format=plain"- case uri of- Nothing -> return $ Left "err: parseURI returned Nothing"- Just u -> retrieve u read----- helper utility that calls httpGet for us--- it applies some function to the returned string so we can remove some--- boilerplate-retrieve uri f = do s <- httpGet uri- case s of- Nothing -> return $ Left "err: httpGet returned nothing"- Just s' -> return $ Right (f s')
+ example/Main.hs view
@@ -0,0 +1,279 @@+{-# LANGUAGE LambdaCase #-} + +{-| +Module : Main +Description : Example of use of Haskell bindings to the RANDOM.ORG Core API + (Release 4) +Copyright : Copyright 2024 Mike Pilgrem +License : BSD-3-Clause +Maintainer : public@pilgrem.com +Stability : Experimental +Portability : Portable + +Example of use of Haskell bindings to the [RANDOM.ORG](https://random.org) Core +API (Release 4). The example assumes the existence of an environment variable +@RANDOM_DOT_ORG_API_KEY@ that contains an API key for the Core API. + +This module has no connection with Randomness and Integrity Services Limited or +its affilates or the RANDOM.ORG domain. +-} + +module Main + ( main + ) where + +import Data.Aeson.Types ( ToJSON ) +import Data.ByteString.Char8 ( pack ) +import Data.Functor ( void ) +import Network.HTTP.Client ( Manager, newManager ) +import Network.HTTP.Client.TLS ( tlsManagerSettings ) +import Servant.Client.JsonRpc ( JsonRpcResponse (..) ) +import System.Environment ( lookupEnv ) +import System.Random.Atmospheric.Api + ( BlobFormat (Base64), Boundary (Fixed), ClientSigResponse + , Key (..), RandomResponse (..), SignedRandomResponse (..) + , TicketData (..), TicketInfoResponse (..) + , TicketResponse (..), TicketType (..), UsageResponse (..) + , createTickets, genBlobs, genDecimalFractions, genGaussians + , genIntegers, genIntegerSequences + , genIntegerSequencesMultiform, genSignedBlobs + , genSignedDecimalFractions, genSignedGaussians + , genSignedIntegers, genSignedIntegerSequences + , genSignedIntegerSequencesMultiform, genSignedStrings + , genSignedUUIDs, genStrings, genUUIDs, getResult, getTicket + , getUsage, listTickets, revealTickets, verifySignedResponse + ) + +main :: IO () +main = do + lookupEnv "RANDOM_DOT_ORG_API_KEY" >>= \case + Nothing -> putStrLn + "No RANDOM.ORG API key found in the environment. Set environment \ + \variable RANDOM_DOT_ORG_API_KEY to the API key." + Just apiKey' -> do + mgr <- newManager tlsManagerSettings + let apiKey = Key $ pack apiKey' + putStrLn "getUsage:" + mUsageResponseStart <- getUsage mgr apiKey + case mUsageResponseStart of + Just usageResponse -> print usageResponse + Nothing -> putStrLn "Error! No usage information." + blankLine + processBasic + "genIntegers (with replacement)" + (genIntegers mgr apiKey True 3 0 1000000) + processBasic + "genIntegers (without replacement)" + (genIntegers mgr apiKey False 52 1 52) + processBasic + "genIntegerSequences" + (genIntegerSequences mgr apiKey True 3 2 0 1000000) + processBasic + "genIntegerSequencesMultiform" + ( genIntegerSequencesMultiform + mgr apiKey True 3 [1, 2, 3] (Fixed 0) (Fixed 1000000) + ) + processBasic + "genDecimalFractions" + (genDecimalFractions mgr apiKey True 3 6) + processBasic + "genGaussians" + (genGaussians mgr apiKey 3 0.0 1.0 6) + processBasic + "genStrings" + (genStrings mgr apiKey True 3 8 ['A' .. 'Z']) + processBasic + "genUUIDs" + (genUUIDs mgr apiKey 3) + processBasic + "genBlobs" + (genBlobs mgr apiKey 3 16 Base64) + ticketIds <- + map (td_ticketId . tr_ticketData) <$> createTickets mgr apiKey 9 False + putStrLn $ "ticket Ids: " <> show ticketIds + ticketIds' <- + map (td_ticketId . tr_ticketData . ltr_ticketResponse) <$> + listTickets mgr apiKey Singleton + putStrLn $ "Head ticket Ids: " <> show ticketIds' + processSig + mgr + "genSignedIntegers" + ( genSignedIntegers + mgr + apiKey + Nothing + Nothing + (Just $ head ticketIds) + True + 3 + 0 + 1000000 + ) + processSig + mgr + "genSignedIntegerSequences" + ( genSignedIntegerSequences + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 1) + True + 3 + 2 + 0 + 1000000 + ) + processSig + mgr + "genSignedIntegerSequencesMultiform" + ( genSignedIntegerSequencesMultiform + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 2) + True + 3 + [1, 2, 3] + (Fixed 0) + (Fixed 1000000) + ) + processSig + mgr + "genSignedDecimalFractions" + ( genSignedDecimalFractions + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 3) + True + 3 + 6 + ) + processSig + mgr + "genSignedGaussians" + ( genSignedGaussians + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 4) + 3 + 0.0 + 1.0 + 6 + ) + processSig + mgr + "genSignedStrings" + ( genSignedStrings + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 5) + True + 3 + 8 + ['A' .. 'Z'] + ) + processSig + mgr + "genSignedUUIDs" + ( genSignedUUIDs + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 6) + 3 + ) + mSerialNumber <- processSig' + mgr + "genSignedBlobs" + ( genSignedBlobs + mgr + apiKey + Nothing + Nothing + (Just $ ticketIds !! 7) + 3 + 16 + Base64 + ) + revealTickets mgr apiKey (head ticketIds) >>= \case + Just ticketCount -> + putStrLn $ "Revealed " <> show ticketCount <> " ticket(s)." + Nothing -> putStrLn "Error! No ticket revelation." + blankLine + getTicket mgr (head ticketIds) >>= \case + Just ticketInfoResponse -> + putStrLn $ "getTicket: " <> show ticketInfoResponse + Nothing -> putStrLn "Error! No ticket information." + blankLine + case mSerialNumber of + Just sn -> do + putStrLn $ "Repeat serial number: " <> show sn + getResult mgr apiKey sn >>= \case + Right (Result _ result) -> print result + _ -> putStrLn "Error! No result." + Nothing -> putStrLn "Error! No serial number." + blankLine + putStrLn "getUsage:" + mUsageResponseEnd <- getUsage mgr apiKey + case mUsageResponseEnd of + Just usageResponse -> print usageResponse + Nothing -> putStrLn "Error! No usage information." + blankLine + case (mUsageResponseStart, mUsageResponseEnd) of + (Just urStart, Just urEnd) -> do + let totalBitsUsed = ur_bitsLeft urStart - ur_bitsLeft urEnd + putStrLn $ "Bits used: " <> show totalBitsUsed + _ -> pure () + where + blankLine :: IO () + blankLine = putStr "\n" + processBasic :: Show a => String -> IO (Maybe (a, Int)) -> IO () + processBasic name action = do + putStrLn $ name <> ":" + action >>= \case + Just (rd, _) -> print rd + Nothing -> putStrLn "Error! No data." + putStr "\n" + processSig :: + (Show a, Show b, ToJSON a, ToJSON b) + => Manager + -> String + -> IO (ClientSigResponse a b) + -> IO () + processSig mgr name action = void $ processSig' mgr name action + processSig' :: + (Show a, Show b, ToJSON a, ToJSON b) + => Manager + -> String + -> IO (ClientSigResponse a b) + -> IO (Maybe Int) + processSig' mgr name action = do + putStrLn $ name <>":" + mSerialNumber <- action >>= \case + Right (Result _ result) -> do + let sn = serialNumber result + putStrLn $ "Serial number: " <> show sn + print $ randomData $ randomResponse result + verifySignedResponse mgr result >>= \case + Just vsr -> putStrLn $ "Verified: " <> show vsr + Nothing -> putStrLn "Error! Could not perform verification." + pure $ Just sn + Right result -> do + putStrLn "Error! No data." + print result + pure Nothing + Left err -> do + putStrLn "Error! No data." + print err + pure Nothing + blankLine + pure mSerialNumber
+ src/System/Random/Atmospheric/Api.hs view
@@ -0,0 +1,3178 @@+{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE InstanceSigs #-} + +{-| +Module : System.Random.Atmospheric.Api +Description : Haskell bindings to the RANDOM.ORG Core API +Copyright : Copyright 2022-2024 Mike Pilgrem +License : BSD-3-Clause +Maintainer : public@pilgrem.com +Stability : Experimental +Portability : Portable + +Haskell bindings to the [RANDOM.ORG](https://random.org) Core API (Release 4). +The API provides access to a true random number generator (TRNG) based on +atmospheric noise. + +NB: The use of the API's services is subject to the terms and conditions of +Randomness and Integrity Services Limited. + +This module has no connection with Randomness and Integrity Services Limited or +its affilates or the RANDOM.ORG domain. + +The Core API comprises the Basic API and the Signed API. +-} + +module System.Random.Atmospheric.Api + ( -- * The Basic API + -- + -- | For each API method yielding random data there are four functions. For + -- example: + -- + -- * 'genIntegers' + -- * 'genIntegers'' + -- * 'genWithSeedIntegers' + -- * 'genWithSeedIntegers'' + -- + -- The functions with and without a prime character differ in the type of + -- the value they yield. This can be simple: + -- + -- > IO (Maybe (a, Int)) + -- + -- where the second value of the tuple represents the advised delay in + -- milliseconds before next calling the API, or complex: + -- + -- > IO (Either ClientError (JsonRpcResponse Value (RandomResponse a))) + -- + -- The type synonym 'RndResponse' is used to simplify the type signatures + -- of the complex functions: + -- + -- > type RndResponse a = JsonRpcResponse Value (RandomResponse a) + -- + -- The @genWithSeed...@ functions are more general, taking an optional seed + -- which, if specified, causes the API to use pregenerated noise. + -- + -- > genIntegers mgr key == genWithSeedIntegers mgr key Nothing + -- + -- > genIntegers' mgr key == genWithSeedIntegers' mgr key Nothing + -- + -- Certain optional API parameters (@base@, default @10@) are not + -- implemented. + + -- ** Simple functions yielding random data + genIntegers + , genIntegerSequences + , genIntegerSequencesMultiform + , genDecimalFractions + , genGaussians + , genStrings + , genUUIDs + , genBlobs + -- ** Complex functions yielding random data + , genIntegers' + , genIntegerSequences' + , genIntegerSequencesMultiform' + , genDecimalFractions' + , genGaussians' + , genStrings' + , genUUIDs' + , genBlobs' + -- ** Simple functions yielding random data, maybe from pregenerated randomization + , genWithSeedIntegers + , genWithSeedIntegerSequences + , genWithSeedIntegerSequencesMultiform + , genWithSeedDecimalFractions + , genWithSeedGaussians + , genWithSeedStrings + , genWithSeedUUIDs + , genWithSeedBlobs + -- ** Complex functions yielding random data, maybe from pregenerated randomization + , genWithSeedIntegers' + , genWithSeedIntegerSequences' + , genWithSeedIntegerSequencesMultiform' + , genWithSeedDecimalFractions' + , genWithSeedGaussians' + , genWithSeedStrings' + , genWithSeedUUIDs' + , genWithSeedBlobs' + -- * The Signed API + -- + -- | For each API method yielding random data there are two functions. For + -- example: + -- + -- * 'genSignedIntegers' + -- * 'genWithSeedSignedIntegers' + -- + -- The @genWithSeed...@ functions are more general, taking an optional seed + -- which, if specified, causes the API to use pregenerated noise. + -- + -- > genIntegers mgr key == genWithSeedIntegers mgr key Nothing + -- + -- > genIntegers' mgr key == genWithSeedIntegers' mgr key Nothing + -- + -- The type synonym 'SigRndResponse' is used to simplify the type signatures + -- of the functions: + -- + -- > type SigRndResponse a b = JsonRpcResponse Value (SignedRandomResponse a b) + -- + -- Certain optional API parameters (@base@, default @10@) are not + -- implemented. + + -- ** Functions yielding signed random data + , genSignedIntegers + , genSignedIntegerSequences + , genSignedIntegerSequencesMultiform + , genSignedDecimalFractions + , genSignedGaussians + , genSignedStrings + , genSignedUUIDs + , genSignedBlobs + -- ** Functions yielding signed random data, maybe from pregenerated randomization + , genWithSeedSignedIntegers + , genWithSeedSignedIntegerSequences + , genWithSeedSignedIntegerSequencesMultiform + , genWithSeedSignedDecimalFractions + , genWithSeedSignedGaussians + , genWithSeedSignedStrings + , genWithSeedSignedUUIDs + , genWithSeedSignedBlobs + -- ** Functions related to serial numbers + , getResult + -- ** Functions related to tickets + , createTickets + , createTickets' + , revealTickets + , revealTickets' + , listTickets + , listTickets' + , getTicket + , getTicket' + -- ** Functions related to verification + , verifySignedResponse + , verifySignedResponse' + -- * Usage of the Core API + , getUsage + , getUsage' + -- * Types and type synonyms + -- ** The Core API + , Key (..) + , Seed + , MkSeedError + , mkSeedfromDate + , mkSeedFromId + , Boundary (..) + , Blob (..) + , BlobFormat (..) + , RandomResponse (..) + , RndResponse + , UsageResponse (..) + , Status (..) + -- ** The Signed API only + , ApiKey (..) + , Method (..) + , LicenseData (..) + , CurrencyAmount (..) + , Currency (..) + , TicketResponse (..) + , TicketData (..) + , TicketId (..) + , TicketType (..) + , Signature (..) + , SignedRandomResponse (..) + , GenIntegersParams (..) + , GenIntegerSequencesParams (..) + , GenIntegerSequencesMultiformParams (..) + , GenDecimalFractionsParams (..) + , GenGaussiansParams (..) + , GenStringsParams (..) + , GenUUIDsParams (..) + , GenBlobsParams (..) + , ClientSigResponse + , GetResultResponse (..) + , CreateTicketsResponse (..) + , RevealTicketsResponse (..) + , TicketInfoResponse (..) + , VerifySignatureResponse (..) + , SigRndResponse + ) where + +import Control.Applicative ( (<|>) ) +import Data.Aeson.Encoding ( unsafeToEncoding ) +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.KeyMap as Map +#endif +import Data.Aeson.Types + ( FromJSON (..), Object, Options (..), SumEncoding (..) + , ToJSON (..), Value (..), (.:), defaultOptions + , fieldLabelModifier, genericParseJSON, genericToEncoding + , genericToJSON, withObject, withText + ) +import Data.Binary.Builder ( fromByteString ) +import Data.ByteString ( ByteString ) +import Data.Char ( toLower ) +#if !MIN_VERSION_aeson(2,0,0) +import qualified Data.HashMap.Strict as Map +#endif +import Data.Proxy ( Proxy (..) ) +import qualified Data.Text as T +import Data.Text ( Text ) +import Data.Text.Encoding ( decodeUtf8, encodeUtf8 ) +import Data.Time ( Day, UTCTime ) +import Data.UUID.Types ( UUID ) +import GHC.Generics ( Generic ) +import Network.HTTP.Client ( Manager ) +import Servant.API ( (:<|>) (..), (:>), JSON ) +import Servant.Client + ( BaseUrl (BaseUrl), ClientEnv (..), ClientM, Scheme (Https) + , client +#if MIN_VERSION_servant_client(0,17,0) + , defaultMakeClientRequest +#endif + , runClientM + ) +#if MIN_VERSION_servant_client(0,16,0) +import Servant.Client.Core ( ClientError ) +#else +import Servant.Client.Core ( ServantError ) +#endif +import Servant.Client.JsonRpc + ( JsonRpc, JsonRpcResponse (..), RawJsonRpc ) +import System.Random.Atmospheric.Api.DateTime ( DateTime (..) ) + +#if !MIN_VERSION_servant_client(0,16,0) +type ClientError = ServantError +#endif + +-- |Type synonym to simplify type signatures defining the Basic API. +type Rnd a b c = JsonRpc a b Value (RandomResponse c) + +type SigRnd a b c d = JsonRpc a b Value (SignedRandomResponse c d) + +-- |Type synonym to simplify type signatures defining responses from the Basic +-- API. +type RndResponse a = JsonRpcResponse Value (RandomResponse a) + +-- |Type synonym to simplify type signatures defining responses from the Signed +-- API. +type SigRndResponse a b = JsonRpcResponse Value (SignedRandomResponse a b) + +-- |Type synonym to simplify type signatures defining responses from the Signed +-- API. +type ClientSigResponse a b = Either ClientError (SigRndResponse a b) + +type GenIntegers = + Rnd "generateIntegers" GenIntegersParams [Int] + +type GenIntegerSequences = + Rnd "generateIntegerSequences" GenIntegerSequencesParams [[Int]] + +type GenIntegerSequencesMultiform = + Rnd "generateIntegerSequences" GenIntegerSequencesMultiformParams [[Int]] + +type GenDecimalFractions = + Rnd "generateDecimalFractions" GenDecimalFractionsParams [Double] + +type GenGaussians = + Rnd "generateGaussians" GenGaussiansParams [Double] + +type GenStrings = + Rnd "generateStrings" GenStringsParams [Text] + +type GenUUIDs = + Rnd "generateUUIDs" GenUUIDsParams [UUID] + +type GenBlobs = + Rnd "generateBlobs" GenBlobsParams [Blob] + +type GenSigIntegers = + SigRnd "generateSignedIntegers" GenSigIntegersParams [Int] GenIntegersParams + +type GenSigIntegerSequences = + SigRnd + "generateSignedIntegerSequences" + GenSigIntegerSequencesParams + [[Int]] + GenIntegerSequencesParams + +type GenSigIntegerSequencesMultiform = + SigRnd + "generateSignedIntegerSequences" + GenSigIntegerSequencesMultiformParams + [[Int]] + GenIntegerSequencesMultiformParams + +type GenSigDecimalFractions = + SigRnd + "generateSignedDecimalFractions" + GenSigDecimalFractionsParams + [Double] + GenDecimalFractionsParams + +type GenSigGaussians = + SigRnd + "generateSignedGaussians" + GenSigGaussiansParams + [Double] + GenGaussiansParams + +type GenSigStrings = + SigRnd "generateSignedStrings" GenSigStringsParams [Text] GenStringsParams + +type GenSigUUIDs = + SigRnd "generateSignedUUIDs" GenSigUUIDsParams [UUID] GenUUIDsParams + +type GenSigBlobs = + SigRnd "generateSignedBlobs" GenSigBlobsParams [Blob] GenBlobsParams + +type GetResult = + JsonRpc "getResult" GetResultParams Value GetResultResponse + +type CreateTickets = + JsonRpc "createTickets" CreateTicketsParams Value CreateTicketsResponse + +type RevealTickets = + JsonRpc "revealTickets" RevealTicketsParams Value RevealTicketsResponse + +type ListTickets = + JsonRpc "listTickets" ListTicketsParams Value [TicketInfoResponse] + +type GetTicket = + JsonRpc "getTicket" GetTicketParams Value TicketInfoResponse + +type VerifySignature = + JsonRpc "verifySignature" VerifySignatureParams Value VerifySignatureResponse + +type GetUsage = + JsonRpc "getUsage" GetUsageParams Value UsageResponse + +type RpcAPI = + GenIntegers + :<|> GenIntegerSequences + :<|> GenIntegerSequencesMultiform + :<|> GenDecimalFractions + :<|> GenGaussians + :<|> GenStrings + :<|> GenUUIDs + :<|> GenBlobs + :<|> GenSigIntegers + :<|> GenSigIntegerSequences + :<|> GenSigIntegerSequencesMultiform + :<|> GenSigDecimalFractions + :<|> GenSigGaussians + :<|> GenSigStrings + :<|> GenSigUUIDs + :<|> GenSigBlobs + :<|> GetResult + :<|> CreateTickets + :<|> RevealTickets + :<|> ListTickets + :<|> GetTicket + :<|> VerifySignature + :<|> GetUsage + +type JsonRpcAPI = + "json-rpc" :> "4" :> "invoke" :> RawJsonRpc JSON RpcAPI + +-- | Type representing Binary Large OBjects (BLOBs). +newtype Blob = Blob + { unBlob :: ByteString + } deriving (Eq, Generic, Show) + +instance FromJSON Blob where + + parseJSON = withText "Blob" (pure . Blob . encodeUtf8) + +instance ToJSON Blob where + + toJSON = String . decodeUtf8 . unBlob + toEncoding = unsafeToEncoding . fromByteString . unBlob + +-- | Type representing signed data. +data SignedData = SignedData + { sd_licenseData :: Maybe LicenseData + , sd_userData :: Maybe Object + , sd_ticketId :: Maybe TicketId + } deriving (Eq, Generic, Show) + +instance ToJSON SignedData where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 3} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 3} + +instance FromJSON SignedData where + + parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 3} + +-- | Type representing data required by the Signed API for certain licences. +newtype LicenseData = LicenseData + { ld_maxPayoutValue :: CurrencyAmount + } deriving (Eq, Generic, Show) + +instance ToJSON LicenseData where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 3} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 3} + +instance FromJSON LicenseData where + + parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 3} + +-- | Type representing monetary amounts. +data CurrencyAmount = CurrencyAmount + { ca_currency :: Currency + , ca_amount :: Double + } deriving (Eq, Generic, Show) + +instance ToJSON CurrencyAmount where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 3} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 3} + +instance FromJSON CurrencyAmount where + + parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 3} + +-- | Type representing currencies recognised by the Signed API. +data Currency + = USD -- ^ United State dollar + | EUR -- ^ Euro + | GBP -- ^ British pound + | BTC -- ^ Bitcoin cryptocurrency + | ETH -- ^ Ether cryptocurrency + deriving (Eq, Generic, Show) + +instance ToJSON Currency + +instance FromJSON Currency + +-- | Type representing the IDs of unique single-use tickets. +newtype TicketId = TicketId + { unTicketId :: ByteString + } deriving (Eq, Generic, Show) + +instance ToJSON TicketId where + + toJSON = String . decodeUtf8 . unTicketId + toEncoding = unsafeToEncoding . fromByteString . unTicketId + +instance FromJSON TicketId where + + parseJSON = withText "TicketId" (pure . TicketId . encodeUtf8) + +-- | Type representing \'seeds\' used to generate random data from historical, +-- pregenerated randomization. +data Seed + = DateSeed Day + -- ^ A seed based on a past date or the current date. + | IdSeed Text + -- ^ A seed based on an id of 1 to 64 characters in length. + deriving (Eq, Generic, Show) + +-- | Type representing errors form 'mkSeedFromId'. +data MkSeedError + = FutureDate + -- ^ The date for an date seed cannot be a future date. + | NullId + -- ^ The text for an id seed cannot be null. + | OversizedId + -- ^ The text for an id seen cannot be longer than 64 characters. + deriving (Eq, Show) + +-- | Construct a seed from a date. Given the current date, checks that the date +-- is a past date or the current date. +mkSeedfromDate :: + Day + -- ^ The current date (not verified). + -> Day + -- ^ A past date or the current date. + -> Either MkSeedError Seed +mkSeedfromDate today date + | date <= today = Right (DateSeed date) + | otherwise = Left FutureDate + +-- | Construct a seed from an id. Checks that the id is between 1 to 64 +-- characters in length. +mkSeedFromId :: Text -> Either MkSeedError Seed +mkSeedFromId t + | T.null t = Left NullId + | T.length t > 64 = Left OversizedId + | otherwise = Right (IdSeed t) + +instance ToJSON Seed where + + toJSON (DateSeed day) = Object $ Map.singleton "date" (toJSON day) + toJSON (IdSeed identifier) = Object $ Map.singleton "id" (toJSON identifier) + +instance FromJSON Seed where + + parseJSON = withObject "Seed" $ \obj -> + DateSeed <$> obj .: "date" <|> IdSeed <$> obj .: "id" + +-- | Type representing parameters to the generateIntegers API method. +data GenIntegersParams = GenIntegersParams + { gip_apiKey :: ApiKey + , gip_n :: Int + , gip_min :: Int + , gip_max :: Int + , gip_replacement :: Bool + , gip_base :: Int + , gip_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenIntegersParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +instance FromJSON GenIntegersParams where + + parseJSON = genericParseJSON $ customOptions 4 + +-- | Type representing parameters to the generateSignedIntegers API method. +data GenSigIntegersParams = GenSigIntegersParams + { sgip_params :: GenIntegersParams + , sgip_data :: SignedData + } deriving (Eq, Show) + +sigParamsToJSON :: + (ToJSON a1, ToJSON a2) + => t + -> (t -> a1) + -> (t -> a2) + -> Value +sigParamsToJSON p pParams pData = + case (toJSON $ pParams p, toJSON $ pData p) of + (Object o_params, Object o_data) -> Object (o_params <> o_data) + _ -> error "error" + +instance ToJSON GenSigIntegersParams where + + toJSON p = sigParamsToJSON p sgip_params sgip_data + +instance FromJSON GenSigIntegersParams where + + parseJSON v = do + sgip_params <- parseJSON v + sgip_data <- parseJSON v + pure GenSigIntegersParams {..} + +-- | Type representing parameters to the generateIntegerSequences API method. +data GenIntegerSequencesParams = GenIntegerSequencesParams + { gisp_apiKey :: ApiKey + , gisp_n :: Int + , gisp_length :: Int + , gisp_min :: Int + , gisp_max :: Int + , gisp_replacement :: Bool + , gisp_base :: Int + , gisp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenIntegerSequencesParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 5} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 5} + +customOptions :: Int -> Options +customOptions n = defaultOptions + { fieldLabelModifier = \l -> case drop n l of + "apiKey" -> "hashedApiKey" + l' -> l' + } + +instance FromJSON GenIntegerSequencesParams where + + parseJSON = genericParseJSON $ customOptions 5 + +-- | Type representing parameters to the generateSignedIntegerSequences API +-- method for non-multiform sequences. +data GenSigIntegerSequencesParams = GenSigIntegerSequencesParams + { sgisp_params :: GenIntegerSequencesParams + , sgisp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigIntegerSequencesParams where + + toJSON :: GenSigIntegerSequencesParams -> Value + toJSON p = sigParamsToJSON p sgisp_params sgisp_data + +instance FromJSON GenSigIntegerSequencesParams where + + parseJSON v = do + sgisp_params <- parseJSON v + sgisp_data <- parseJSON v + pure GenSigIntegerSequencesParams {..} + +-- | Type representing parameters to the generateIntegerSequences API method for +-- multiform sequences. +data GenIntegerSequencesMultiformParams = GenIntegerSequencesMultiformParams + { gismp_apiKey :: ApiKey + , gismp_n :: Int + , gismp_length :: [Int] + , gismp_min :: Boundary + , gismp_max :: Boundary + , gismp_replacement :: Bool + , gismp_base :: Int + , gismp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +-- | Type representing boundaries of multiform @generateIntegerSequences@. +data Boundary + = Fixed Int -- ^ Fixed boundary for all sequences. + | Multiform [Int] -- ^ List of boundaries for each sequence. + deriving (Eq, Generic, Show) + +instance ToJSON Boundary where + toJSON (Fixed b) = toJSON b + toJSON (Multiform bs) = toJSON bs + toEncoding (Fixed b) = toEncoding b + toEncoding (Multiform bs) = toEncoding bs + +instance FromJSON Boundary where + + parseJSON = genericParseJSON defaultOptions {sumEncoding = UntaggedValue} + +instance ToJSON GenIntegerSequencesMultiformParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 6} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 6} + +instance FromJSON GenIntegerSequencesMultiformParams where + + parseJSON = genericParseJSON $ customOptions 6 + +-- | Type representing parameters to the generateSignedIntegerSequences API +-- method for multiform sequences. +data GenSigIntegerSequencesMultiformParams = + GenSigIntegerSequencesMultiformParams + { sgismp_params :: GenIntegerSequencesMultiformParams + , sgismp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigIntegerSequencesMultiformParams where + + toJSON p = sigParamsToJSON p sgismp_params sgismp_data + +instance FromJSON GenSigIntegerSequencesMultiformParams where + + parseJSON v = do + sgismp_params <- parseJSON v + sgismp_data <- parseJSON v + pure GenSigIntegerSequencesMultiformParams {..} + +-- | Type representing parameters to the @generateDecimalFractions@ API method. +data GenDecimalFractionsParams = GenDecimalFractionsParams + { gdfp_apiKey :: ApiKey + , gdfp_n :: Int + , gdfp_decimalPlaces :: Int + , gdfp_replacement :: Bool + , gdfp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenDecimalFractionsParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 5} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 5} + +instance FromJSON GenDecimalFractionsParams where + + parseJSON = genericParseJSON $ customOptions 5 + +-- | Type representing parameters to the @generateSignedDecimalFractions@ API +-- method. +data GenSigDecimalFractionsParams = GenSigDecimalFractionsParams + { sgdfp_params :: GenDecimalFractionsParams + , sgdfp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigDecimalFractionsParams where + + toJSON p = sigParamsToJSON p sgdfp_params sgdfp_data + +instance FromJSON GenSigDecimalFractionsParams where + + parseJSON v = do + sgdfp_params <- parseJSON v + sgdfp_data <- parseJSON v + pure GenSigDecimalFractionsParams {..} + +-- | Type representing parameters to the @generateGaussianss@ API method. +data GenGaussiansParams = GenGaussiansParams + { ggp_apiKey :: ApiKey + , ggp_n :: Int + , ggp_mean :: Double + , ggp_standardDeviation :: Double + , ggp_significantDigits :: Int + , ggp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenGaussiansParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +instance FromJSON GenGaussiansParams where + + parseJSON = genericParseJSON $ customOptions 4 + +-- | Type representing parameters to the @generateSignedGaussianss@ API method. +data GenSigGaussiansParams = GenSigGaussiansParams + { sggp_params :: GenGaussiansParams + , sggp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigGaussiansParams where + + toJSON p = sigParamsToJSON p sggp_params sggp_data + +instance FromJSON GenSigGaussiansParams where + + parseJSON v = do + sggp_params <- parseJSON v + sggp_data <- parseJSON v + pure GenSigGaussiansParams {..} + +-- | Type representing parameters to the @generateStrings@ API method. +data GenStringsParams = GenStringsParams + { gsp_apiKey :: ApiKey + , gsp_n :: Int + , gsp_length :: Int + , gsp_characters :: [Char] + , gsp_replacement :: Bool + , gsp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenStringsParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +instance FromJSON GenStringsParams where + + parseJSON = genericParseJSON $ customOptions 4 + +-- | Type representing parameters to the @generateSignedStrings@ API method. +data GenSigStringsParams = GenSigStringsParams + { sgsp_params :: GenStringsParams + , sgsp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigStringsParams where + + toJSON p = sigParamsToJSON p sgsp_params sgsp_data + +instance FromJSON GenSigStringsParams where + + parseJSON v = do + sgsp_params <- parseJSON v + sgsp_data <- parseJSON v + pure GenSigStringsParams {..} + +-- | Type representing parameters to the @generateUUIDs@ API method. +data GenUUIDsParams = GenUUIDsParams + { gup_apiKey :: ApiKey + , gup_n :: Int + , gup_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenUUIDsParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +instance FromJSON GenUUIDsParams where + + parseJSON = genericParseJSON $ customOptions 4 + +-- | Type representing parameters to the @generateSignedUUIDs@ API method. +data GenSigUUIDsParams = GenSigUUIDsParams + { sgup_params :: GenUUIDsParams + , sgup_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigUUIDsParams where + + toJSON p = sigParamsToJSON p sgup_params sgup_data + +instance FromJSON GenSigUUIDsParams where + + parseJSON v = do + sgup_params <- parseJSON v + sgup_data <- parseJSON v + pure GenSigUUIDsParams {..} + +-- | Type representing parameters to the @generateBlobs@ API method. +data GenBlobsParams = GenBlobsParams + { gbp_apiKey :: ApiKey + , gbp_n :: Int + , gbp_size :: Int + , gbp_format :: BlobFormat + , gbp_pregeneratedRandomization :: Maybe Seed + } deriving (Eq, Generic, Show) + +instance ToJSON GenBlobsParams where + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +instance FromJSON GenBlobsParams where + + parseJSON = genericParseJSON $ customOptions 4 + +-- | Type representing BLOB formats. +data BlobFormat + = Base64 + | Hex + deriving (Eq, Generic, Show) + +instance ToJSON BlobFormat where + + toJSON = genericToJSON defaultOptions {constructorTagModifier = map toLower} + + toEncoding = + genericToEncoding defaultOptions {constructorTagModifier = map toLower} + +instance FromJSON BlobFormat where + + parseJSON = + genericParseJSON defaultOptions {constructorTagModifier = map toLower} + +-- | Type representing parameters to the @generateSignedBlobs@ API method. +data GenSigBlobsParams = GenSigBlobsParams + { sgbp_params :: GenBlobsParams + , sgbp_data :: SignedData + } deriving (Eq, Show) + +instance ToJSON GenSigBlobsParams where + + toJSON p = sigParamsToJSON p sgbp_params sgbp_data + +instance FromJSON GenSigBlobsParams where + + parseJSON v = do + sgbp_params <- parseJSON v + sgbp_data <- parseJSON v + pure GenSigBlobsParams {..} + +data GetResultParams = GetResultParams + { grp_apiKey :: Key + , grp_serialNumber :: Int + } deriving (Eq, Generic, Show) + +instance ToJSON GetResultParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +data CreateTicketsParams = CreateTicketsParams + { ctp_apiKey :: Key + , ctp_n :: Int + , ctp_showResult :: Bool + } deriving (Eq, Generic, Show) + +instance ToJSON CreateTicketsParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +data RevealTicketsParams = RevealTicketsParams + { rtp_apiKey :: Key + , rtp_ticketId :: TicketId + } deriving (Eq, Generic, Show) + +instance ToJSON RevealTicketsParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +data ListTicketsParams = ListTicketsParams + { ltp_apiKey :: Key + , ltp_ticketType :: TicketType + } deriving (Eq, Generic, Show) + +instance ToJSON ListTicketsParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +-- | Type representing types of tickets to list. +data TicketType + = Singleton + -- ^ No previous or next tickets. + | Head + -- ^ No previous ticket but next ticket. + | Tail + -- ^ Previous ticket but no next ticket. + deriving (Eq, Generic, Show) + +instance ToJSON TicketType where + + toJSON = genericToJSON defaultOptions {constructorTagModifier = map toLower} + + toEncoding = + genericToEncoding defaultOptions {constructorTagModifier = map toLower} + +-- | Type representing parameters to the @getTicket@ API method. +newtype GetTicketParams = GetTicketParams + { gtp_ticketId :: TicketId + } deriving (Eq, Generic, Show) + +instance ToJSON GetTicketParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +-- | Type representing parameters to the @getTicket@ API method. +data VerifySignatureParams = VerifySignatureParams + { vsp_random :: Value + , vsp_signature :: Signature + } deriving (Eq, Generic, Show) + +instance ToJSON VerifySignatureParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 4} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 4} + +-- | Type representing signatures. +newtype Signature = Signature + { unSignature :: ByteString + } deriving (Eq, Show) + +instance FromJSON Signature where + + parseJSON = withText "Signature" (pure . Signature . encodeUtf8) + +instance ToJSON Signature where + + toJSON = String . decodeUtf8 . unSignature + toEncoding = unsafeToEncoding . fromByteString . unSignature + +-- | Type representing types of tickets to list. +newtype GetUsageParams = GetUsageParams + { usep_apiKey :: Key + } deriving (Eq, Generic, Show) + +instance ToJSON GetUsageParams where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 5} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 5} + +-- |Type representing responses from methods of the Basic API yielding random +-- data. +data RandomResponse a = RandomResponse + { randomData :: a + , completionTime :: UTCTime + , bitsUsed :: Int + , bitsLeft :: Int + , requestsLeft :: Int + , advisoryDelay :: Int + } deriving (Eq, Show) + +instance FromJSON a => FromJSON (RandomResponse a) where + parseJSON = withObject "random.org response" $ \obj -> do + random <- obj .: "random" + randomData <- random .: "data" + completionTime <- random .: "completionTime" + bitsUsed <- obj .: "bitsUsed" + bitsLeft <- obj .: "bitsLeft" + requestsLeft <- obj .: "requestsLeft" + advisoryDelay <- obj .: "advisoryDelay" + pure RandomResponse {..} + +-- |Type representing responses from methods of the Signed API yielding random +-- data. +data SignedRandomResponse a b = SignedRandomResponse + { randomResponse :: RandomResponse a + , method :: Method + , params :: b + , license :: Object + , licenseData :: Maybe LicenseData + , userData :: Maybe Object + , ticketData :: Maybe TicketData + , serialNumber :: Int + , signature :: Signature + , cost :: CurrencyAmount + -- ^ The cost of the request charged to the RANDOM.ORG account associated + -- with the API key used in the request. + } deriving (Eq, Show) + +-- | Type representing methods of the Signed API generating random data. +data Method + = GenerateSignedIntegers + | GenerateSignedIntegerSequences + | GenerateSignedDecimalFractions + | GenerateSignedGaussians + | GenerateSignedStrings + | GenerateSignedUUIDs + | GenerateSignedBlobs + deriving (Eq, Generic, Show) + +instance ToJSON Method where + + toJSON = genericToJSON defaultOptions {constructorTagModifier = firstToLower} + + toEncoding = + genericToEncoding defaultOptions {constructorTagModifier = firstToLower} + +instance FromJSON Method where + + parseJSON = + genericParseJSON defaultOptions {constructorTagModifier = firstToLower} + +firstToLower :: String -> String +firstToLower "" = "" +firstToLower (x:xs) = toLower x : xs + +-- |Type representing data about tickets. +data TicketData = TicketData + { td_ticketId :: TicketId + , td_previousTicketId :: Maybe TicketId + -- ^ The previous ticket, if any, in the same chain as this ticket. + , td_nextTicketId :: Maybe TicketId + -- ^ The next ticket, if any, in the same chain as this ticket. + } deriving (Eq, Generic, Show) + +instance ToJSON TicketData where + + toJSON = genericToJSON defaultOptions {fieldLabelModifier = drop 3} + + toEncoding = genericToEncoding defaultOptions {fieldLabelModifier = drop 3} + +instance FromJSON TicketData where + + parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 3} + +instance (FromJSON a, FromJSON b) => FromJSON (SignedRandomResponse a b) where + + parseJSON = withObject "random.org signed response" $ \obj -> do + random <- obj .: "random" + method <- random .: "method" + params <- obj .: "random" + randomData <- random .: "data" + license <- random .: "license" + licenseData <- random .: "licenseData" + userData <- random .: "userData" + ticketData <- random .: "ticketData" + completionTime <- random .: "completionTime" + serialNumber <- random .: "serialNumber" + signature <- obj .: "signature" + cost <- CurrencyAmount USD <$> obj .: "cost" + bitsUsed <- obj .: "bitsUsed" + bitsLeft <- obj .: "bitsLeft" + requestsLeft <- obj .: "requestsLeft" + advisoryDelay <- obj .: "advisoryDelay" + let randomResponse = RandomResponse {..} + pure SignedRandomResponse {..} + +toJSONRandom :: (ToJSON a, ToJSON b) => SignedRandomResponse a b -> Value +toJSONRandom srr = + let paramsKeyMap = case toJSON $ params srr of + Object paramsKeyMap' -> paramsKeyMap' + _ -> error "toJSONTandon: no params object!" + hashedApiKey = case Map.lookup "apiKey" paramsKeyMap of + Just hashedApiKey' -> hashedApiKey' + Nothing -> error "toJSONRandom: no apiKey!" + otherParams = Map.delete "apiKey" paramsKeyMap + rr = randomResponse srr + in Object + $ Map.singleton "method" (toJSON $ method srr) + <> Map.singleton "hashedApiKey" hashedApiKey + <> otherParams + <> Map.singleton "data" (toJSON $ randomData rr) + <> Map.singleton "license" (toJSON $ license srr) + <> Map.singleton "licenseData" (toJSON $ licenseData srr) + <> Map.singleton "userData" (toJSON $ userData srr) + <> Map.singleton "ticketData" (toJSON $ ticketData srr) + <> Map.singleton "completionTime" (toJSON $ DateTime $ completionTime rr) + <> Map.singleton "serialNumber" (toJSON $ serialNumber srr) + +-- |Type representing responses from the method of the Signed API yielding +-- new tickets. +newtype CreateTicketsResponse = CreateTicketsResponse [TicketResponse] + deriving (Eq, FromJSON, Generic, Show) + +-- |Type representing ticket responses from the Signed API. +data TicketResponse = TicketResponse + { tr_ticketData :: TicketData + , tr_creationTime :: UTCTime + } deriving (Eq, Show) + +instance FromJSON TicketResponse where + + parseJSON v = do + tr_ticketData <- parseJSON v + withObject + "TicketResponse" + ( \obj -> do + tr_creationTime <- obj .: "creationTime" + pure TicketResponse {..} + ) + v + +-- |Type representing responses from the method of the Signed API revealing +-- tickets. +newtype RevealTicketsResponse = RevealTicketsResponse Int + deriving (Eq, Show) + +instance FromJSON RevealTicketsResponse where + + parseJSON = withObject "RevealTicketsResponse" $ \obj -> + RevealTicketsResponse <$> obj .: "ticketCount" + +-- | Type representing responses from the @listTickets@ or @getTicket@ API +-- methods. +data TicketInfoResponse = TicketInfoResponse + { ltr_ticketResponse :: TicketResponse + , ltr_hashedApiKey :: ApiKey + , ltr_showResult :: Bool + , ltr_usedTime :: Maybe UTCTime + , ltr_expirationTime :: Maybe UTCTime + , ltr_serialNumber :: Maybe Int + } deriving (Eq, Show) + +instance FromJSON TicketInfoResponse where + + parseJSON v = do + ltr_ticketResponse <- parseJSON v + withObject + "ListTicketRespone" + ( \obj -> do + ltr_hashedApiKey <- obj .: "hashedApiKey" + ltr_showResult <- obj .: "showResult" + ltr_usedTime <- obj .: "usedTime" + ltr_expirationTime <- obj .: "expirationTime" + ltr_serialNumber <- obj .: "serialNumber" + pure TicketInfoResponse {..} + ) + v + +-- | Type representing responses from the @verifySignature@ API method. +newtype VerifySignatureResponse = VerifySignatureResponse + { vsr_authenticity :: Bool + } deriving (Eq, Generic, Show) + +instance FromJSON VerifySignatureResponse where + + parseJSON = + genericParseJSON defaultOptions {fieldLabelModifier = drop 4} + +-- | Types representing responses from the @getResult@ API method. +data GetResultResponse + = Integers (SignedRandomResponse [Int] GenIntegersParams) + | IntegerSequences (SignedRandomResponse [[Int]] GenIntegerSequencesParams) + | IntegerSequencesMultiform + (SignedRandomResponse [[Int]] GenIntegerSequencesMultiformParams) + | DecimalFractions (SignedRandomResponse [Double] GenDecimalFractionsParams) + | Gaussians (SignedRandomResponse [Double] GenGaussiansParams) + | Strings (SignedRandomResponse [Text] GenStringsParams) + | UUIDs (SignedRandomResponse [UUID] GenUUIDsParams) + | Blobs (SignedRandomResponse [Blob] GenBlobsParams) + deriving (Eq, Generic, Show) + +instance FromJSON GetResultResponse where + + parseJSON = genericParseJSON defaultOptions {sumEncoding = UntaggedValue} + +-- |Type representing responses from the method of the Basic and Signed API +-- yielding information about the API usage. +data UsageResponse = UsageResponse + { ur_status :: Status + , ur_creationTime :: UTCTime + , ur_bitsLeft :: Int + , ur_requestsLeft :: Int + , ur_totalBits :: Int + , ur_totalRequests :: Int + } deriving (Eq, Generic, Show) + +instance FromJSON UsageResponse where + + parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 3} + +-- | Type representing the statuses of API keys. +data Status + = Running + -- ^ The API key is running. + | Stopped + -- ^ The API key is stopped. + deriving (Eq, Generic, Show) + +instance ToJSON Status where + + toJSON = genericToJSON defaultOptions {constructorTagModifier = map toLower} + + toEncoding = + genericToEncoding defaultOptions {constructorTagModifier = map toLower} + +instance FromJSON Status where + + parseJSON = + genericParseJSON defaultOptions {constructorTagModifier = map toLower} + +api :: Proxy JsonRpcAPI +api = Proxy + +randomDotOrgApi :: BaseUrl +randomDotOrgApi = BaseUrl Https "api.random.org" 443 "" + +-- |Type representing API keys. +newtype Key = Key + { unKey :: ByteString + } deriving (Eq, Show) + +instance ToJSON Key where + + toJSON = String . decodeUtf8 . unKey + toEncoding = unsafeToEncoding . fromByteString . unKey + +instance FromJSON Key where + + parseJSON = withText "Key" (pure . Key . encodeUtf8) + +-- | Type representing API keys or hashed API keys. +data ApiKey + = HashedApiKey ByteString + | ApiKey Key + deriving (Eq, Show) + +instance ToJSON ApiKey where + + toJSON (HashedApiKey hashedApiKey) = String $ decodeUtf8 hashedApiKey + toJSON (ApiKey apiKey) = toJSON apiKey + + toEncoding (HashedApiKey hashedApiKey) = + unsafeToEncoding $ fromByteString hashedApiKey + toEncoding (ApiKey apiKey) = toEncoding apiKey + +-- | Parsing of JSON will prefer the v'HashedApiKey' data constructor to the +-- v'ApiKey' data constructor. That is because the responses from the Signed +-- API include hashed API keys. +instance FromJSON ApiKey where + + parseJSON = withText "ApiKey" (pure . HashedApiKey . encodeUtf8) + +-- |This method generates true random integers within a user-defined range. If +-- successful, the function yields the random data and the advised delay in +-- milliseconds. +genIntegers :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Maybe ([Int], Int)) +genIntegers mgr key = genWithSeedIntegers mgr key Nothing + +-- |This method generates true random integers within a user-defined range. +genIntegers' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Either ClientError (RndResponse [Int])) +genIntegers' mgr key = genWithSeedIntegers' mgr key Nothing + +-- |This method generates true random integers within a user-defined range. If +-- successful, the function yields the random data and the advised delay in +-- milliseconds. +genWithSeedIntegers :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Maybe ([Int], Int)) +genWithSeedIntegers mgr key mSeed replacement n rangeMin rangeMax = + toMaybe <$> genWithSeedIntegers' mgr key mSeed replacement n rangeMin rangeMax + +-- |This method generates true random integers within a user-defined range. +genWithSeedIntegers' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Either ClientError (RndResponse [Int])) +genWithSeedIntegers' mgr key mSeed replacement n rangeMin rangeMax = runClientM + (generateIntegers params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenIntegersParams + { gip_apiKey = ApiKey key + , gip_n = n + , gip_min = rangeMin + , gip_max = rangeMax + , gip_replacement = replacement + , gip_base = 10 + , gip_pregeneratedRandomization = mSeed + } + +generateIntegers :: GenIntegersParams -> ClientM (RndResponse [Int]) + +-- |This method generates true random integers within a user-defined range. +genSignedIntegers :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [Int] GenIntegersParams) +genSignedIntegers mgr key = genWithSeedSignedIntegers mgr key Nothing + +-- |This method generates true random integers within a user-defined range. +genWithSeedSignedIntegers :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of integers requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [Int] GenIntegersParams) +genWithSeedSignedIntegers + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + replacement + n + rangeMin + rangeMax + = runClientM + (generateSignedIntegers params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigIntegersParams + { sgip_params = + GenIntegersParams + { gip_apiKey = ApiKey key + , gip_n = n + , gip_min = rangeMin + , gip_max = rangeMax + , gip_replacement = replacement + , gip_base = 10 + , gip_pregeneratedRandomization = mSeed + } + , sgip_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedIntegers :: + GenSigIntegersParams + -> ClientM (SigRndResponse [Int] GenIntegersParams) + +-- |This method generates sequences of true random integers within a +-- user-defined range. If successful, the function yields the random data and +-- the advised delay in milliseconds. +genIntegerSequences :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Maybe ([[Int]], Int)) +genIntegerSequences mgr key = genWithSeedIntegerSequences mgr key Nothing + +-- |This method generates sequences of true random integers within a +-- user-defined range. +genIntegerSequences' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Either ClientError (RndResponse [[Int]])) +genIntegerSequences' mgr key = genWithSeedIntegerSequences' mgr key Nothing + +-- |This method generates sequences of true random integers within a +-- user-defined range. If successful, the function yields the random data and +-- the advised delay in milliseconds. +genWithSeedIntegerSequences :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Maybe ([[Int]], Int)) +genWithSeedIntegerSequences mgr key mSeed replacement n l rangeMin rangeMax = + toMaybe <$> + genWithSeedIntegerSequences' mgr key mSeed replacement n l rangeMin rangeMax + +-- |This method generates sequences of true random integers within a +-- user-defined range. +genWithSeedIntegerSequences' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (Either ClientError (RndResponse [[Int]])) +genWithSeedIntegerSequences' mgr key mSeed replacement n l rangeMin rangeMax = + runClientM + (generateIntegerSequences params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenIntegerSequencesParams + { gisp_apiKey = ApiKey key + , gisp_n = n + , gisp_length = l + , gisp_min = rangeMin + , gisp_max = rangeMax + , gisp_replacement = replacement + , gisp_base = 10 + , gisp_pregeneratedRandomization = mSeed + } + +generateIntegerSequences :: + GenIntegerSequencesParams + -> ClientM (RndResponse [[Int]]) + +-- |This method generates sequences of true random integers within a +-- user-defined range. +genSignedIntegerSequences :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [[Int]] GenIntegerSequencesParams) +genSignedIntegerSequences mgr key = + genWithSeedSignedIntegerSequences mgr key Nothing + +-- |This method generates sequences of true random integers within a +-- user-defined range. +genWithSeedSignedIntegerSequences :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> Int + -- ^ The length of the sequence. Must be in the range [1, 10,000]. + -> Int + -- ^ The lower boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> Int + -- ^ The upper boundary for the range from which the random integers will + -- be picked. Must be within the range [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [[Int]] GenIntegerSequencesParams) +genWithSeedSignedIntegerSequences + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + replacement + n + l + rangeMin + rangeMax + = runClientM + (generateSignedIntegerSequences params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigIntegerSequencesParams + { sgisp_params = + GenIntegerSequencesParams + { gisp_apiKey = ApiKey key + , gisp_n = n + , gisp_length = l + , gisp_min = rangeMin + , gisp_max = rangeMax + , gisp_replacement = replacement + , gisp_base = 10 + , gisp_pregeneratedRandomization = mSeed + } + , sgisp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedIntegerSequences :: + GenSigIntegerSequencesParams + -> ClientM (SigRndResponse [[Int]] GenIntegerSequencesParams) + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. If successful, the function yields the random data and +-- the advised delay in milliseconds. +genIntegerSequencesMultiform :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacment? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> IO (Maybe ([[Int]], Int)) +genIntegerSequencesMultiform mgr key = + genWithSeedIntegerSequencesMultiform mgr key Nothing + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. +genIntegerSequencesMultiform' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> IO (Either ClientError (RndResponse [[Int]])) +genIntegerSequencesMultiform' mgr key = + genWithSeedIntegerSequencesMultiform' mgr key Nothing + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. If successful, the function yields the random data and +-- the advised delay in milliseconds. +genWithSeedIntegerSequencesMultiform :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> IO (Maybe ([[Int]], Int)) +genWithSeedIntegerSequencesMultiform + mgr + key + mSeed + replacement + n + ls + rangeMin + rangeMax + = toMaybe <$> + genWithSeedIntegerSequencesMultiform' + mgr + key + mSeed + replacement + n + ls + rangeMin + rangeMax + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. +genWithSeedIntegerSequencesMultiform' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range [-1,000,000,000, + -- 1,000,000,000]. + -> IO (Either ClientError (RndResponse [[Int]])) +genWithSeedIntegerSequencesMultiform' + mgr + key + mSeed + replacement + n + ls + rangeMin + rangeMax + = runClientM + (generateIntegerSequencesMultiform params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenIntegerSequencesMultiformParams + { gismp_apiKey = ApiKey key + , gismp_n = n + , gismp_length = ls + , gismp_min = rangeMin + , gismp_max = rangeMax + , gismp_replacement = replacement + , gismp_base = 10 + , gismp_pregeneratedRandomization = mSeed + } + +generateIntegerSequencesMultiform :: + GenIntegerSequencesMultiformParams + -> ClientM (RndResponse [[Int]]) + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. +genSignedIntegerSequencesMultiform :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range + -- [-1,000,000,000, 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range + -- [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [[Int]] GenIntegerSequencesMultiformParams) +genSignedIntegerSequencesMultiform mgr key = + genWithSeedSignedIntegerSequencesMultiform mgr key Nothing + +-- |This method generates multiform sequences of true random integers within a +-- user-defined range. +genWithSeedSignedIntegerSequencesMultiform :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of sequences requested. Must be in the range [1, 10,000]. + -> [Int] + -- ^ The lengths of the sequences. Each must be in the range [1, 10,000]. + -> Boundary + -- ^ The lower boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range + -- [-1,000,000,000, 1,000,000,000]. + -> Boundary + -- ^ The upper boundary (or boundaries) for the range from which the random + -- integers will be picked. Must be within the range + -- [-1,000,000,000, 1,000,000,000]. + -> IO (ClientSigResponse [[Int]] GenIntegerSequencesMultiformParams) +genWithSeedSignedIntegerSequencesMultiform + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + replacement + n + ls + rangeMin + rangeMax + = runClientM + (generateSignedIntegerSequencesMultiform params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigIntegerSequencesMultiformParams + { sgismp_params = + GenIntegerSequencesMultiformParams + { gismp_apiKey = ApiKey key + , gismp_n = n + , gismp_length = ls + , gismp_min = rangeMin + , gismp_max = rangeMax + , gismp_replacement = replacement + , gismp_base = 10 + , gismp_pregeneratedRandomization = mSeed + } + , sgismp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedIntegerSequencesMultiform :: + GenSigIntegerSequencesMultiformParams + -> ClientM (SigRndResponse [[Int]] GenIntegerSequencesMultiformParams) + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. If successful, the function yields the random data and the advised +-- delay in milliseconds. +genDecimalFractions :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (Maybe ([Double], Int)) +genDecimalFractions mgr key = genWithSeedDecimalFractions mgr key Nothing + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. +genDecimalFractions' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (Either ClientError (RndResponse [Double])) +genDecimalFractions' mgr key = genWithSeedDecimalFractions' mgr key Nothing + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. If successful, the function yields the random data and the advised +-- delay in milliseconds. +genWithSeedDecimalFractions :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (Maybe ([Double], Int)) +genWithSeedDecimalFractions mgr key mSeed replacement n dps = + toMaybe <$> genWithSeedDecimalFractions' mgr key mSeed replacement n dps + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. +genWithSeedDecimalFractions' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (Either ClientError (RndResponse [Double])) +genWithSeedDecimalFractions' mgr key mSeed replacement n dps = runClientM + (generateDecimalFractions params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenDecimalFractionsParams + { gdfp_apiKey = ApiKey key + , gdfp_n = n + , gdfp_decimalPlaces = dps + , gdfp_replacement = replacement + , gdfp_pregeneratedRandomization = mSeed + } + +generateDecimalFractions :: + GenDecimalFractionsParams + -> ClientM (RndResponse [Double]) + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. +genSignedDecimalFractions :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range + -- [1, 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (ClientSigResponse [Double] GenDecimalFractionsParams) +genSignedDecimalFractions mgr key = + genWithSeedSignedDecimalFractions mgr key Nothing + +-- |This method generates true random decimal fractions from a uniform +-- distribution across the interval [0, 1) with a user-defined number of decimal +-- places. +genWithSeedSignedDecimalFractions :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of decimal fractions requested. Must be in the range + -- [1, 10,000]. + -> Int + -- ^ The number of decimal places. Must be within the range [1, 14]. + -> IO (ClientSigResponse [Double] GenDecimalFractionsParams) +genWithSeedSignedDecimalFractions + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + replacement + n + dps + = runClientM + (generateSignedDecimalFractions params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigDecimalFractionsParams + { sgdfp_params = + GenDecimalFractionsParams + { gdfp_apiKey = ApiKey key + , gdfp_n = n + , gdfp_decimalPlaces = dps + , gdfp_replacement = replacement + , gdfp_pregeneratedRandomization = mSeed + } + , sgdfp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedDecimalFractions :: + GenSigDecimalFractionsParams + -> ClientM (SigRndResponse [Double] GenDecimalFractionsParams) + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. If +-- successful, the function yields the random data and the advised delay in +-- milliseconds. +genGaussians :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random numbers requested. Must be in the range [1, + -- 10,000]. + -> Double + -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double + -- ^ The standard deviation. Must be in the range [-1,000,000, 1,000,000]. + -> Int + -- ^ The number of significant digits. Must be within the range [2, 14]. + -> IO (Maybe ([Double], Int)) +genGaussians mgr key = genWithSeedGaussians mgr key Nothing + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. +genGaussians' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random numbers requested. Must be in the range [1, + -- 10,000]. + -> Double + -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double + -- ^ The standard deviation. Must be in the range [-1,000,000, 1,000,000]. + -> Int + -- ^ The number of significant digits. Must be within the range [2, 14]. + -> IO (Either ClientError (RndResponse [Double])) +genGaussians' mgr key = genWithSeedGaussians' mgr key Nothing + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. If +-- successful, the function yields the random data and the advised delay in +-- milliseconds. +genWithSeedGaussians :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int -- ^ The number of random numbers requested. Must be in the range + -- [1, 10,000]. + -> Double -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double -- ^ The standard deviation. Must be in the range [-1,000,000, + -- 1,000,000]. + -> Int -- ^ The number of significant digits. Must be within the range + -- [2, 14]. + -> IO (Maybe ([Double], Int)) +genWithSeedGaussians mgr key mSeed n mean sd sds = + toMaybe <$> genWithSeedGaussians' mgr key mSeed n mean sd sds + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. +genWithSeedGaussians' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int + -- ^ The number of random numbers requested. Must be in the range [1, + -- 10,000]. + -> Double + -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double + -- ^ The standard deviation. Must be in the range [-1,000,000, 1,000,000]. + -> Int + -- ^ The number of significant digits. Must be within the range [2, 14]. + -> IO (Either ClientError (RndResponse [Double])) +genWithSeedGaussians' mgr key mSeed n mean sd sds = runClientM + (generateGaussians params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenGaussiansParams + { ggp_apiKey = ApiKey key + , ggp_n = n + , ggp_mean = mean + , ggp_standardDeviation = sd + , ggp_significantDigits = sds + , ggp_pregeneratedRandomization = mSeed + } + +generateGaussians :: GenGaussiansParams -> ClientM (RndResponse [Double]) + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. +genSignedGaussians :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random numbers requested. Must be in the range + -- [1, 10,000]. + -> Double + -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double + -- ^ The standard deviation. Must be in the range [-1,000,000, 1,000,000]. + -> Int + -- ^ The number of significant digits. Must be within the range [2, 14]. + -> IO (ClientSigResponse [Double] GenGaussiansParams) +genSignedGaussians mgr key = genWithSeedSignedGaussians mgr key Nothing + +-- |This method generates true random numbers from a Gaussian distribution (also +-- known as a normal distribution). The method uses a Box-Muller Transform to +-- generate the Gaussian distribution from uniformly distributed numbers. +genWithSeedSignedGaussians :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random numbers requested. Must be in the range + -- [1, 10,000]. + -> Double + -- ^ The mean. Must be in the range [-1,000,000, 1,000,000]. + -> Double + -- ^ The standard deviation. Must be in the range [-1,000,000, 1,000,000]. + -> Int + -- ^ The number of significant digits. Must be within the range [2, 14]. + -> IO (ClientSigResponse [Double] GenGaussiansParams) +genWithSeedSignedGaussians + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + n + mean + sd + sds + = runClientM + (generateSignedGaussians params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigGaussiansParams + { sggp_params = + GenGaussiansParams + { ggp_apiKey = ApiKey key + , ggp_n = n + , ggp_mean = mean + , ggp_standardDeviation = sd + , ggp_significantDigits = sds + , ggp_pregeneratedRandomization = mSeed + } + , sggp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedGaussians :: + GenSigGaussiansParams + -> ClientM (SigRndResponse [Double] GenGaussiansParams) + +-- |This method generates true random strings. If successful, the function +-- yields the random data and the advised delay in milliseconds. +genStrings :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (Maybe ([Text], Int)) +genStrings mgr key = genWithSeedStrings mgr key Nothing + +-- |This method generates true random strings. +genStrings' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (Either ClientError (RndResponse [Text])) +genStrings' mgr key = genWithSeedStrings' mgr key Nothing + +-- |This method generates true random strings. If successful, the function +-- yields the random data and the advised delay in milliseconds. +genWithSeedStrings :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (Maybe ([Text], Int)) +genWithSeedStrings mgr key mSeed replacement n l cs = + toMaybe <$> genWithSeedStrings' mgr key mSeed replacement n l cs + +-- |This method generates true random strings. +genWithSeedStrings' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range [1, + -- 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (Either ClientError (RndResponse [Text])) +genWithSeedStrings' mgr key mSeed replacement n l cs = runClientM + (generateStrings params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenStringsParams + { gsp_apiKey = ApiKey key + , gsp_n = n + , gsp_length = l + , gsp_characters = cs + , gsp_replacement = replacement + , gsp_pregeneratedRandomization = mSeed + } + +generateStrings :: GenStringsParams -> ClientM (RndResponse [Text]) + +-- |This method generates true random strings. +genSignedStrings :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range + -- [1, 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (ClientSigResponse [Text] GenStringsParams) +genSignedStrings mgr key = genWithSeedSignedStrings mgr key Nothing + +-- |This method generates true random strings. +genWithSeedSignedStrings :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Bool + -- ^ With replacement? + -> Int + -- ^ The number of random strings requested. Must be in the range + -- [1, 10,000]. + -> Int + -- ^ The length of each string. Must be in the range [1, 32]. + -> [Char] + -- ^ The set of characters that are allowed to occur in the random strings. + -- The maximum number of characters is 128. + -> IO (ClientSigResponse [Text] GenStringsParams) +genWithSeedSignedStrings + mgr + key + mSeed + mLicenseData + mUserData + mTicketId + replacement + n + l + cs + = runClientM + (generateSignedStrings params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigStringsParams + { sgsp_params = + GenStringsParams + { gsp_apiKey = ApiKey key + , gsp_n = n + , gsp_length = l + , gsp_characters = cs + , gsp_replacement = replacement + , gsp_pregeneratedRandomization = mSeed + } + , sgsp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedStrings :: + GenSigStringsParams + -> ClientM (SigRndResponse [Text] GenStringsParams) + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. If successful, the +-- function yields the random data and the advised delay in milliseconds. +genUUIDs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range [1, + -- 10,000]. + -> IO (Maybe ([UUID], Int)) +genUUIDs mgr key = genWithSeedUUIDs mgr key Nothing + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. +genUUIDs' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range [1, + -- 10,000]. + -> IO (Either ClientError (RndResponse [UUID])) +genUUIDs' mgr key = genWithSeedUUIDs' mgr key Nothing + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. If successful, the +-- function yields the random data and the advised delay in milliseconds. +genWithSeedUUIDs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range [1, + -- 10,000]. + -> IO (Maybe ([UUID], Int)) +genWithSeedUUIDs mgr key mSeed n = toMaybe <$> genWithSeedUUIDs' mgr key mSeed n + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. +genWithSeedUUIDs' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range [1, + -- 10,000]. + -> IO (Either ClientError (RndResponse [UUID])) +genWithSeedUUIDs' mgr key mSeed n = runClientM + (generateUUIDs params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenUUIDsParams + { gup_apiKey = ApiKey key + , gup_n = n + , gup_pregeneratedRandomization = mSeed + } + +generateUUIDs :: GenUUIDsParams -> ClientM (RndResponse [UUID]) + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. +genSignedUUIDs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range + -- [1, 10,000]. + -> IO (ClientSigResponse [UUID] GenUUIDsParams) +genSignedUUIDs mgr key = genWithSeedSignedUUIDs mgr key Nothing + +-- |This method generates true random version 4 Universally Unique IDentifiers +-- (UUIDs) in accordance with section 4.4 of RFC 4122. +genWithSeedSignedUUIDs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random UUIDs requested. Must be in the range + -- [1, 10,000]. + -> IO (ClientSigResponse [UUID] GenUUIDsParams) +genWithSeedSignedUUIDs mgr key mSeed mLicenseData mUserData mTicketId n = + runClientM + (generateSignedUUIDs params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigUUIDsParams + { sgup_params = + GenUUIDsParams + { gup_apiKey = ApiKey key + , gup_n = n + , gup_pregeneratedRandomization = mSeed + } + , sgup_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedUUIDs :: + GenSigUUIDsParams + -> ClientM (SigRndResponse [UUID] GenUUIDsParams) + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +-- If successful, the function yields the random data and the advised delay in +-- milliseconds. +genBlobs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes. Must be in the range [1, + -- 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (Maybe ([Blob], Int)) +genBlobs mgr key = genWithSeedBlobs mgr key Nothing + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +genBlobs' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes (not bits). Must be in the + -- range [1, 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (Either ClientError (RndResponse [Blob])) +genBlobs' mgr key = genWithSeedBlobs' mgr key Nothing + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +-- If successful, the function yields the random data and the advised delay in +-- milliseconds. +genWithSeedBlobs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes. Must be in the range [1, + -- 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (Maybe ([Blob], Int)) +genWithSeedBlobs mgr key mSeed n s f = + toMaybe <$> genWithSeedBlobs' mgr key mSeed n s f + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +genWithSeedBlobs' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes (not bits). Must be in the + -- range [1, 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (Either ClientError (RndResponse [Blob])) +genWithSeedBlobs' mgr key mSeed n s f = runClientM + (generateBlobs params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenBlobsParams + { gbp_apiKey = ApiKey key + , gbp_n = n + , gbp_size = s * 8 + , gbp_format = f + , gbp_pregeneratedRandomization = mSeed + } + +generateBlobs :: GenBlobsParams -> ClientM (RndResponse [Blob]) + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +genSignedBlobs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes (not bits). Must be in the + -- range [1, 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (ClientSigResponse [Blob] GenBlobsParams) +genSignedBlobs mgr key = genWithSeedSignedBlobs mgr key Nothing + +-- |This method generates true random Binary Large OBjects (BLOBs). The total +-- size of all BLOBs requested must not exceed 131,072 bytes (128 kilobytes). +genWithSeedSignedBlobs :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Maybe Seed + -- ^ The optional seed. + -> Maybe LicenseData + -- ^ Data, if any, of relevance to the license that is associated with the + -- API key. + -> Maybe Object + -- ^ Optional user data to be included in the signed response. + -> Maybe TicketId + -- ^ Optional unique ticket ID. Can be used only once. + -> Int + -- ^ The number of random BLOBs requested. Must be in the range [1, 100]. + -> Int + -- ^ The size of each blob, measured in bytes (not bits). Must be in the + -- range [1, 131,072]. + -> BlobFormat + -- ^ The format of the BLOBs. + -> IO (ClientSigResponse [Blob] GenBlobsParams) +genWithSeedSignedBlobs mgr key mSeed mLicenseData mUserData mTicketId n s f = + runClientM + (generateSignedBlobs params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GenSigBlobsParams + { sgbp_params = + GenBlobsParams + { gbp_apiKey = ApiKey key + , gbp_n = n + , gbp_size = s * 8 + , gbp_format = f + , gbp_pregeneratedRandomization = mSeed + } + , sgbp_data = + SignedData mLicenseData mUserData mTicketId + } + +generateSignedBlobs :: + GenSigBlobsParams + -> ClientM (SigRndResponse [Blob] GenBlobsParams) + +-- |Helper function to help simplify method functions +toMaybe :: Either ClientError (RndResponse a) -> Maybe (a, Int) +toMaybe (Right (Result _ result')) = + Just (randomData result', advisoryDelay result') +toMaybe _ = Nothing + +-- | Retrieve a previously generated result from its serial number. +getResult :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key. + -> Int + -- ^ The serial number. + -> IO (Either ClientError (JsonRpcResponse Value GetResultResponse)) +getResult mgr key serialNumber = runClientM + (getResult' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GetResultParams + { grp_apiKey = key + , grp_serialNumber = serialNumber + } + +getResult' :: + GetResultParams + -> ClientM (JsonRpcResponse Value GetResultResponse) + +-- | Create unique tickets for use with the Signed API. +createTickets :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> Int + -- ^ The number of tickets requested. Must be in the range [1, 50]. + -> Bool + -- ^ Make full information about the ticket available? + -> IO [TicketResponse] +createTickets mgr key n showResult = + createTickets' mgr key n showResult >>= \case + Right (Result _ (CreateTicketsResponse ticketResponses)) -> + pure ticketResponses + _ -> pure [] + +-- | Create unique tickets for use with the Signed API. +createTickets' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> Int + -- ^ The number of tickets requested. Must be in the range [1, 50]. + -> Bool + -- ^ Make full information about the ticket available? + -> IO (Either ClientError (JsonRpcResponse Value CreateTicketsResponse)) +createTickets' mgr key n showResult = runClientM + (createTickets'' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = CreateTicketsParams + { ctp_apiKey = key + , ctp_n = n + , ctp_showResult = showResult + } + +createTickets'' :: + CreateTicketsParams + -> ClientM (JsonRpcResponse Value CreateTicketsResponse) + +-- | This method enables other methods to reveal greater information about the +-- given ticket. +revealTickets :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> TicketId + -- ^ The ticketId to reveal. + -> IO (Maybe Int) +revealTickets mgr key ticketId = + revealTickets' mgr key ticketId >>= \case + Right (Result _ (RevealTicketsResponse ticketCount)) -> + pure $ Just ticketCount + _ -> pure Nothing + +-- | This method enables other methods to reveal greater information about the +-- given ticket. +revealTickets' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> TicketId + -- ^ The ticketId to reveal. + -> IO (Either ClientError (JsonRpcResponse Value RevealTicketsResponse)) +revealTickets' mgr key ticketId = runClientM + (revealTickets'' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = RevealTicketsParams + { rtp_apiKey = key + , rtp_ticketId = ticketId + } + +revealTickets'' :: + RevealTicketsParams + -> ClientM (JsonRpcResponse Value RevealTicketsResponse) + +-- | This method enables other methods to reveal greater information about the +-- given ticket. +listTickets :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> TicketType + -- ^ The type of tickets to obtain information about. + -> IO [TicketInfoResponse] +listTickets mgr key ticketType = + listTickets' mgr key ticketType >>= \case + Right (Result _ listTicketsResponses) -> + pure listTicketsResponses + _ -> pure [] + +-- | This method enables other methods to reveal greater information about the +-- given ticket. +listTickets' :: + Manager + -- ^ The connection manager. + -> Key + -- ^ The API key + -> TicketType + -- ^ The type of tickets to obtain information about. + -> IO (Either ClientError (JsonRpcResponse Value [TicketInfoResponse])) +listTickets' mgr key ticketType = runClientM + (listTickets'' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = ListTicketsParams + { ltp_apiKey = key + , ltp_ticketType = ticketType + } + +listTickets'' :: + ListTicketsParams + -> ClientM (JsonRpcResponse Value [TicketInfoResponse]) + +-- | This method yields information about the given ticket. +getTicket :: + Manager + -- ^ The connection manager. + -> TicketId + -- ^ The ticket to obtain information about. + -> IO (Maybe TicketInfoResponse) +getTicket mgr ticketId = + getTicket' mgr ticketId >>= \case + Right (Result _ ticketInfoResponse) -> + pure $ Just ticketInfoResponse + _ -> pure Nothing + +-- | This method yields information about the given ticket. +getTicket' :: + Manager + -- ^ The connection manager. + -> TicketId + -- ^ The ticket to obtain information about. + -> IO (Either ClientError (JsonRpcResponse Value TicketInfoResponse)) +getTicket' mgr ticketId = runClientM (getTicket'' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GetTicketParams + { gtp_ticketId = ticketId + } + +getTicket'' :: + GetTicketParams + -> ClientM (JsonRpcResponse Value TicketInfoResponse) + +-- | This method verifies a response from the Signed API. +verifySignedResponse :: + (ToJSON a, ToJSON b) + => Manager + -- ^ The connection manager. + -> SignedRandomResponse a b + -- ^ The ticket to obtain information about. + -> IO (Maybe Bool) +verifySignedResponse mgr srr = + verifySignedResponse' mgr srr >>= \case + Right (Result _ vsr) -> + pure $ Just $ vsr_authenticity vsr + _ -> pure Nothing + +-- | This method verifies a response from the Signed API. +verifySignedResponse' :: + (ToJSON a, ToJSON b) + => Manager + -- ^ The connection mannager. + -> SignedRandomResponse a b + -- ^ The ticket to obtain information about. + -> IO (Either ClientError (JsonRpcResponse Value VerifySignatureResponse)) +verifySignedResponse' mgr srr = runClientM + (verifySignature params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = VerifySignatureParams + { vsp_random = toJSONRandom srr + , vsp_signature = signature srr + } + +verifySignature :: + VerifySignatureParams + -> ClientM (JsonRpcResponse Value VerifySignatureResponse) + +-- |This method returns information related to the usage of a given API key. +getUsage :: + Manager -- ^ The connection manager. + -> Key -- ^ The API key + -> IO (Maybe UsageResponse) +getUsage mgr key = + getUsage' mgr key >>= \case + Right (Result _ usageResponse) -> pure $ Just usageResponse + _ -> pure Nothing + +-- |This method returns information related to the usage of a given API key. +getUsage' :: + Manager -- ^ The connection manager. + -> Key -- ^ The API key + -> IO (Either ClientError (JsonRpcResponse Value UsageResponse)) +getUsage' mgr key = runClientM + (getUsage'' params) +-- middleware supported from servant-client-0.20.2 +#if MIN_VERSION_servant_client(0,20,2) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest id) +-- makeClientRequest supported from servant-client-0.17 +#elif MIN_VERSION_servant_client(0,17,0) + (ClientEnv mgr randomDotOrgApi Nothing defaultMakeClientRequest) +#else + (ClientEnv mgr randomDotOrgApi Nothing) +#endif + where + params = GetUsageParams + { usep_apiKey = key + } + +getUsage'' :: GetUsageParams -> ClientM (JsonRpcResponse Value UsageResponse) + +generateIntegers + :<|> generateIntegerSequences + :<|> generateIntegerSequencesMultiform + :<|> generateDecimalFractions + :<|> generateGaussians + :<|> generateStrings + :<|> generateUUIDs + :<|> generateBlobs + :<|> generateSignedIntegers + :<|> generateSignedIntegerSequences + :<|> generateSignedIntegerSequencesMultiform + :<|> generateSignedDecimalFractions + :<|> generateSignedGaussians + :<|> generateSignedStrings + :<|> generateSignedUUIDs + :<|> generateSignedBlobs + :<|> getResult' + :<|> createTickets'' + :<|> revealTickets'' + :<|> listTickets'' + :<|> getTicket'' + :<|> verifySignature + :<|> getUsage'' + = client api
+ src/System/Random/Atmospheric/Api/DateTime.hs view
@@ -0,0 +1,188 @@+{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE TupleSections #-} + +{-| +Module : System.Random.Atmospheric.Api.DateTime +Description : Date and time format used by the RANDOM.ORG Core API (Release 4) +Copyright : Copyright 2024 Mike Pilgrem (except as indicated) +License : BSD-3-Clause +Maintainer : public@pilgrem.com +Stability : Experimental +Portability : Portable + +The output of the [RANDOM.ORG](https://random.org) Core API (Release 4) uses a +date and time format that is allowed by RFC 3999 but not permitted by ISO 8601. + +This module has no connection with Randomness and Integrity Services Limited or +its affilates or the RANDOM.ORG domain. +-} + +module System.Random.Atmospheric.Api.DateTime + ( DateTime (..) + ) where + +import Data.Aeson.Encoding ( encodingToLazyByteString ) +import Data.Aeson.Encoding.Internal ( Encoding' (..) ) +import Data.Aeson.Types ( ToJSON (..), Value (..) ) +import Data.ByteString.Builder ( Builder, char7, char8, integerDec) +import Data.ByteString.Builder.Prim + ( BoundedPrim, (>$<), (>*<), condB, emptyB + , liftFixedToBounded, primBounded + ) +import qualified Data.ByteString.Builder.Prim as BP +import qualified Data.ByteString.Lazy as L +import Data.Char ( chr ) +import Data.Int ( Int64 ) +import Data.Text ( Text ) +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import Data.Time.Calendar ( Day, toGregorian ) +import Data.Time.Clock + ( DiffTime, UTCTime (..), diffTimeToPicoseconds ) + +-- | Type representing UTC date and times but with a different 'ToJSON' +-- instance that uses a version of ISO 8601 modified to use an alternative +-- allowed by RFC 3999. +newtype DateTime = DateTime + { unDateTime :: UTCTime + } + +instance ToJSON DateTime where + + toJSON = stringEncoding . Encoding . quote . utcTime . unDateTime + + toEncoding = Encoding . quote . utcTime . unDateTime + +-- | Modified version of ISO 8601 to use an alternative allowed by RFC 3999. +dayTime :: Day -> TimeOfDay64 -> Builder +dayTime d t = day d <> delimiter <> timeOfDay64 t + where + delimiter = char7 ' ' + -- ISO 8601 requires the delimiter to be 'T' but RFC 3999 allows the + -- delimiter to be ' '. +{-# INLINE dayTime #-} + +-------------------------------------------------------------------------------- +-- The following is based on module Data.Aeson.Encoding.Builder of the package +-- aeson-2.2.3.0, copyright 2011 MailRank, Inc. and 2013 Simon Meier. +-------------------------------------------------------------------------------- + +-- | Encode something to a JSON string. +stringEncoding :: Encoding' Text -> Value +stringEncoding = String + . T.dropAround (== '"') + . T.decodeLatin1 + . L.toStrict + . encodingToLazyByteString +{-# INLINE stringEncoding #-} + +-- | Add quotes surrounding a builder +quote :: Builder -> Builder +quote b = char8 '"' <> b <> char8 '"' + +utcTime :: UTCTime -> Builder +utcTime (UTCTime d s) = dayTime d (diffTimeOfDay64 s) <> char7 'Z' +{-# INLINE utcTime #-} + +day :: Day -> Builder +day dd = + encodeYear yr + <> primBounded (ascii6 ('-', (mh, (ml, ('-', (dh, dl)))))) () + where + (yr,m,d) = toGregorian dd + !(T mh ml) = twoDigits m + !(T dh dl) = twoDigits d +{-# INLINE day #-} + +-- | Used in encoding day, month, quarter +encodeYear :: Integer -> Builder +encodeYear y + | y >= 1000 = integerDec y + | y >= 0 = primBounded (ascii4 (padYear y)) () + | y >= -999 = primBounded (ascii5 ('-', padYear (- y))) () + | otherwise = integerDec y + where + padYear y' = + let (ab, c) = fromIntegral y' `quotRem` 10 + (a, b) = ab `quotRem` 10 + in ('0', (digit a, (digit b, digit c))) +{-# INLINE encodeYear #-} + +ascii4 :: (Char, (Char, (Char, Char))) -> BoundedPrim a +ascii4 cs = liftFixedToBounded $ const cs >$< + BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 +{-# INLINE ascii4 #-} + +ascii5 :: (Char, (Char, (Char, (Char, Char)))) -> BoundedPrim a +ascii5 cs = liftFixedToBounded $ const cs >$< + BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 +{-# INLINE ascii5 #-} + +ascii6 :: (Char, (Char, (Char, (Char, (Char, Char))))) -> BoundedPrim a +ascii6 cs = liftFixedToBounded $ const cs >$< + BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 +{-# INLINE ascii6 #-} + +ascii8 :: + (Char, (Char, (Char, (Char, (Char, (Char, (Char, Char))))))) + -> BoundedPrim a +ascii8 cs = liftFixedToBounded $ const cs >$< + BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< BP.char7 >*< + BP.char7 >*< BP.char7 +{-# INLINE ascii8 #-} + +twoDigits :: Int -> T +twoDigits a = T (digit hi) (digit lo) + where + (hi, lo) = a `quotRem` 10 + +digit :: Int -> Char +digit x = chr (x + 48) + +data T = T {-# UNPACK #-} !Char {-# UNPACK #-} !Char + +timeOfDay64 :: TimeOfDay64 -> Builder +timeOfDay64 (TOD h m s) + | frac == 0 = hhmmss -- omit subseconds if 0 + | otherwise = hhmmss <> primBounded showFrac frac + where + hhmmss = + primBounded (ascii8 (hh, (hl, (':', (mh, (ml, (':', (sh, sl)))))))) () + !(T hh hl) = twoDigits h + !(T mh ml) = twoDigits m + !(T sh sl) = twoDigits (fromIntegral real) + (real,frac) = s `quotRem` pico + showFrac = ('.',) >$< (liftFixedToBounded BP.char7 >*< trunc12) + trunc12 = (`quotRem` micro) >$< + condB (\(_, y) -> y == 0) (fst >$< trunc6) (digits6 >*< trunc6) + digits6 = ((`quotRem` milli) . fromIntegral) >$< (digits3 >*< digits3) + trunc6 = ((`quotRem` milli) . fromIntegral) >$< + condB (\(_, y) -> y == 0) (fst >$< trunc3) (digits3 >*< trunc3) + digits3 = (`quotRem` 10) >$< (digits2 >*< digits1) + digits2 = (`quotRem` 10) >$< (digits1 >*< digits1) + digits1 = liftFixedToBounded (digit >$< BP.char7) + trunc3 = condB (== 0) emptyB $ + (`quotRem` 100) >$< (digits1 >*< trunc2) + trunc2 = condB (== 0) emptyB $ + (`quotRem` 10) >$< (digits1 >*< trunc1) + trunc1 = condB (== 0) emptyB digits1 + + pico = 1000000000000 -- number of picoseconds in 1 second + micro = 1000000 -- number of microseconds in 1 second + milli = 1000 -- number of milliseconds in 1 second + +data TimeOfDay64 = TOD {-# UNPACK #-} !Int + {-# UNPACK #-} !Int + {-# UNPACK #-} !Int64 + +posixDayLength :: DiffTime +posixDayLength = 86400 + +diffTimeOfDay64 :: DiffTime -> TimeOfDay64 +diffTimeOfDay64 t + | t >= posixDayLength = TOD 23 59 (60000000000000 + pico (t - posixDayLength)) + | otherwise = TOD (fromIntegral h) (fromIntegral m) s + where + (h, mp) = pico t `quotRem` 3600000000000000 + (m, s) = mp `quotRem` 60000000000000 + pico = fromIntegral . diffTimeToPicoseconds
+ stack-ghc-8.10.7.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-18.28 # GHC 8.10.7 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-8.4.4.yaml view
@@ -0,0 +1,13 @@+snapshot: lts-12.26 # GHC 8.4.4 + +extra-deps: +# lts-12.26 provides Cabal-2.2.0.1 +- Cabal-2.4.0.0@sha256:5c6b0304560bce113669c04a7eab6adc72b5f17dbf6861d9c06eb51d19471d00,21190 +# lts-12.26 provides aeson-1.3.1.1 +- aeson-1.4.1.0@sha256:1abae3de05312cfd31eec28070ae3fdc4b324c2fbc375b4f9675ff94dc48aff7,6378 +# lts-12.26 provides base-orphans-0.7 +- base-orphans-0.8.1@sha256:defd0057b5db93257528d89b5b01a0fee9738e878c121c686948ac4aa5dded63,2927 +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171 +# lts-12.26 provides time-compat-0.1.0.3 +- time-compat-1.9.2@sha256:3aef4356d3663caf0a490e1deafad051d0f2baafb1375b1c60900c0bcf09cf3b,2501
+ stack-ghc-8.6.5.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-14.27 # GHC 8.6.5 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-8.8.4.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-16.31 # GHC 8.8.4 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-9.0.2.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-19.33 # GHC 9.0.2 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-9.10.1.yaml view
@@ -0,0 +1,26 @@+snapshot: nightly-2024-10-11 # GHC 9.8.2 +compiler: ghc-9.10.1 + +extra-deps: +# Specified, as pruned +- Win32-2.14.0.0@sha256:e34af84fec733b5c0c8f052ec39499785e719e2fbbe308983adf26c82ea3704d,5942 +# Specified, as pruned +- directory-1.3.8.3@sha256:0aa305acf5d6026647a5f7461ff81d65cffdf6082790ab0bf70763a4f2bdfe6c,3306 +# Specified, as pruned +- filepath-1.5.2.0@sha256:8af7a843cba7eddc8d44ae94002b766ee8c23cbcd3ecdb2cc79ee6e0a694419a,5178 +# Specified, as pruned +- process-1.6.19.0@sha256:807bfa9b4038b59ae0c362bd94a783f898fbe0b42dbe1f2ede3c392bf2b8727d,3148 +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171 +# Specified, as pruned +- time-1.12.2@sha256:88e8493d9130038d3b9968a2530a0900141cd3d938483c83dde56e12b875ebc8,6510 +# Specified, as pruned +- unix-2.8.5.1@sha256:3f702a252a313a7bcb56e3908a14e7f9f1b40e41b7bdc8ae8a9605a1a8686f06,9808 + +flags: + Win32: + os-string: true + directory: + os-string: true + unix: + os-string: true
+ stack-ghc-9.2.8.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-20.26 # GHC 9.2.8 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-9.4.8.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-21.25 # GHC 9.4.8 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-9.6.6.yaml view
@@ -0,0 +1,5 @@+snapshot: lts-22.36 # GHC 9.6.6 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171
+ stack-ghc-9.8.2.yaml view
@@ -0,0 +1,5 @@+snapshot: nightly-2024-10-04 # GHC 9.8.2 + +extra-deps: +- servant-jsonrpc-1.2.0@sha256:595a37f4966ce4580813efa889d26165061225778b8ab91b4a88bc3575cbd1bb,1339 +- servant-jsonrpc-client-1.2.0@sha256:b89aa1e30a781aa3164d40a367e7c1a6672d498f4f46d6ad45673ce2fe22b445,1171