Created
December 15, 2014 18:17
-
-
Save bjartwolf/c3e235842e83f3c0ee14 to your computer and use it in GitHub Desktop.
smsservice.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FDK.SmsSender | |
open PSWinCom.Gateway.Client; | |
open SmsTypes; | |
type ISmsService = abstract member SendSms: FdkSms -> SmsStatus | |
type Sender = string | |
type SmsService(sender: Sender, client: IGatewayClient) = | |
interface ISmsService with | |
member this.SendSms fdkSms= | |
let receiverNumber, body = fdkSms | |
let sms = new Sms(ReceiverNumber = receiverNumber, SenderNumber = sender, Text = body ); | |
let messages:list<Message> = [sms] | |
try | |
let response = client.Send(Seq.toList messages) | |
// We only send one SMS so we only care about the first result | |
let result = List.head (List.ofSeq response.Results) | |
Response result | |
with | |
| ex -> Error ex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment