serwersms 0.0.3 → 2.0.0
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 +5 -5
- data/lib/serwersms/client_credentials.rb +13 -0
- data/lib/serwersms/client_factory.rb +76 -0
- data/lib/serwersms/client_token.rb +13 -0
- data/lib/serwersms/error.rb +10 -0
- data/lib/serwersms/http/api_client.rb +63 -0
- data/lib/serwersms/http/http_credentials.rb +22 -0
- data/lib/serwersms/http/http_token.rb +23 -0
- data/lib/serwersms/resources/accounts.rb +59 -0
- data/lib/serwersms/resources/blacklist.rb +55 -0
- data/lib/serwersms/resources/contacts.rb +134 -0
- data/lib/serwersms/resources/error.rb +20 -0
- data/lib/serwersms/resources/files.rb +61 -0
- data/lib/serwersms/resources/groups.rb +83 -0
- data/lib/serwersms/resources/messages.rb +228 -0
- data/lib/serwersms/resources/phones.rb +33 -0
- data/lib/serwersms/resources/premium.rb +48 -0
- data/lib/serwersms/resources/senders.rb +33 -0
- data/lib/serwersms/resources/stats.rb +31 -0
- data/lib/serwersms/resources/subaccounts.rb +72 -0
- data/lib/serwersms/resources/templates.rb +55 -0
- data/lib/serwersms/resources_mixin.rb +55 -0
- data/lib/serwersms.rb +21 -58
- metadata +28 -27
- data/lib/library/accounts.rb +0 -65
- data/lib/library/blacklist.rb +0 -63
- data/lib/library/contacts.rb +0 -145
- data/lib/library/error.rb +0 -19
- data/lib/library/files.rb +0 -74
- data/lib/library/groups.rb +0 -103
- data/lib/library/messages.rb +0 -352
- data/lib/library/payments.rb +0 -55
- data/lib/library/phones.rb +0 -40
- data/lib/library/premium.rb +0 -58
- data/lib/library/senders.rb +0 -36
- data/lib/library/stats.rb +0 -31
- data/lib/library/subaccounts.rb +0 -87
- data/lib/library/templates.rb +0 -69
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Messages
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Send SMS message
|
|
9
|
+
#
|
|
10
|
+
# @param phone [String]
|
|
11
|
+
# @param text [String] Message content
|
|
12
|
+
# @param sender [String] Sender name — only for FULL SMS
|
|
13
|
+
# @param params [Hash]
|
|
14
|
+
# @option params [Boolean] :details Show details of messages
|
|
15
|
+
# @option params [Boolean] :utf Change encoding to UTF-8 (only for FULL SMS)
|
|
16
|
+
# @option params [Boolean] :flash
|
|
17
|
+
# @option params [Boolean] :speed Priority canal — only for FULL SMS
|
|
18
|
+
# @option params [Boolean] :test Test mode
|
|
19
|
+
# @option params [Boolean] :vcard vCard message
|
|
20
|
+
# @option params [String] :wap_push WAP Push URL address
|
|
21
|
+
# @option params [String] :date Set the date of sending
|
|
22
|
+
# @option params [Integer] :group_id Sending to the group instead of a phone number
|
|
23
|
+
# @option params [Integer] :contact_id Sending to phone from contacts
|
|
24
|
+
# @option params [String] :unique_id Own identifiers of messages
|
|
25
|
+
# @return [Hash]
|
|
26
|
+
# @option return [Boolean] :success
|
|
27
|
+
# @option return [Integer] :queued Number of queued messages
|
|
28
|
+
# @option return [Integer] :unsent Number of unsent messages
|
|
29
|
+
# @option return [Array] :items
|
|
30
|
+
# @option item [String] :id
|
|
31
|
+
# @option item [String] :phone
|
|
32
|
+
# @option item [String] :status queued|unsent
|
|
33
|
+
# @option item [String] :queued Date of enqueued
|
|
34
|
+
# @option item [Integer] :parts Number of parts
|
|
35
|
+
# @option item [Integer] :error_code
|
|
36
|
+
# @option item [String] :error_message
|
|
37
|
+
# @option item [String] :text
|
|
38
|
+
def send_sms(phone, text, sender = nil, params = {})
|
|
39
|
+
params['phone'] = phone
|
|
40
|
+
params['text'] = text
|
|
41
|
+
params['sender'] = sender
|
|
42
|
+
@client.call('messages/send_sms', params)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Send personalized messages
|
|
46
|
+
#
|
|
47
|
+
# @param messages [Array]
|
|
48
|
+
# @option message [String] :phone
|
|
49
|
+
# @option message [String] :text
|
|
50
|
+
# @param sender [String] Sender name — only for FULL SMS
|
|
51
|
+
# @param params [Hash]
|
|
52
|
+
# @option params [Boolean] :details Show details of messages
|
|
53
|
+
# @option params [Boolean] :utf Change encoding to UTF-8 (only for FULL SMS)
|
|
54
|
+
# @option params [Boolean] :flash
|
|
55
|
+
# @option params [Boolean] :speed Priority canal — only for FULL SMS
|
|
56
|
+
# @option params [Boolean] :test Test mode
|
|
57
|
+
# @option params [String] :date Set the date of sending
|
|
58
|
+
# @option params [Integer,Array] :group_id Sending to the group instead of a phone number
|
|
59
|
+
# @option params [String] :text Message if group_id is set
|
|
60
|
+
# @option params [String,Array] :unique_id Own identifiers of messages
|
|
61
|
+
# @option params [Boolean] :voice Send VMS
|
|
62
|
+
# @return [Hash]
|
|
63
|
+
# @option return [Boolean] :success
|
|
64
|
+
# @option return [Integer] :queued
|
|
65
|
+
# @option return [Integer] :unsent
|
|
66
|
+
# @option return [Array] :items
|
|
67
|
+
def send_personalized(messages, sender = nil, params = {})
|
|
68
|
+
params['messages'] = messages
|
|
69
|
+
params['sender'] = sender
|
|
70
|
+
@client.call('messages/send_personalized', params)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Send Voice message
|
|
74
|
+
#
|
|
75
|
+
# @param phone [String]
|
|
76
|
+
# @param params [Hash]
|
|
77
|
+
# @option params [String] :text Text to speech
|
|
78
|
+
# @option params [String] :file_id ID of wav file
|
|
79
|
+
# @option params [String] :date Set the date of sending
|
|
80
|
+
# @option params [Boolean] :test Test mode
|
|
81
|
+
# @option params [Integer,Array] :group_id Sending to the group instead of a phone number
|
|
82
|
+
# @option params [Integer,Array] :contact_id Sending to phone from contacts
|
|
83
|
+
# @return [Hash]
|
|
84
|
+
# @option return [Boolean] :success
|
|
85
|
+
# @option return [Integer] :queued
|
|
86
|
+
# @option return [Integer] :unsent
|
|
87
|
+
# @option return [Array] :items
|
|
88
|
+
def send_voice(phone, params = {})
|
|
89
|
+
params['phone'] = phone
|
|
90
|
+
@client.call('messages/send_voice', params)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Send MMS
|
|
94
|
+
#
|
|
95
|
+
# @param phone [String, Array]
|
|
96
|
+
# @param title [String] Title of message (max 40 chars)
|
|
97
|
+
# @param params [Hash]
|
|
98
|
+
# @option params [String] :file_id File ID
|
|
99
|
+
# @option params [String,Array] :file File in base64 encoding
|
|
100
|
+
# @option params [String] :date Set the date of sending
|
|
101
|
+
# @option params [Boolean] :test Test mode
|
|
102
|
+
# @option params [Integer,Array] :group_id Sending to the group instead of a phone number
|
|
103
|
+
# @return [Hash]
|
|
104
|
+
# @option return [Boolean] :success
|
|
105
|
+
# @option return [Integer] :queued
|
|
106
|
+
# @option return [Integer] :unsent
|
|
107
|
+
# @option return [Array] :items
|
|
108
|
+
def send_mms(phone, title, params = {})
|
|
109
|
+
params['phone'] = phone
|
|
110
|
+
params['title'] = title
|
|
111
|
+
@client.call('messages/send_mms', params)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Send message to ND/SC number
|
|
115
|
+
#
|
|
116
|
+
# @param phone [String] Sender phone number
|
|
117
|
+
# @param text [String] Message
|
|
118
|
+
# @return [Hash]
|
|
119
|
+
# @option return [Boolean] :success
|
|
120
|
+
def send_nd(phone, text)
|
|
121
|
+
@client.call('messages/send_nd', 'phone' => phone, 'text' => text)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Send message to NDI/SCI number
|
|
125
|
+
#
|
|
126
|
+
# @param phone [String] Sender phone number
|
|
127
|
+
# @param text [String] Message
|
|
128
|
+
# @param ndi_number [String] Recipient phone number
|
|
129
|
+
# @return [Hash]
|
|
130
|
+
# @option return [Boolean] :success
|
|
131
|
+
def send_ndi(phone, text, ndi_number)
|
|
132
|
+
@client.call('messages/send_ndi', 'phone' => phone, 'text' => text, 'ndi_number' => ndi_number)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# View single message
|
|
136
|
+
#
|
|
137
|
+
# @param id [String]
|
|
138
|
+
# @param params [Hash]
|
|
139
|
+
# @option params [String] :unique_id
|
|
140
|
+
# @option params [Boolean] :show_contact Show details of the recipient from contacts
|
|
141
|
+
# @return [Hash]
|
|
142
|
+
# @option return [String] :id
|
|
143
|
+
# @option return [String] :phone
|
|
144
|
+
# @option return [String] :status delivered|undelivered|sent|unsent|in_progress|saved
|
|
145
|
+
# @option return [String] :queued Date of enqueued
|
|
146
|
+
# @option return [String] :sent Date of sending
|
|
147
|
+
# @option return [String] :delivered Date of delivery
|
|
148
|
+
# @option return [String] :sender
|
|
149
|
+
# @option return [String] :type eco|full|mms|voice
|
|
150
|
+
# @option return [String] :text
|
|
151
|
+
# @option return [String] :reason message_expired|unsupported_number|message_rejected|
|
|
152
|
+
# missed_call|wrong_number|limit_exhausted|lock_send|
|
|
153
|
+
# wrong_message|operator_error|wrong_sender_name|
|
|
154
|
+
# number_is_blacklisted|sending_to_foreign_networks_is_locked|
|
|
155
|
+
# no_permission_to_send_messages|other_error
|
|
156
|
+
# @option return [Hash] :contact
|
|
157
|
+
def view(id, params = {})
|
|
158
|
+
params['id'] = id
|
|
159
|
+
@client.call('messages/view', params)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Check message delivery reports
|
|
163
|
+
#
|
|
164
|
+
# @param params [Hash]
|
|
165
|
+
# @option params [String,Array] :id Message ID
|
|
166
|
+
# @option params [String,Array] :unique_id Message unique ID
|
|
167
|
+
# @option params [String,Array] :phone
|
|
168
|
+
# @option params [String] :date_from Start date
|
|
169
|
+
# @option params [String] :date_to End date
|
|
170
|
+
# @option params [String] :status delivered|undelivered|pending|sent|unsent
|
|
171
|
+
# @option params [String] :type eco|full|mms|voice
|
|
172
|
+
# @option params [Integer] :stat_id Package ID
|
|
173
|
+
# @option params [Boolean] :show_contact Show details of the recipient from contacts
|
|
174
|
+
# @option params [Integer] :page The number of the displayed page
|
|
175
|
+
# @option params [Integer] :limit Limit items displayed on single page
|
|
176
|
+
# @option params [String] :order asc|desc
|
|
177
|
+
# @return [Hash]
|
|
178
|
+
# @option return [Hash] :paging
|
|
179
|
+
# @option paging [Integer] :page
|
|
180
|
+
# @option paging [Integer] :count
|
|
181
|
+
# @option return [Array] :items
|
|
182
|
+
def reports(params = {})
|
|
183
|
+
@client.call('messages/reports', params)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# List of received messages
|
|
187
|
+
#
|
|
188
|
+
# @param type [String] eco|nd|ndi|mms
|
|
189
|
+
# @param params [Hash]
|
|
190
|
+
# @option params [String] :ndi Filtering by NDI
|
|
191
|
+
# @option params [String] :phone Filtering by phone
|
|
192
|
+
# @option params [String] :date_from Start date
|
|
193
|
+
# @option params [String] :date_to End date
|
|
194
|
+
# @option params [Boolean] :read Mark as read
|
|
195
|
+
# @option params [Integer] :page The number of the displayed page
|
|
196
|
+
# @option params [Integer] :limit Limit items displayed on single page
|
|
197
|
+
# @option params [String] :order asc|desc
|
|
198
|
+
# @return [Hash]
|
|
199
|
+
# @option return [Hash] :paging
|
|
200
|
+
# @option return [Array] :items
|
|
201
|
+
# @option item [Integer] :id
|
|
202
|
+
# @option item [String] :type eco|nd|ndi|mms
|
|
203
|
+
# @option item [String] :phone
|
|
204
|
+
# @option item [String] :received Date of received message
|
|
205
|
+
# @option item [String] :message_id ID of outgoing message (only for ECO SMS)
|
|
206
|
+
# @option item [Boolean] :blacklist Is the phone blacklisted?
|
|
207
|
+
# @option item [String] :text Message
|
|
208
|
+
# @option item [String] :to_number Number of the recipient (for MMS)
|
|
209
|
+
# @option item [String] :title Title of message (for MMS)
|
|
210
|
+
# @option item [Array] :attachments (for MMS)
|
|
211
|
+
# @option item [Hash] :contact
|
|
212
|
+
def received(type, params = {})
|
|
213
|
+
params['type'] = type
|
|
214
|
+
@client.call('messages/received', params)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Delete message from the scheduler
|
|
218
|
+
#
|
|
219
|
+
# @param id [String]
|
|
220
|
+
# @param unique_id [String]
|
|
221
|
+
# @return [Hash]
|
|
222
|
+
# @option return [Boolean] :success
|
|
223
|
+
def delete(id, unique_id = nil)
|
|
224
|
+
@client.call('messages/delete', 'id' => id, 'unique_id' => unique_id)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Phones
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Check phone via HLR
|
|
9
|
+
#
|
|
10
|
+
# @param phone [String]
|
|
11
|
+
# @param id [String] Query ID returned if processing takes longer than 60 seconds
|
|
12
|
+
# @return [Hash]
|
|
13
|
+
# @option return [String] :phone
|
|
14
|
+
# @option return [String] :status
|
|
15
|
+
# @option return [Integer] :imsi
|
|
16
|
+
# @option return [String] :network
|
|
17
|
+
# @option return [Boolean] :ported
|
|
18
|
+
# @option return [String] :network_ported
|
|
19
|
+
def check(phone, id = nil)
|
|
20
|
+
@client.call('phones/check', 'phone' => phone, 'id' => id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Validate phone number
|
|
24
|
+
#
|
|
25
|
+
# @param phone [String]
|
|
26
|
+
# @return [Hash]
|
|
27
|
+
# @option return [Boolean] :correct
|
|
28
|
+
def test(phone)
|
|
29
|
+
@client.call('phones/test', 'phone' => phone)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Premium
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# List of received SMS Premium
|
|
9
|
+
#
|
|
10
|
+
# @return [Hash]
|
|
11
|
+
# @option return [Array] :items
|
|
12
|
+
# @option item [Integer] :id
|
|
13
|
+
# @option item [String] :to_number Premium number
|
|
14
|
+
# @option item [String] :from_number Sender phone number
|
|
15
|
+
# @option item [String] :date
|
|
16
|
+
# @option item [Integer] :limit Limitation the number of responses
|
|
17
|
+
# @option item [String] :text Message
|
|
18
|
+
def index(params = {})
|
|
19
|
+
@client.call('premium/index', params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Send reply for received SMS Premium
|
|
23
|
+
#
|
|
24
|
+
# @param phone [String] Recipient phone number
|
|
25
|
+
# @param text [String] Message
|
|
26
|
+
# @param gate [String] Premium number
|
|
27
|
+
# @param id [Integer] ID of received SMS Premium
|
|
28
|
+
# @return [Hash]
|
|
29
|
+
# @option return [Boolean] :success
|
|
30
|
+
def send(phone, text, gate, id)
|
|
31
|
+
@client.call('premium/send', 'phone' => phone, 'text' => text, 'gate' => gate, 'id' => id)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# View quiz results
|
|
35
|
+
#
|
|
36
|
+
# @param id [Integer]
|
|
37
|
+
# @return [Hash]
|
|
38
|
+
# @option return [Integer] :id
|
|
39
|
+
# @option return [String] :name
|
|
40
|
+
# @option return [Array] :items
|
|
41
|
+
# @option item [Integer] :id
|
|
42
|
+
# @option item [Integer] :count Number of responses
|
|
43
|
+
def quiz(id)
|
|
44
|
+
@client.call('quiz/view', 'id' => id)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Senders
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Create new sender name
|
|
9
|
+
#
|
|
10
|
+
# @param name [String]
|
|
11
|
+
# @return [Hash]
|
|
12
|
+
# @option return [Boolean] :success
|
|
13
|
+
def add(name)
|
|
14
|
+
@client.call('senders/add', 'name' => name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# List of senders
|
|
18
|
+
#
|
|
19
|
+
# @param params [Hash]
|
|
20
|
+
# @option params [Boolean] :predefined
|
|
21
|
+
# @option params [String] :sort Values: name
|
|
22
|
+
# @option params [String] :order Values: asc|desc
|
|
23
|
+
# @return [Hash]
|
|
24
|
+
# @option return [Array] :items
|
|
25
|
+
# @option item [String] :name
|
|
26
|
+
# @option item [String] :agreement delivered|required|not_required
|
|
27
|
+
# @option item [String] :status pending_authorization|authorized|rejected|deactivated
|
|
28
|
+
def index(params = {})
|
|
29
|
+
@client.call('senders/index', params)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Stats
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Sending statistics
|
|
9
|
+
#
|
|
10
|
+
# @param params [Hash]
|
|
11
|
+
# @option params [String] :type eco|full|voice|mms
|
|
12
|
+
# @option params [String] :begin Start date
|
|
13
|
+
# @option params [String] :end End date
|
|
14
|
+
# @return [Hash]
|
|
15
|
+
# @option return [Array] :items
|
|
16
|
+
# @option item [Integer] :id
|
|
17
|
+
# @option item [String] :name
|
|
18
|
+
# @option item [Integer] :delivered
|
|
19
|
+
# @option item [Integer] :pending
|
|
20
|
+
# @option item [Integer] :undelivered
|
|
21
|
+
# @option item [Integer] :unsent
|
|
22
|
+
# @option item [String] :begin
|
|
23
|
+
# @option item [String] :end
|
|
24
|
+
# @option item [String] :text
|
|
25
|
+
# @option item [String] :type eco|full|voice|mms
|
|
26
|
+
def index(params = {})
|
|
27
|
+
@client.call('stats/index', params)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Subaccounts
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Create new subaccount
|
|
9
|
+
#
|
|
10
|
+
# @param subaccount_username [String]
|
|
11
|
+
# @param subaccount_password [String]
|
|
12
|
+
# @param subaccount_id [Integer] Subaccount ID used as permissions template
|
|
13
|
+
# @param params [Hash]
|
|
14
|
+
# @option params [String] :name
|
|
15
|
+
# @option params [String] :phone
|
|
16
|
+
# @option params [String] :email
|
|
17
|
+
# @return [Hash]
|
|
18
|
+
# @option return [Boolean] :success
|
|
19
|
+
# @option return [Integer] :id
|
|
20
|
+
def add(subaccount_username, subaccount_password, subaccount_id, params = {})
|
|
21
|
+
params['subaccount_username'] = subaccount_username
|
|
22
|
+
params['subaccount_password'] = subaccount_password
|
|
23
|
+
params['subaccount_id'] = subaccount_id
|
|
24
|
+
@client.call('subaccounts/add', params)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# List of subaccounts
|
|
28
|
+
#
|
|
29
|
+
# @return [Hash]
|
|
30
|
+
# @option return [Array] :items
|
|
31
|
+
# @option item [Integer] :id
|
|
32
|
+
# @option item [String] :username
|
|
33
|
+
def index(params = {})
|
|
34
|
+
@client.call('subaccounts/index', params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# View subaccount details
|
|
38
|
+
#
|
|
39
|
+
# @param id [Integer]
|
|
40
|
+
# @return [Hash]
|
|
41
|
+
# @option return [Integer] :id
|
|
42
|
+
# @option return [String] :username
|
|
43
|
+
# @option return [String] :name
|
|
44
|
+
# @option return [String] :phone
|
|
45
|
+
# @option return [String] :email
|
|
46
|
+
def view(id)
|
|
47
|
+
@client.call('subaccounts/view', 'id' => id)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Set limit on subaccount
|
|
51
|
+
#
|
|
52
|
+
# @param id [Integer]
|
|
53
|
+
# @param type [String] eco|full|voice|mms|hlr
|
|
54
|
+
# @param value [Integer]
|
|
55
|
+
# @return [Hash]
|
|
56
|
+
# @option return [Boolean] :success
|
|
57
|
+
# @option return [Integer] :id
|
|
58
|
+
def limit(id, type, value)
|
|
59
|
+
@client.call('subaccounts/limit', 'id' => id, 'type' => type, 'value' => value)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Delete a subaccount
|
|
63
|
+
#
|
|
64
|
+
# @param id [Integer]
|
|
65
|
+
# @return [Hash]
|
|
66
|
+
# @option return [Boolean] :success
|
|
67
|
+
def delete(id)
|
|
68
|
+
@client.call('subaccounts/delete', 'id' => id)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module Resources
|
|
3
|
+
class Templates
|
|
4
|
+
def initialize(client)
|
|
5
|
+
@client = client
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# List of templates
|
|
9
|
+
#
|
|
10
|
+
# @param params [Hash]
|
|
11
|
+
# @option params [String] :sort Values: name
|
|
12
|
+
# @option params [String] :order Values: asc|desc
|
|
13
|
+
# @return [Hash]
|
|
14
|
+
# @option return [Array] :items
|
|
15
|
+
# @option item [Integer] :id
|
|
16
|
+
# @option item [String] :name
|
|
17
|
+
# @option item [String] :text
|
|
18
|
+
def index(params = {})
|
|
19
|
+
@client.call('templates/index', params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Add new template
|
|
23
|
+
#
|
|
24
|
+
# @param name [String]
|
|
25
|
+
# @param text [String]
|
|
26
|
+
# @return [Hash]
|
|
27
|
+
# @option return [Boolean] :success
|
|
28
|
+
# @option return [Integer] :id
|
|
29
|
+
def add(name, text)
|
|
30
|
+
@client.call('templates/add', 'name' => name, 'text' => text)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Edit a template
|
|
34
|
+
#
|
|
35
|
+
# @param id [Integer]
|
|
36
|
+
# @param name [String]
|
|
37
|
+
# @param text [String]
|
|
38
|
+
# @return [Hash]
|
|
39
|
+
# @option return [Boolean] :success
|
|
40
|
+
# @option return [Integer] :id
|
|
41
|
+
def edit(id, name, text)
|
|
42
|
+
@client.call('templates/edit', 'id' => id, 'name' => name, 'text' => text)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Delete a template
|
|
46
|
+
#
|
|
47
|
+
# @param id [Integer]
|
|
48
|
+
# @return [Hash]
|
|
49
|
+
# @option return [Boolean] :success
|
|
50
|
+
def delete(id)
|
|
51
|
+
@client.call('templates/delete', 'id' => id)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module SerwerSMS
|
|
2
|
+
module ResourcesMixin
|
|
3
|
+
def messages
|
|
4
|
+
@messages ||= SerwerSMS::Resources::Messages.new(self)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def accounts
|
|
8
|
+
@accounts ||= SerwerSMS::Resources::Accounts.new(self)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def blacklist
|
|
12
|
+
@blacklist ||= SerwerSMS::Resources::Blacklist.new(self)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def contacts
|
|
16
|
+
@contacts ||= SerwerSMS::Resources::Contacts.new(self)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def error
|
|
20
|
+
@error ||= SerwerSMS::Resources::Error.new(self)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def files
|
|
24
|
+
@files ||= SerwerSMS::Resources::Files.new(self)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def groups
|
|
28
|
+
@groups ||= SerwerSMS::Resources::Groups.new(self)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def phones
|
|
32
|
+
@phones ||= SerwerSMS::Resources::Phones.new(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def premium
|
|
36
|
+
@premium ||= SerwerSMS::Resources::Premium.new(self)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def senders
|
|
40
|
+
@senders ||= SerwerSMS::Resources::Senders.new(self)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def stats
|
|
44
|
+
@stats ||= SerwerSMS::Resources::Stats.new(self)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def subaccounts
|
|
48
|
+
@subaccounts ||= SerwerSMS::Resources::Subaccounts.new(self)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def templates
|
|
52
|
+
@templates ||= SerwerSMS::Resources::Templates.new(self)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/serwersms.rb
CHANGED
|
@@ -1,58 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@username = username
|
|
23
|
-
@password = password
|
|
24
|
-
@messages = Messages.new(self)
|
|
25
|
-
@files = Files.new(self)
|
|
26
|
-
@premium = Premium.new(self)
|
|
27
|
-
@accounts = Accounts.new(self)
|
|
28
|
-
@senders = Senders.new(self)
|
|
29
|
-
@groups = Groups.new(self)
|
|
30
|
-
@contacts = Contacts.new(self)
|
|
31
|
-
@phones = Phones.new(self)
|
|
32
|
-
@subaccounts = Subaccounts.new(self)
|
|
33
|
-
@blacklist = Blacklist.new(self)
|
|
34
|
-
@payments = Payments.new(self)
|
|
35
|
-
@stats = Stats.new(self)
|
|
36
|
-
@templates = Templates.new(self)
|
|
37
|
-
@error = Error.new(self)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def call(url, params = {})
|
|
41
|
-
uri = URI.parse(@@api_url+url)
|
|
42
|
-
https = Net::HTTP.new(uri.host,uri.port)
|
|
43
|
-
req = Net::HTTP::Post.new(uri.path,{'Content-Type' => 'application/json'})
|
|
44
|
-
params['username'] = @username
|
|
45
|
-
params['password'] = @password
|
|
46
|
-
params['system'] = @@system
|
|
47
|
-
puts @@system
|
|
48
|
-
req.body = params.to_json
|
|
49
|
-
res = https.request(req)
|
|
50
|
-
|
|
51
|
-
return res.body
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
require 'net/http'
|
|
56
|
-
require 'net/https'
|
|
57
|
-
require 'json'
|
|
58
|
-
Dir[File.dirname(__FILE__) + '/library/*.rb'].each {|file| require file }
|
|
1
|
+
require 'serwersms/error'
|
|
2
|
+
require 'serwersms/http/api_client'
|
|
3
|
+
require 'serwersms/http/http_credentials'
|
|
4
|
+
require 'serwersms/http/http_token'
|
|
5
|
+
require 'serwersms/resources/accounts'
|
|
6
|
+
require 'serwersms/resources/blacklist'
|
|
7
|
+
require 'serwersms/resources/contacts'
|
|
8
|
+
require 'serwersms/resources/error'
|
|
9
|
+
require 'serwersms/resources/files'
|
|
10
|
+
require 'serwersms/resources/groups'
|
|
11
|
+
require 'serwersms/resources/messages'
|
|
12
|
+
require 'serwersms/resources/phones'
|
|
13
|
+
require 'serwersms/resources/premium'
|
|
14
|
+
require 'serwersms/resources/senders'
|
|
15
|
+
require 'serwersms/resources/stats'
|
|
16
|
+
require 'serwersms/resources/subaccounts'
|
|
17
|
+
require 'serwersms/resources/templates'
|
|
18
|
+
require 'serwersms/resources_mixin'
|
|
19
|
+
require 'serwersms/client_credentials'
|
|
20
|
+
require 'serwersms/client_token'
|
|
21
|
+
require 'serwersms/client_factory'
|