Copyright | (c) 2015, GetShopTV |
---|---|
License | BSD3 |
Maintainer | nickolay@getshoptv.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module describes SMSAero API and defines corresponding types.
- type SMSAeroAPI = RequireAuth :> (AnswerJson :> (("send" :> SendApi) :<|> (("status" :> StatusApi) :<|> (("balance" :> SmsAeroGet BalanceResponse) :<|> (("senders" :> SmsAeroGet SendersResponse) :<|> ("sign" :> SmsAeroGet SignResponse))))))
- type SendApi = RequiredQueryParam "to" Phone :> (RequiredQueryParam "text" Text :> (RequiredQueryParam "from" Signature :> (QueryParam "date" SMSAeroDate :> SmsAeroGet SendResponse)))
- type StatusApi = RequiredQueryParam "id" MessageId :> SmsAeroGet StatusResponse
- data SmsAeroJson
- data AnswerJson
- data RequireAuth
- data RequiredQueryParam sym a
- type SmsAeroGet a = Get `[SmsAeroJson]` (SmsAeroResponse a)
- data SMSAeroAuth = SMSAeroAuth {
- authUser :: Text
- authPassword :: Text
- newtype Signature = Signature {
- getSignature :: Text
- newtype MessageId = MessageId Integer
- newtype Phone = Phone {}
- newtype SMSAeroDate = SMSAeroDate {}
- data SmsAeroResponse a
- = ResponseOK a
- | ResponseReject Text
- data SendResponse
- data StatusResponse
- newtype BalanceResponse = BalanceResponse Double
- newtype SendersResponse = SendersResponse [Signature]
- data SignResponse
API
type SMSAeroAPI = RequireAuth :> (AnswerJson :> (("send" :> SendApi) :<|> (("status" :> StatusApi) :<|> (("balance" :> SmsAeroGet BalanceResponse) :<|> (("senders" :> SmsAeroGet SendersResponse) :<|> ("sign" :> SmsAeroGet SignResponse)))))) Source
SMSAero API.
type SendApi = RequiredQueryParam "to" Phone :> (RequiredQueryParam "text" Text :> (RequiredQueryParam "from" Signature :> (QueryParam "date" SMSAeroDate :> SmsAeroGet SendResponse))) Source
SMSAero API to send a message.
type StatusApi = RequiredQueryParam "id" MessageId :> SmsAeroGet StatusResponse Source
SMSAero API to check message status.
Combinators
data SmsAeroJson Source
Content type for SMSAero JSON answer (it has JSON body but "text/plain" Content-Type).
Accept * SmsAeroJson | |
FromJSON a => MimeUnrender * SmsAeroJson a |
data AnswerJson Source
Implicit parameter that tells SMSAero to respond with JSON.
HasClient sub => HasClient ((:>) * * AnswerJson sub) | |
type Client ((:>) * * AnswerJson sub) = Client sub |
data RequireAuth Source
SMSAero authentication credentials.
HasClient sub => HasClient ((:>) * * RequireAuth sub) | |
type Client ((:>) * * RequireAuth sub) = SMSAeroAuth -> Client sub |
data RequiredQueryParam sym a Source
Like QueryParam
, but always required.
(HasClient sub, KnownSymbol sym, ToText a) => HasClient ((:>) * * (RequiredQueryParam sym a) sub) | |
type Client ((:>) * * (RequiredQueryParam sym a) sub) = a -> Client sub |
type SmsAeroGet a = Get `[SmsAeroJson]` (SmsAeroResponse a) Source
Regular SMSAero GET API.
Types
data SMSAeroAuth Source
SMSAero authentication data.
SMSAeroAuth | |
|
SMSAero sender's signature. This is used for the "from" field.
SMSAero sent message id.
newtype SMSAeroDate Source
Date. Textually SMSAeroDate
is represented as a number of seconds since 01 Jan 1970.
Responses
data SmsAeroResponse a Source
Every SMSAero response is either rejected or provides some info.
ResponseOK a | Some useful payload. |
ResponseReject Text | Rejection reason. |
Show a => Show (SmsAeroResponse a) | |
Generic (SmsAeroResponse a) | |
ToJSON a => ToJSON (SmsAeroResponse a) | This is a generic instance and does not match |
FromJSON a => FromJSON (SmsAeroResponse a) | |
type Rep (SmsAeroResponse a) |
data SendResponse Source
SMSAero response to a send request.
SendAccepted MessageId | Message accepted. |
SendNoCredits | No credits to send a message. |
Show SendResponse | |
Generic SendResponse | |
ToJSON SendResponse | This is a generic instance and does not match |
FromJSON SendResponse | |
type Rep SendResponse |
data StatusResponse Source
SMSAero response to a status request.
StatusDeliverySuccess | Message is successfully delivered. |
StatusDeliveryFailure | Message delivery has failed. |
StatusSmscSubmit | Message submitted to SMSC. |
StatusSmscReject | Message rejected by SMSC. |
StatusQueue | Message queued. |
StatusWaitStatus | Wait for message status. |
Show StatusResponse | |
Generic StatusResponse | |
ToJSON StatusResponse | This is a generic instance and does not match |
FromJSON StatusResponse | |
type Rep StatusResponse |
newtype BalanceResponse Source
SMSAero response to a balance request. This is a number of available messages to send.
newtype SendersResponse Source
SMSAero response to a senders request. This is just a list of available signatures.
data SignResponse Source
SMSAero response to a sign request.
SignApproved | Signature is approved. |
SignRejected | Signature is rejected. |
SignPending | Signature is pending. |
Show SignResponse | |
Generic SignResponse | |
ToJSON SignResponse | This is a generic instance and does not match |
FromJSON SignResponse | |
type Rep SignResponse |