voicecom_sms 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWQxNGQ1NWZmZWUyOWNiZTk2ZDEwYjlmZTVhODg5YmVkMTIyMTBiMg==
4
+ NWM4YjVlZWI5YzQ3YmI4MzlmMjgwZTE3YzQ4MmIxYjkyMGE4ODhkMA==
5
5
  data.tar.gz: !binary |-
6
- Nzg1ZTdjMjE3YTk4MTc3ZGYwNGFmZjFhYjQ0MGNjZGYxYzE0YmVjYQ==
6
+ NjQzNWZhYzMxNjU5MjY2NmQyMmYxMDU1N2JiZjEyMzgxM2Y3YTRiNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTY4NTJjYzc0ODhmYWVmNjY4OGY3YjQ1OGNjYTVkOTlmNjdmNTg2Y2U2NjI1
10
- N2FhNzBlNzY3Njc5ZWZjMTI3ZjNjYTEwODIyOGU5ZjU4MmFlY2I5MzhiMmM1
11
- MzFkYzA3ODA2Mzg0N2NiZDg2OGViNzVmYWFiZGJkMmEzMDg5Nzk=
9
+ ZWYyMTNmMTgzZTg2NWE0ZWYwM2UwY2YyZDBiZWQzM2VhMWE0YmZhYzAwMWNi
10
+ M2NjNmY3OWQ1Y2FiNjM0NjA5Mjg1MTlmNDRmMWIxZDlhYWI3YzNlMjAyNzE2
11
+ MWU2MjBiZDY5MTI5YTEwOGRlNjRkYzQ2MzVhYmNjYzNjNzMwYTI=
12
12
  data.tar.gz: !binary |-
13
- YzQxOTViMGFmNGYxYTdlMTMzMzk4MzYwNmE0Y2Y4OTBiYTgwYTMxNGQ3NGJi
14
- OWQ3ZjVmMThhNzIyOTYxYzdiZGM2OGRmYzg0M2I1OGM5NGViNWRlZmY5YzNk
15
- ZWRkZGJmNGRjN2M2OGEyMTA2YWUxNGJhZThlNzczMDdmM2EzZDg=
13
+ NjQzZWYwMzdmZTRhNWM1YjBhYzJhODI3YWVjMWU2ZDBhZDZmYzc1NDE3NmNj
14
+ MDhjMjNmYjJkYjZkYjJjMDIyNGY2YjBhZTdlODA0ZmQ0NzQ2ZTFhNzNlNGJk
15
+ ZTgwZWVhNWE4ZmYyNDA0Y2IxOTZjOTY1ZWE3MGUzYzYwOWYyYjQ=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.0
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
- make_request(message, number, text)
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.status
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: message.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}&id=1&msisdn=359899947329&text=some+message").
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 == VoicecomSms::Provider::STATUS[:success]
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.0.0"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voicecom_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Empowerunited