instasent 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +36 -20
- data/instasent-0.1.4.gem +0 -0
- data/lib/instasent.rb +38 -127
- data/lib/instasent/version.rb +1 -1
- metadata +11 -15
- data/examples/verify/check_verify.rb +0 -8
- data/examples/verify/get_verify.rb +0 -8
- data/examples/verify/get_verify_by_id.rb +0 -8
- data/examples/verify/request_verify.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 41a7baee0294e847f4f457a6b769392c6208741cda1527d002924a37770c926c
|
4
|
+
data.tar.gz: 7127f7615384e50ae81586788933bee837ea15aee941271b3b57b985fe0bc7ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fdbcd4f9c187b81060c0e9f522666f619a6ff8614a310cff57faf789ccf43f277abcad9eb236cf207bb4f884769c47a392548d51a155764ee6fe208a370a93a
|
7
|
+
data.tar.gz: ceba25db1469eb4b8c9aac8c1e666545efa9d86c28bb055c7ebb768907a2a03c9c705b6f726de03c6a5e0ee79f04cdb9c9dc69f40fabd06bfed22400018be844
|
data/README.md
CHANGED
@@ -1,47 +1,61 @@
|
|
1
|
-
Welcome to __Instasent Ruby SDK__. This repository contains
|
1
|
+
Welcome to __Instasent Ruby SDK__. This repository contains Ruby SDK for Instasent's REST API.
|
2
|
+
|
3
|
+
# Notice!
|
4
|
+
|
5
|
+
> **Verify** product is currently deprecated and will be removed in the next release. The same functionality can be easily implemented by sending an SMS. If you need help migrating please contact usage
|
2
6
|
|
3
7
|
## Installation
|
4
8
|
|
5
|
-
The easiest way to install the
|
9
|
+
The easiest way to install the SDK is via gem:
|
6
10
|
|
7
11
|
```
|
8
|
-
|
12
|
+
gem install instasent
|
9
13
|
```
|
14
|
+
|
10
15
|
And then execute:
|
11
16
|
|
12
|
-
|
17
|
+
```
|
18
|
+
bundle
|
19
|
+
```
|
20
|
+
|
13
21
|
or including the following in your Gemfile:
|
14
22
|
|
15
23
|
```
|
16
24
|
gem 'instasent'
|
17
25
|
```
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
# Usage
|
28
|
+
|
29
|
+
Check the [examples directory](https://github.com/instasent/instasent-ruby-lib/tree/master/examples) to see working examples of this SDK usage
|
30
|
+
|
31
|
+
### Sending an SMS
|
32
|
+
|
22
33
|
```ruby
|
23
34
|
require 'instasent'
|
24
35
|
|
25
36
|
client = Instasent::Client.new('my-token')
|
26
37
|
|
27
|
-
response = client.send_sms('
|
38
|
+
response = client.send_sms('Company', '+34666666666', 'test message')
|
28
39
|
|
29
40
|
puts response['response_code']
|
30
41
|
puts response['response_body']
|
31
42
|
```
|
32
|
-
|
43
|
+
|
44
|
+
If you want to send an Unicode SMS (i.e with 😀 emoji) you only need to replace `send_sms` call to `send_sms_unicode`
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
response = client.send_sms_unicode('Company', '+34666666666', 'Unicode test: ña éáíóú 😀')
|
48
|
+
```
|
49
|
+
|
50
|
+
## Available actions
|
51
|
+
|
33
52
|
```
|
34
53
|
SMS
|
35
54
|
client.send_sms(sender, to, text)
|
55
|
+
client.send_sms_unicode(sender, to, text)
|
36
56
|
client.get_sms(page, per_page)
|
37
57
|
client.get_sms_by_id(message_id)
|
38
58
|
|
39
|
-
VERIFY
|
40
|
-
client.request_verify(sender, to, text); // text must include %token% string
|
41
|
-
client.check_verify(id, token)
|
42
|
-
client.get_verify_by_id(id)
|
43
|
-
client.get_verify(page, per_page)
|
44
|
-
|
45
59
|
LOOKUP
|
46
60
|
client.do_lookup(to)
|
47
61
|
client.get_lookup_by_id(id)
|
@@ -50,11 +64,13 @@ client.get_lookups(page, per_page)
|
|
50
64
|
ACCOUNT
|
51
65
|
client.get_account_balance()
|
52
66
|
```
|
53
|
-
|
54
|
-
|
55
|
-
|
67
|
+
|
68
|
+
# Full documentation
|
69
|
+
|
70
|
+
Full documentation of the API can be found at http://docs.instasent.com/
|
56
71
|
|
57
72
|
# Getting help
|
58
73
|
|
59
|
-
If you need help installing or using the
|
60
|
-
|
74
|
+
If you need help installing or using the SDK, please contact Instasent Support at support@instasent.com
|
75
|
+
|
76
|
+
If you've instead found a bug in the library or have a feature request, go ahead and open an issue or pull request!
|
data/instasent-0.1.4.gem
ADDED
Binary file
|
data/lib/instasent.rb
CHANGED
@@ -1,94 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "instasent/version"
|
2
4
|
require "net/https"
|
3
5
|
require "json"
|
4
6
|
|
5
7
|
module Instasent
|
6
8
|
class Client
|
9
|
+
@@secureChannel = "https://api.instasent.com/"
|
7
10
|
|
8
|
-
|
9
|
-
@@secureChannel = "https://api.instasent.cdfom/"
|
10
|
-
@@use_secure_channel = TRUE
|
11
|
-
|
12
|
-
def initialize(token, use_secure_channel=true)
|
11
|
+
def initialize(token)
|
13
12
|
@@token = token
|
14
|
-
@@use_secure_channel = use_secure_channel
|
15
13
|
end
|
16
14
|
|
17
15
|
def send_sms(sender, to, text, client_id='')
|
18
|
-
|
19
|
-
if @use_secure_channel
|
20
|
-
url = @@secureChannel + "sms/"
|
21
|
-
else
|
22
|
-
url = @@rootEndpoint + "sms/"
|
23
|
-
end
|
16
|
+
url = @@secureChannel + "sms/"
|
24
17
|
|
25
18
|
http_method = 'POST'
|
26
19
|
|
27
20
|
data = {'from' => sender, 'to' => to, 'text' => text}
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
return response
|
32
|
-
|
22
|
+
execute_request(url, http_method, data)
|
33
23
|
end
|
34
24
|
|
35
|
-
def
|
36
|
-
|
37
|
-
if @use_secure_channel
|
38
|
-
url = @@secureChannel + "sms/?page=" + page.to_s + "per_page=" + per_page.to_s
|
39
|
-
else
|
40
|
-
url = @@rootEndpoint + "sms/?page=" + page.to_s + "per_page=" + per_page.to_s
|
41
|
-
end
|
25
|
+
def send_sms_unicode(sender, to, text, client_id='')
|
26
|
+
url = @@secureChannel + "sms/"
|
42
27
|
|
43
|
-
http_method = '
|
44
|
-
|
45
|
-
response = self.execute_request(url, http_method)
|
28
|
+
http_method = 'POST'
|
46
29
|
|
47
|
-
|
30
|
+
data = {'from' => sender, 'to' => to, 'text' => text, 'allowUnicode' => 'true'}
|
48
31
|
|
32
|
+
execute_request(url, http_method, data)
|
49
33
|
end
|
50
34
|
|
51
|
-
def
|
52
|
-
|
53
|
-
if @@use_secure_channel
|
54
|
-
url = @@secureChannel + 'sms/' + id
|
55
|
-
else
|
56
|
-
url = @@rootEndpoint + 'sms/' + id
|
57
|
-
end
|
35
|
+
def get_sms(page=1, per_page=10)
|
36
|
+
url = @@secureChannel + "sms/?page=" + page.to_s + "per_page=" + per_page.to_s
|
58
37
|
|
59
38
|
http_method = 'GET'
|
60
39
|
|
61
|
-
|
62
|
-
|
63
|
-
return response
|
64
|
-
|
40
|
+
execute_request(url, http_method)
|
65
41
|
end
|
66
42
|
|
67
|
-
def
|
68
|
-
|
69
|
-
if @use_secure_channel
|
70
|
-
url = @@secureChannel + "sms/"
|
71
|
-
else
|
72
|
-
url = @@rootEndpoint + "sms/"
|
73
|
-
end
|
74
|
-
|
75
|
-
http_method = 'POST'
|
76
|
-
|
77
|
-
data = {'from' => sender, 'to' => to, 'text' => text}
|
78
|
-
|
79
|
-
response = self.execute_request(url, http_method, data)
|
43
|
+
def get_sms_by_id(id)
|
44
|
+
url = @@secureChannel + 'sms/' + id
|
80
45
|
|
81
|
-
|
46
|
+
http_method = 'GET'
|
82
47
|
|
48
|
+
execute_request(url, http_method)
|
83
49
|
end
|
84
50
|
|
85
51
|
def request_verify(sender, to, text, token_length = '', timeout = '', client_id='')
|
86
|
-
|
87
|
-
if @@use_secure_channel
|
88
|
-
url = @@secureChannel + "verify/"
|
89
|
-
else
|
90
|
-
url = @@rootEndpoint + "verify/"
|
91
|
-
end
|
52
|
+
url = @@secureChannel + "verify/"
|
92
53
|
|
93
54
|
http_method = 'POST'
|
94
55
|
data = {'sms' => {'from' => sender, 'to' => to, 'text' => text}}
|
@@ -105,110 +66,64 @@ module Instasent
|
|
105
66
|
# data['clientId'] = client_id
|
106
67
|
# end
|
107
68
|
|
108
|
-
|
109
|
-
|
110
|
-
return response
|
111
|
-
|
69
|
+
execute_request(url, http_method, data)
|
112
70
|
end
|
113
71
|
|
114
72
|
def check_verify(id, token)
|
115
|
-
|
116
|
-
if @@use_secure_channel
|
117
|
-
url = @@secureChannel + 'verify/' + id + '?token=' + token
|
118
|
-
else
|
119
|
-
url = @@rootEndpoint + 'verify/' + id + '?token=' + token
|
120
|
-
end
|
73
|
+
url = @@secureChannel + 'verify/' + id + '?token=' + token
|
121
74
|
|
122
75
|
http_method = 'GET'
|
123
76
|
|
124
|
-
|
125
|
-
|
126
|
-
return response
|
127
|
-
|
77
|
+
execute_request(url, http_method, {})
|
128
78
|
end
|
129
79
|
|
130
80
|
def get_verify_by_id(id)
|
131
|
-
|
132
|
-
if @@use_secure_channel
|
133
|
-
url = @@secureChannel + 'verify/' + id
|
134
|
-
else
|
135
|
-
url = @@rootEndpoint + 'verify/' + id
|
136
|
-
end
|
81
|
+
url = @@secureChannel + 'verify/' + id
|
137
82
|
|
138
83
|
http_method = 'GET'
|
139
84
|
|
140
|
-
|
141
|
-
|
142
|
-
return response
|
143
|
-
|
85
|
+
execute_request(url, http_method, {})
|
144
86
|
end
|
145
87
|
|
146
88
|
def get_verify(page=1, per_page=10)
|
147
|
-
|
148
|
-
if @use_secure_channel
|
149
|
-
url = @@secureChannel + 'verify/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
150
|
-
else
|
151
|
-
url = @@rootEndpoint + 'verify/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
152
|
-
end
|
89
|
+
url = @@secureChannel + 'verify/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
153
90
|
|
154
91
|
http_method = 'GET'
|
155
92
|
|
156
|
-
|
157
|
-
|
158
|
-
return response
|
159
|
-
|
93
|
+
execute_request(url, http_method)
|
160
94
|
end
|
161
95
|
|
162
96
|
def do_lookup(to)
|
163
|
-
|
164
|
-
url = if @use_secure_channel then @@secureChannel + 'lookup/' else @@rootEndpoint + 'lookup/' end
|
97
|
+
url = @@secureChannel + 'lookup/'
|
165
98
|
http_method = 'POST'
|
166
99
|
data = {'to' => to}
|
167
100
|
|
168
|
-
|
169
|
-
|
170
|
-
return response
|
171
|
-
|
101
|
+
execute_request(url, http_method, data)
|
172
102
|
end
|
173
103
|
|
174
104
|
def get_lookup_by_id(id)
|
175
|
-
|
176
|
-
url = if @use_secure_channel then @@secureChannel + 'lookup/' + id else @@rootEndpoint + 'lookup/' + id end
|
105
|
+
url = @@secureChannel + 'lookup/' + id
|
177
106
|
http_method = 'GET'
|
178
|
-
|
179
|
-
|
180
|
-
return response
|
181
|
-
|
107
|
+
execute_request(url, http_method, {})
|
182
108
|
end
|
183
109
|
|
184
110
|
def get_lookups(page=1, per_page=10)
|
185
|
-
|
186
|
-
if @use_secure_channel
|
187
|
-
url = @@secureChannel + 'lookup/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
188
|
-
else
|
189
|
-
url = @@rootEndpoint + 'lookup/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
190
|
-
end
|
111
|
+
url = @@secureChannel + 'lookup/?page=' + page.to_s + 'per_page=' + per_page.to_s
|
191
112
|
|
192
113
|
http_method = 'GET'
|
193
114
|
|
194
|
-
|
195
|
-
|
196
|
-
return response
|
197
|
-
|
115
|
+
execute_request(url, http_method)
|
198
116
|
end
|
199
117
|
|
200
118
|
def get_account_balance
|
201
|
-
|
202
|
-
url = if @use_secure_channel then @@secureChannel + 'organization/account/' else @@rootEndpoint + 'organization/account/' end
|
119
|
+
url = @@secureChannel + 'organization/account/'
|
203
120
|
http_method = 'GET'
|
204
|
-
|
205
|
-
|
206
|
-
return response
|
207
|
-
|
121
|
+
execute_request(url, http_method, {})
|
208
122
|
end
|
209
123
|
|
210
|
-
|
124
|
+
private
|
211
125
|
|
126
|
+
def execute_request(url='', http_method='', data='')
|
212
127
|
url_parsed = URI.parse(url)
|
213
128
|
|
214
129
|
if http_method=='GET'
|
@@ -222,15 +137,11 @@ module Instasent
|
|
222
137
|
req.add_field("Accept", "application/json")
|
223
138
|
req.add_field("Content-Type", "application/json")
|
224
139
|
|
225
|
-
res = Net::HTTP.start(url_parsed.host, url_parsed.port) { |http|
|
140
|
+
res = Net::HTTP.start(url_parsed.host, url_parsed.port, use_ssl: true) { |http|
|
226
141
|
http.request(req)
|
227
142
|
}
|
228
143
|
|
229
|
-
|
230
|
-
|
144
|
+
{'response_body' => res.body, 'response_code' => res.code}
|
231
145
|
end
|
232
|
-
|
233
146
|
end
|
234
|
-
|
235
|
-
|
236
147
|
end
|
data/lib/instasent/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instasent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instasent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.12'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description: Implementation of the Instasent SMS lib for Ruby
|
@@ -45,7 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
@@ -59,10 +59,7 @@ files:
|
|
59
59
|
- examples/sms/get_sms.rb
|
60
60
|
- examples/sms/get_sms_by_id.rb
|
61
61
|
- examples/sms/send_sms.rb
|
62
|
-
-
|
63
|
-
- examples/verify/get_verify.rb
|
64
|
-
- examples/verify/get_verify_by_id.rb
|
65
|
-
- examples/verify/request_verify.rb
|
62
|
+
- instasent-0.1.4.gem
|
66
63
|
- instasent.gemspec
|
67
64
|
- lib/instasent.rb
|
68
65
|
- lib/instasent/version.rb
|
@@ -76,17 +73,16 @@ require_paths:
|
|
76
73
|
- lib
|
77
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
75
|
requirements:
|
79
|
-
- -
|
76
|
+
- - ">="
|
80
77
|
- !ruby/object:Gem::Version
|
81
78
|
version: '0'
|
82
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
80
|
requirements:
|
84
|
-
- -
|
81
|
+
- - ">="
|
85
82
|
- !ruby/object:Gem::Version
|
86
83
|
version: '0'
|
87
84
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.0.14
|
85
|
+
rubygems_version: 3.0.3
|
90
86
|
signing_key:
|
91
87
|
specification_version: 4
|
92
88
|
summary: Implementation of the Instasent SMS lib for Ruby
|