|
1 | | -# Vapor Telesign Provider |
| 1 | +# TelesignKit |
2 | 2 |
|
3 | | - |
4 | | - |
5 | | -[](https://circleci.com/gh/vapor-community/telesign-provider/tree/master) |
| 3 | + |
| 4 | + |
6 | 5 |
|
7 | 6 |
|
| 7 | +### TelesignKit is a Swift package used to communicate with the [Telesign](https://telesign.com) API for Server Side Swift Apps. |
| 8 | + |
8 | 9 | ## What's Telesign? |
9 | | -[Telesign][telesign_home] 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. |
| 10 | +[Telesign](https://www.telesign.com) 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. |
10 | 11 |
|
11 | | -## Integrating with your Vapor project |
12 | | -Start by adding the repo to your `Package.swift` |
| 12 | +## Installation |
| 13 | +To start using TelesignKit, in your `Package.swift`, add the following |
13 | 14 |
|
14 | 15 | ~~~~swift |
15 | | -.package(url: "https://github.com/vapor-community/telesign-provider.git", from: "2.0.2") |
| 16 | +.package(url: "https://github.com/vapor-community/telesignkit.git", from: "1.0.0") |
16 | 17 | ~~~~ |
17 | 18 |
|
18 | | -Register the config and the provider to your Application |
19 | | -~~~~swift |
20 | | -let config = TelesignConfig(apiKey: "myapikey", customerId: "mycustomerId") |
| 19 | +## Using the API |
21 | 20 |
|
22 | | -services.register(config) |
| 21 | +In your `main.swift` simply create a `TelesignClient`: |
23 | 22 |
|
24 | | -try services.register(TelesignProvider()) |
| 23 | +~~~swift |
| 24 | +import NIO |
| 25 | +import TelesignKit |
25 | 26 |
|
26 | | -app = try Application(services: services) |
| 27 | +let eventloop: EventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) |
27 | 28 |
|
28 | | -telesignClient = try app.make(TelesignClient.self) |
29 | | -~~~~ |
30 | 29 |
|
31 | | -And you are all set. Interacting with the API is quite easy and adopts the `Future` syntax used in Vapor 3. |
32 | | -Making calls to the api is straight forward. |
33 | | -~~~~swift |
34 | | -try telesignClient.messaging.send(message: "Hello Vapor", to: "1234567", messageType: .ARN) |
35 | | -~~~~ |
| 30 | +let client = TelesignClient(eventLoop: eventloop, |
| 31 | + apiKey: "YOUR_API_KEY", |
| 32 | + customerId: "YOUR_CUSTOMER_ID") |
| 33 | + |
| 34 | +do { |
| 35 | + let result = try client.messaging.send(phoneNumber: "11234567890", |
| 36 | + message: "Hello Telesign!", |
| 37 | + messageType: .ARN).wait() |
| 38 | + print(result) |
| 39 | +} catch { |
| 40 | + print(error) |
| 41 | +} |
| 42 | +~~~ |
36 | 43 |
|
37 | | -## Supports the full API |
| 44 | +## Supports the following APIs |
38 | 45 | * [x] Messaging |
39 | 46 | * [x] PhoneId |
40 | 47 | * [x] Score |
41 | | -* [x] Voice |
42 | | - |
43 | | -[telesign_home]: https://www.telesign.com "Telesign" |
|
0 commit comments