approveapi: ApproveAPI Haskell Client

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Haskell client for the ApproveAPI HTTP API ApproveAPI is a simple API to request a user's real-time approval on anything via email, sms + mobile push. category: Web


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.0, 0.1.3.0
Change log None available
Dependencies aeson (>=1.0 && <2.0), base (>=4.7 && <5.0), base64-bytestring (>1.0 && <2.0), bytestring (>=0.10.0 && <0.11), case-insensitive (>=1.2.0 && <1.3), containers (>=0.5.0.0 && <0.6), deepseq (>=1.4 && <1.6), exceptions (>=0.10.0 && <0.11), http-api-data (>=0.3.4 && <0.4), http-client (==0.5.*), http-client-tls (>=0.3.5 && <0.4), http-media (>=0.4 && <0.8), http-types (>=0.8 && <0.13), iso8601-time (>=0.1.3 && <0.2.0), katip (>=0.4 && <0.9), microlens (>=0.4.3 && <0.5), mtl (>=2.2.2 && <2.3), network (>=2.6.2 && <2.8), random (==1.1.*), safe-exceptions (<0.2), text (>=0.11 && <1.3), time (>=1.5 && <1.10), transformers (>=0.4.0.0 && <0.6), unordered-containers (>=0.2.9 && <0.3), vector (>=0.10.9 && <0.13) [details]
License MIT
Copyright 2019 - ApproveAPI
Author Kevin King
Maintainer dev@approveapi.com
Category API, Client
Home page https://approveapi.com
Uploaded by kcking at 2019-03-22T21:28:40Z

Modules

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for approveapi-0.1.0.0

[back to package description]

approveapi-haskell

Haskell API bindings for the ApproveAPI HTTP API.

ApproveAPI is a simple API to request a user's real-time approval on anything via email, sms + mobile push.

Getting Started

To get started, we create a config:

import qualified ApproveApi as A
...
config <- (`A.addAuthMethod` A.AuthBasicApiKey "sk_test_yourapikeyhere" "")
          <$> A.newConfig 

Now we can make API calls. For example, let's send an approval prompt to confirm a financial transaction.

import qualified Network.HTTP.Client.TLS as NH
...
let body = "Your AcmeBank credit card was just charged $3249.99 at APPLE STORE,\
\ San Francisco. Authorize this transaction?"
let prompt = (A.mkCreatePromptRequest "alice@approveapi.com" body) {
                A.createPromptRequestLongPoll = Just True,
		            A.createPromptRequestApproveText = Just "Authorize",
		            A.createPromptRequestRejectText = Just "Reject"
              }
let createPromptRequest = A.createPrompt prompt

mgr <- NH.newTlsManager
createPromptResponse <- A.dispatchMime mgr config createPromptRequest

flip mapM_ createPromptResponse (\r ->
  case A.promptAnswer r of 
    Nothing -> putStrLn $ "No response yet"
    Just answer -> case A.promptAnswerResult answer of
      True -> putStrLn $ "Request approved"
      False -> putStrLn $ "Request rejected"
  )

Documentation

Full documentation is available here: approveapi.com/docs.