instasent 0.1.3 → 0.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 +17 -2
- data/examples/account/get_account_balance.rb +8 -0
- data/examples/lookup/do_lookup.rb +8 -0
- data/examples/lookup/get_lookup_by_id.rb +8 -0
- data/examples/lookup/get_lookups.rb +8 -0
- data/examples/{get_sms.rb → sms/get_sms.rb} +0 -0
- data/examples/{get_sms_by_id.rb → sms/get_sms_by_id.rb} +0 -0
- data/examples/{send_sms.rb → sms/send_sms.rb} +0 -0
- data/examples/verify/check_verify.rb +8 -0
- data/examples/verify/get_verify.rb +8 -0
- data/examples/verify/get_verify_by_id.rb +8 -0
- data/examples/verify/request_verify.rb +8 -0
- data/lib/instasent.rb +147 -2
- data/lib/instasent/version.rb +1 -1
- metadata +13 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73250272bd955b58b58dc7a74b6dab0b7b67bcf9
|
4
|
+
data.tar.gz: 5f72ad17b1421bfaf73b62a15460692e2c53c70c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2cea5ccd28ead6b018475eee63081ee9cebb9b6cb63956ceeae2fd51af96e049e98e3984430c35dd04f12f747f3abd28fef13cfcd91dd6aa378539f038a2f4a
|
7
|
+
data.tar.gz: 65028063d25f52b59f9b6a0afad92e285c7f5d625c7e7f64369307cde7525e9ebbd927edad27bc6ed74d28d08ee7fd6fd3461c72247024594c02a04822b40d3f
|
data/README.md
CHANGED
@@ -18,22 +18,37 @@ gem 'instasent'
|
|
18
18
|
|
19
19
|
## Example
|
20
20
|
### Send an SMS
|
21
|
-
You can check 'examples/send-sms.
|
21
|
+
You can check 'examples/send-sms.rb' file.
|
22
22
|
```ruby
|
23
23
|
require 'instasent'
|
24
24
|
|
25
25
|
client = Instasent::Client.new('my-token')
|
26
26
|
|
27
|
-
response = client.send_sms('
|
27
|
+
response = client.send_sms('My company', '+34666666666', 'test message')
|
28
28
|
|
29
29
|
puts response['response_code']
|
30
30
|
puts response['response_body']
|
31
31
|
```
|
32
32
|
## Available functions
|
33
33
|
```
|
34
|
+
SMS
|
34
35
|
client.send_sms(sender, to, text)
|
35
36
|
client.get_sms(page, per_page)
|
36
37
|
client.get_sms_by_id(message_id)
|
38
|
+
|
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
|
+
LOOKUP
|
46
|
+
client.do_lookup(to)
|
47
|
+
client.get_lookup_by_id(id)
|
48
|
+
client.get_lookups(page, per_page)
|
49
|
+
|
50
|
+
ACCOUNT
|
51
|
+
client.get_account_balance()
|
37
52
|
```
|
38
53
|
## Documentation
|
39
54
|
Complete documentation at :
|
File without changes
|
File without changes
|
File without changes
|
data/lib/instasent.rb
CHANGED
@@ -6,8 +6,8 @@ module Instasent
|
|
6
6
|
class Client
|
7
7
|
|
8
8
|
@@rootEndpoint = "http://api.instasent.com/"
|
9
|
-
@@secureChannel = "https://api.instasent.
|
10
|
-
@@use_secure_channel =
|
9
|
+
@@secureChannel = "https://api.instasent.cdfom/"
|
10
|
+
@@use_secure_channel = TRUE
|
11
11
|
|
12
12
|
def initialize(token, use_secure_channel=true)
|
13
13
|
@@token = token
|
@@ -64,6 +64,149 @@ module Instasent
|
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
|
+
def send_sms(sender, to, text, client_id='')
|
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)
|
80
|
+
|
81
|
+
return response
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
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
|
92
|
+
|
93
|
+
http_method = 'POST'
|
94
|
+
data = {'sms' => {'from' => sender, 'to' => to, 'text' => text}}
|
95
|
+
|
96
|
+
# if token_length != ''
|
97
|
+
# data['tokenLength'] = token_length
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# if timeout != ''
|
101
|
+
# data['timeout'] = timeout
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# if client_id != ''
|
105
|
+
# data['clientId'] = client_id
|
106
|
+
# end
|
107
|
+
|
108
|
+
response = self.execute_request(url, http_method, data)
|
109
|
+
|
110
|
+
return response
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
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
|
121
|
+
|
122
|
+
http_method = 'GET'
|
123
|
+
|
124
|
+
response = self.execute_request(url, http_method, {})
|
125
|
+
|
126
|
+
return response
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
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
|
137
|
+
|
138
|
+
http_method = 'GET'
|
139
|
+
|
140
|
+
response = self.execute_request(url, http_method, {})
|
141
|
+
|
142
|
+
return response
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
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
|
153
|
+
|
154
|
+
http_method = 'GET'
|
155
|
+
|
156
|
+
response = self.execute_request(url, http_method)
|
157
|
+
|
158
|
+
return response
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
def do_lookup(to)
|
163
|
+
|
164
|
+
url = if @use_secure_channel then @@secureChannel + 'lookup/' else @@rootEndpoint + 'lookup/' end
|
165
|
+
http_method = 'POST'
|
166
|
+
data = {'to' => to}
|
167
|
+
|
168
|
+
response = self.execute_request(url, http_method, data)
|
169
|
+
|
170
|
+
return response
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
def get_lookup_by_id(id)
|
175
|
+
|
176
|
+
url = if @use_secure_channel then @@secureChannel + 'lookup/' + id else @@rootEndpoint + 'lookup/' + id end
|
177
|
+
http_method = 'GET'
|
178
|
+
response = self.execute_request(url, http_method, {})
|
179
|
+
|
180
|
+
return response
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
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
|
191
|
+
|
192
|
+
http_method = 'GET'
|
193
|
+
|
194
|
+
response = self.execute_request(url, http_method)
|
195
|
+
|
196
|
+
return response
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
def get_account_balance
|
201
|
+
|
202
|
+
url = if @use_secure_channel then @@secureChannel + 'organization/account/' else @@rootEndpoint + 'organization/account/' end
|
203
|
+
http_method = 'GET'
|
204
|
+
response = self.execute_request(url, http_method, {})
|
205
|
+
|
206
|
+
return response
|
207
|
+
|
208
|
+
end
|
209
|
+
|
67
210
|
def execute_request(url='', http_method='', data='')
|
68
211
|
|
69
212
|
url_parsed = URI.parse(url)
|
@@ -76,6 +219,8 @@ module Instasent
|
|
76
219
|
end
|
77
220
|
|
78
221
|
req.add_field("Authorization", "Bearer "+@@token.to_s)
|
222
|
+
req.add_field("Accept", "application/json")
|
223
|
+
req.add_field("Content-Type", "application/json")
|
79
224
|
|
80
225
|
res = Net::HTTP.start(url_parsed.host, url_parsed.port) { |http|
|
81
226
|
http.request(req)
|
data/lib/instasent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instasent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,9 +52,17 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- bin/console
|
54
54
|
- bin/setup
|
55
|
-
- examples/
|
56
|
-
- examples/
|
57
|
-
- examples/
|
55
|
+
- examples/account/get_account_balance.rb
|
56
|
+
- examples/lookup/do_lookup.rb
|
57
|
+
- examples/lookup/get_lookup_by_id.rb
|
58
|
+
- examples/lookup/get_lookups.rb
|
59
|
+
- examples/sms/get_sms.rb
|
60
|
+
- examples/sms/get_sms_by_id.rb
|
61
|
+
- examples/sms/send_sms.rb
|
62
|
+
- examples/verify/check_verify.rb
|
63
|
+
- examples/verify/get_verify.rb
|
64
|
+
- examples/verify/get_verify_by_id.rb
|
65
|
+
- examples/verify/request_verify.rb
|
58
66
|
- instasent.gemspec
|
59
67
|
- lib/instasent.rb
|
60
68
|
- lib/instasent/version.rb
|