clicksend_client 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +96 -43
- data/lib/clicksend_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22defa57f778797619ad88acb3642e162ce37459b07e41d1b9ba39ca75c0023e
|
|
4
|
+
data.tar.gz: 4d03fb206d074cf54d15a77a52a267d72bd51dd0c5d4f1cb352977360ab0119e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4a0db93e40289f1cfee124d854c9face1276d8fdf76251d99cc5ce54301130339785510d167a559d5d811c5bac8a66ef76cae95dede4c1bde71d26feebbbaf7
|
|
7
|
+
data.tar.gz: a3a811465409e3079087bf6e7210a879054f227dfb5f192e6428f392c5d1b3f85381c87699e7c6343b866dbe450773a7a87d63fda47568e61637d0deae32375e
|
data/README.md
CHANGED
|
@@ -1,84 +1,137 @@
|
|
|
1
|
-
# The official
|
|
1
|
+
# The official Ruby SDK for ClickSend v3 API
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
This is the official [ClickSend](https://clicksend.com) SDK. Documentation can be found [here](https://developers.clicksend.com/docs/rest/v3/?ruby#introduction).
|
|
3
|
+
This is the official [ClickSend](https://clicksend.com) Ruby SDK. Full API documentation can be found [here](https://developers.clicksend.com/docs/rest/v3/?ruby#introduction).
|
|
5
4
|
|
|
6
5
|
## Requirements
|
|
7
6
|
|
|
8
|
-
- [
|
|
9
|
-
-
|
|
7
|
+
- Ruby >= 2.7 (install via [Homebrew](https://brew.sh): `brew install ruby`)
|
|
8
|
+
- Bundler (`gem install bundler`)
|
|
9
|
+
- A [ClickSend account](https://dashboard.clicksend.com/#/signup/step1/) with an API key
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Add the gem to your `Gemfile`:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
```ruby
|
|
16
|
+
source 'https://rubygems.org'
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
gem build clicksend_client.gemspec
|
|
18
|
+
gem 'clicksend_client', '~> 1.0.0'
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Then
|
|
21
|
+
Then install:
|
|
22
22
|
|
|
23
|
-
```
|
|
24
|
-
|
|
23
|
+
```bash
|
|
24
|
+
bundle install
|
|
25
25
|
```
|
|
26
|
-
(for development, run `gem install --dev ./clicksend_client-1.0.0.gem` to install the development dependencies)
|
|
27
|
-
|
|
28
|
-
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
|
29
|
-
|
|
30
|
-
Finally add this to the Gemfile:
|
|
31
|
-
|
|
32
|
-
gem 'clicksend_client', '~> 1.0.0'
|
|
33
26
|
|
|
34
27
|
### Install from Git
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
gem 'clicksend_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
|
|
39
|
-
|
|
40
|
-
### Include the Ruby code directly
|
|
41
|
-
|
|
42
|
-
Include the Ruby code directly using `-I` as follows:
|
|
43
|
-
|
|
44
|
-
```shell
|
|
45
|
-
ruby -Ilib script.rb
|
|
29
|
+
```ruby
|
|
30
|
+
gem 'clicksend_client', git: 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
|
|
46
31
|
```
|
|
47
32
|
|
|
48
33
|
## Getting Started
|
|
49
34
|
|
|
50
|
-
Please follow the [installation](#installation) procedure and then run the following code:
|
|
51
35
|
```ruby
|
|
52
|
-
|
|
36
|
+
#!/usr/bin/env ruby
|
|
37
|
+
# frozen_string_literal: true
|
|
38
|
+
|
|
53
39
|
require 'clicksend_client'
|
|
54
40
|
|
|
55
|
-
#
|
|
41
|
+
# — Credentials ————————————————————————————————————————————————————————————————
|
|
42
|
+
USERNAME = 'your_username'
|
|
43
|
+
API_KEY = 'your_api_key'
|
|
44
|
+
|
|
45
|
+
# — Message details ————————————————————————————————————————————————————————————
|
|
46
|
+
FROM_NUMBER = '' # E.164 format e.g. "+61400000000", or leave empty for default sender ID
|
|
47
|
+
TO_NUMBER = '+61411111111' # Recipient in E.164 format
|
|
48
|
+
MESSAGE = 'Hello from ClickSend Ruby SDK!'
|
|
49
|
+
|
|
50
|
+
# — Configure the client ———————————————————————————————————————————————————————
|
|
56
51
|
ClickSendClient.configure do |config|
|
|
57
|
-
|
|
58
|
-
config.
|
|
59
|
-
config.password = 'YOUR PASSWORD'
|
|
52
|
+
config.username = USERNAME
|
|
53
|
+
config.password = API_KEY
|
|
60
54
|
end
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
# — Build and send the SMS —————————————————————————————————————————————————————
|
|
57
|
+
sms_message = ClickSendClient::SmsMessage.new(
|
|
58
|
+
to: TO_NUMBER,
|
|
59
|
+
from: FROM_NUMBER,
|
|
60
|
+
body: MESSAGE,
|
|
61
|
+
source: 'ruby'
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
collection = ClickSendClient::SmsMessageCollection.new(messages: [sms_message])
|
|
63
65
|
|
|
64
66
|
begin
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
api = ClickSendClient::SMSApi.new
|
|
68
|
+
response = api.sms_send_post(collection)
|
|
69
|
+
puts "Success: #{response}"
|
|
68
70
|
rescue ClickSendClient::ApiError => e
|
|
69
|
-
puts "
|
|
71
|
+
puts "API error: #{e.message}"
|
|
72
|
+
puts "Response body: #{e.response_body}" if e.respond_to?(:response_body)
|
|
70
73
|
end
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can find your API key in the [ClickSend Dashboard](https://dashboard.clicksend.com) under **Account > API Credentials**.
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
71
79
|
|
|
80
|
+
```bash
|
|
81
|
+
bundle exec ruby send_sms.rb
|
|
72
82
|
```
|
|
73
83
|
|
|
84
|
+
A successful response looks like:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"http_code": 200,
|
|
89
|
+
"response_code": "SUCCESS",
|
|
90
|
+
"response_msg": "Messages queued for delivery.",
|
|
91
|
+
"data": {
|
|
92
|
+
"total_price": 0.891,
|
|
93
|
+
"total_count": 1,
|
|
94
|
+
"queued_count": 1,
|
|
95
|
+
"messages": [
|
|
96
|
+
{
|
|
97
|
+
"status": "SUCCESS",
|
|
98
|
+
"to": "+61411111111",
|
|
99
|
+
"from": "ClickSend",
|
|
100
|
+
"body": "Hello from ClickSend Ruby SDK!",
|
|
101
|
+
"message_price": "0.8910",
|
|
102
|
+
"carrier": "Telstra",
|
|
103
|
+
"country": "AU"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Upgrading the SDK
|
|
111
|
+
|
|
112
|
+
Update the version in your `Gemfile`, then run:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
bundle update clicksend_client
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Available versions are listed on [RubyGems](https://rubygems.org/gems/clicksend_client/versions).
|
|
119
|
+
|
|
74
120
|
## Documentation
|
|
75
121
|
|
|
76
|
-
|
|
122
|
+
Full SDK and REST API documentation: [developers.clicksend.com](https://developers.clicksend.com/docs/rest/v3/?ruby#introduction)
|
|
77
123
|
|
|
78
|
-
##
|
|
124
|
+
## Authorization
|
|
79
125
|
|
|
80
126
|
|
|
81
127
|
### BasicAuth
|
|
82
128
|
|
|
83
|
-
- **Type**: HTTP basic authentication
|
|
129
|
+
- **Type**: HTTP basic authentication — pass your ClickSend username and API key as `config.username` / `config.password`
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Resources
|
|
84
133
|
|
|
134
|
+
- [ClickSend Ruby SDK on RubyGems](https://rubygems.org/gems/clicksend_client)
|
|
135
|
+
- [ClickSend REST API v3 Docs](https://developers.clicksend.com/docs/rest/v3/)
|
|
136
|
+
- [ClickSend Dashboard](https://dashboard.clicksend.com)
|
|
137
|
+
- [Support](https://help.clicksend.com)
|