startmobile_sms 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,15 +11,26 @@ The easy way to send and check a single sms with startmobile.com.ua provider.
11
11
  StartmobileSms.setup do |config|
12
12
  config.login = 'login'
13
13
  config.password = 'password'
14
+ config.out_number = 'out_number'
14
15
  end
15
16
 
16
17
  == Usage
17
18
 
18
- # Send single sms
19
+ # Send single sms (out_number is optional)
19
20
  sms_id = StartmobileSms.send(:phone => '30971234567', :text => 'Hello!', :out_number => 'service_name')
20
21
 
21
22
  # Check sms delivery status
22
23
  StartmobileSms.check(sms_id)
24
+
25
+ # Or use instance object
26
+ sms = StartmobileSms::Message.new(:phone => '30971234567', :text => 'Hello!')
27
+
28
+ sms.phone # 30971234567
29
+ sms.text # Hello!
30
+ sms.send # send sms to server
31
+ sms.id # response id
32
+
33
+ sms.status # check sms status (Accepted, Enroute, Delivered, Expired, Deleted, Undeliverable, Rejected, Unknown)
23
34
 
24
35
  == Wiki
25
36
 
@@ -25,13 +25,14 @@ module StartmobileSms
25
25
  end
26
26
  end
27
27
 
28
- hash_accessor :login, :password, :post_url
28
+ hash_accessor :login, :password, :post_url, :out_number
29
29
 
30
30
  def initialize(other = {})
31
31
  merge!(other)
32
32
 
33
33
  self[:login] ||= 'login'
34
34
  self[:password] ||= 'password'
35
+ self[:out_number] ||= 'INFO'
35
36
  self[:post_url] ||= 'http://bulk.startmobile.com.ua/clients.php'
36
37
  end
37
38
  end
@@ -5,11 +5,12 @@ module StartmobileSms
5
5
  class Message
6
6
 
7
7
  attr_accessor :phone, :text, :out_number
8
+ attr_reader :id
8
9
 
9
10
  def initialize(options={})
10
11
  @phone = options[:phone]
11
12
  @text = options[:text]
12
- @out_number = options[:out_number] || 'INFO'
13
+ @out_number = options[:out_number] || StartmobileSms.config.out_number
13
14
  end
14
15
 
15
16
  def xml_content
@@ -43,11 +44,10 @@ module StartmobileSms
43
44
  return nil unless response
44
45
 
45
46
  doc = Nokogiri::XML(response)
46
- doc.at('.//id').content
47
+ @id = doc.at('.//id').content
47
48
  end
48
49
 
49
-
50
- def check(id)
50
+ def check(id=@id)
51
51
  response = make_post(check_content(id))
52
52
  return nil unless response
53
53
 
@@ -55,6 +55,10 @@ module StartmobileSms
55
55
  doc.at('.//state').content
56
56
  end
57
57
 
58
+ def status
59
+ @id.nil? ? 'You must send sms before check' : check
60
+ end
61
+
58
62
  # Class methods
59
63
 
60
64
  def self.send(options)
@@ -1,3 +1,3 @@
1
1
  module StartmobileSms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startmobile_sms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Galeta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-17 00:00:00 +02:00
18
+ date: 2012-01-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency