Swiftpack.co - Package - vapor-community/Telesign

Vapor Telesign Provider

Swift Vapor CircleCI

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.

Integrating with your Vapor project

Start by adding the repo to your Package.swift

For Swift 3

.Package(url: "https://github.com/vapor-community/Telesign.git", Version(1,0,0))

For Swift 4

.package(url: "https://github.com/vapor-community/Telesign.git", .exact(Version(1,0,0)))

You'll need a config file as well. Place a telesign.json file in your Config folder

{
         "apiKey": "YOUR_API_KEY", 
         "clientId": "CLIENT_ID"
}

Add the provider to your droplet

import Telesign
...
try drop.addProvider(Telesign.Provider.self)

Making calls with the api couldn't be easier

let apiResult = try droplet.telesign?.messaging.send(message: "Hello Vapor", to: "12345678", messageType: .ARN)

And you can also check the status of a message. From our previous api call:

let status = try droplet.telesign?.messaging.getResultFor(reference: apiResult?.referenceId ?? "").description ?? ""
print(status)
// Prints "Message in progress"

Implementation Progress

  • [x] Messaging
  • [x] PhoneId
  • [x] Score
  • [x] Voice

Testing for those who want to fork a new branch

To avoid having to remember to add tests to LinuxMain.swift you can use Sourcery to add your tets cases there for you. Just install the sourcery binary with Homebrew brew install sourcery, navigate to your project folder, and from the command line run the following:

sourcery --sources Tests/ --templates Sourcery/LinuxMain.stencil --args testimports='@testable import TelesignTests'

It will generate the following with your tests added:

import XCTest
@testable import TelesignTests
extension Messagestests {
static var allTests = [
  ("testSending", testSending),
  ...
]
}
.
.
XCTMain([
  testCase(MessagesTests.allTests),
  ...
])

Github

link
Stars: 3
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.1 - Sep 2, 2017

1.0.0 - Jul 29, 2017

v0.1.0-beta - Jul 25, 2017