Swift Package Index

telesign-kit

https://github.com/vapor-community/telesign-kit.git

A Swift package used to communicate with the Telesign API


Compatibility

  • 3.1.1 and master
    5.3
    5.2
    5.1
    5.0
    4.2
  • 3.1.1 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS

TelesignKit

TelesignKit is a Swift package used to communicate with the Telesign API for Server Side Swift Apps.

What's Telesign?

Telesign is a Communication Platform as a Service. Allowing you to send SMS messages for your use case, text to voice communications, phone identification to reduce risk/fraud and many other things.

Installation

To start using TelesignKit, in your Package.swift, add the following

.package(url: "https://github.com/vapor-community/telesignkit.git", from: "3.0.0")

Using the API

In your main.swift simply create a TelesignClient:

import NIO
import TelesignKit

let httpClient = HTTPClient(..)

let client = TelesignClient(httpClient: httpClient,
                            eventLoop: eventloop,
                            apiKey: "YOUR_API_KEY",
                            customerId: "YOUR_CUSTOMER_ID")

do {
    let result = try client.messaging.send(phoneNumber: "11234567890",
                                           message: "Hello Telesign!",
                                           messageType: .ARN).wait()
    print(result)
} catch {
    print(error)
}

Vapor Integration

To use TelesignKit with Vapor 4.x, add a simple extension on Request.

extension Request {
    public var telesign: TelesignClient {
    return TelesignClient(httpClient: self.application.client.http, eventLoop: self.eventLoop, apiKey: "TELESIGN_API_KEY", customerId: "CUSTOMER_ID")
    }
}

// Later...

func sendSMS(req: Request) -> EventLoopFuture<Response> {
    return req.telesign.messaging.send(...)
}

Supports the following APIs

  • Messaging
  • PhoneId
  • Score