voicecom_sms 4.0.0 → 4.1.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 +8 -8
- data/VERSION +1 -1
- data/lib/voicecom_sms/provider.rb +15 -5
- data/spec/voicecom_sms/provider_spec.rb +2 -2
- data/voicecom_sms.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
NWM4YjVlZWI5YzQ3YmI4MzlmMjgwZTE3YzQ4MmIxYjkyMGE4ODhkMA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NjQzNWZhYzMxNjU5MjY2NmQyMmYxMDU1N2JiZjEyMzgxM2Y3YTRiNw==
|
|
7
7
|
!binary "U0hBNTEy":
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
ZWYyMTNmMTgzZTg2NWE0ZWYwM2UwY2YyZDBiZWQzM2VhMWE0YmZhYzAwMWNi
|
|
10
|
+
M2NjNmY3OWQ1Y2FiNjM0NjA5Mjg1MTlmNDRmMWIxZDlhYWI3YzNlMjAyNzE2
|
|
11
|
+
MWU2MjBiZDY5MTI5YTEwOGRlNjRkYzQ2MzVhYmNjYzNjNzMwYTI=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NjQzZWYwMzdmZTRhNWM1YjBhYzJhODI3YWVjMWU2ZDBhZDZmYzc1NDE3NmNj
|
|
14
|
+
MDhjMjNmYjJkYjZkYjJjMDIyNGY2YjBhZTdlODA0ZmQ0NzQ2ZTFhNzNlNGJk
|
|
15
|
+
ZTgwZWVhNWE4ZmYyNDA0Y2IxOTZjOTY1ZWE3MGUzYzYwOWYyYjQ=
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.1.0
|
|
@@ -24,12 +24,22 @@ module VoicecomSms
|
|
|
24
24
|
# example: for Bulgaria (+359) and mobile number 899947121 you should use '359899947121'
|
|
25
25
|
# @param text String No idea what characters is supported by voicecom - have to experiment. UTF-8 with latin works for sure.
|
|
26
26
|
#
|
|
27
|
+
# @block number it will yield the current message id if you want to process it. for exampel to add the environment
|
|
28
|
+
# send_sms('123', 'hi') do |id|
|
|
29
|
+
# "#{Rails.env}-#{id}"
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
27
32
|
# @return VoicecomSms::Message - you can take the status field from there, and have the id of the transaction.
|
|
28
|
-
def send_sms(number, text)
|
|
33
|
+
def send_sms(number, text, &block)
|
|
29
34
|
message = VoicecomSms::Message.create({text: text, number: normalize_number(number), status: STATUS[:undefined]})
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
message_id = if block_given?
|
|
37
|
+
yield message.id
|
|
38
|
+
else
|
|
39
|
+
message_id
|
|
40
|
+
end
|
|
32
41
|
|
|
42
|
+
make_request(message, number, text, message_id)
|
|
33
43
|
|
|
34
44
|
if @request.error or !@request.sent?
|
|
35
45
|
message.update_attributes(response: @request.error, status: STATUS[:failure])
|
|
@@ -40,7 +50,7 @@ module VoicecomSms
|
|
|
40
50
|
message.update_attributes(response: @response.inspect, status: status, response_received_at: Time.current)
|
|
41
51
|
end
|
|
42
52
|
|
|
43
|
-
message
|
|
53
|
+
message
|
|
44
54
|
end
|
|
45
55
|
|
|
46
56
|
def normalize_number(number)
|
|
@@ -49,11 +59,11 @@ module VoicecomSms
|
|
|
49
59
|
end
|
|
50
60
|
|
|
51
61
|
private
|
|
52
|
-
def make_request(message, number, text)
|
|
62
|
+
def make_request(message, number, text, message_id)
|
|
53
63
|
|
|
54
64
|
@request.params = {
|
|
55
65
|
sid: VoicecomSms.config.client_id,
|
|
56
|
-
id:
|
|
66
|
+
id: message_id,
|
|
57
67
|
msisdn: number,
|
|
58
68
|
text: text,
|
|
59
69
|
#priority: 2, # 1 - high priority, 2 - normal priority (default)
|
|
@@ -23,7 +23,7 @@ describe VoicecomSms::Provider do
|
|
|
23
23
|
describe "#send_sms" do
|
|
24
24
|
before(:each) do
|
|
25
25
|
@provider = VoicecomSms::Provider.new
|
|
26
|
-
stub_request(:get, "https://localhost:8443/smsapi/bsms/index.php?sid=#{VoicecomSms.config.client_id}&
|
|
26
|
+
stub_request(:get, "https://localhost:8443/smsapi/bsms/index.php?id&msisdn=359899947329&sid=#{VoicecomSms.config.client_id}&text=some%20message").
|
|
27
27
|
to_return(lambda { |request| File.new("request_stubs/success.curl")})
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -59,7 +59,7 @@ describe VoicecomSms::Provider do
|
|
|
59
59
|
|
|
60
60
|
it "should return the status" do
|
|
61
61
|
result = @provider.send_sms(destination_mobile_number, 'some message')
|
|
62
|
-
result.should
|
|
62
|
+
result.should be_an_instance_of VoicecomSms::Message
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
data/voicecom_sms.gemspec
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "voicecom_sms"
|
|
8
|
-
s.version = "4.
|
|
8
|
+
s.version = "4.1.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Empowerunited", "Evgenia Manolova", "Gudata"]
|