clockworksms 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -6
- data/README.md +70 -54
- data/lib/clockwork/api.rb +6 -3
- data/lib/clockwork/sms.rb +4 -2
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b320572710fdd15caaa287b035fb5986e1716e6a
|
4
|
+
data.tar.gz: 4f245423d51515acd428a39b4943e45c8c916160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b73d28a88ab322b465c97617e4439019017910ac93a4471f7b7f8464c84945c7a9bc1428122a31b5c5149cd3c988be97b51720631256509e8727859ad3e2b26
|
7
|
+
data.tar.gz: 172feb809d68e8b4ba93251508f975be48a9ffc770b009d10afb6e9066ea52c9bca268a0ae6e2e52dd0076365e727b48c1b803fa8cdff543383e0253533c9155
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Clockwork SMS API Ruby Gem
|
2
|
-
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/clockworksms.svg)](http://badge.fury.io/rb/clockworksms)
|
3
3
|
## Install
|
4
4
|
|
5
5
|
Just add the following to your Gemfile:
|
@@ -18,71 +18,80 @@ For more information on the available optional parameters for each SMS (Clockwor
|
|
18
18
|
|
19
19
|
### Send a single SMS message
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if response.success
|
27
|
-
puts response.message_id
|
28
|
-
else
|
29
|
-
puts response.error_code
|
30
|
-
puts response.error_description
|
31
|
-
end
|
21
|
+
```ruby
|
22
|
+
require 'clockwork'
|
23
|
+
api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
|
24
|
+
message = api.messages.build( :to => '441234123456', :content => 'This is a test message.' )
|
25
|
+
response = message.deliver
|
32
26
|
|
27
|
+
if response.success
|
28
|
+
puts response.message_id
|
29
|
+
else
|
30
|
+
puts response.error_code
|
31
|
+
puts response.error_description
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
33
35
|
### Alternative usage for sending an SMS message
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
message = api.messages.build
|
39
|
-
message.to = '441234123456'
|
40
|
-
message.content = 'This is a test message.'
|
41
|
-
response = message.deliver
|
37
|
+
```ruby
|
38
|
+
require 'clockwork'
|
39
|
+
api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
|
42
40
|
|
41
|
+
message = api.messages.build
|
42
|
+
message.to = '441234123456'
|
43
|
+
message.content = 'This is a test message.'
|
44
|
+
response = message.deliver
|
45
|
+
|
46
|
+
if response.success
|
47
|
+
puts response.message_id
|
48
|
+
else
|
49
|
+
puts response.error_code
|
50
|
+
puts response.error_description
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
### Send multiple SMS messages (with an optional client ID)
|
55
|
+
|
56
|
+
You should not use the `Clockwork::Message#deliver` method for each message, but instead use the `Clockwork::API#deliver` method to send multiple messages in the same API request. This will decrease load on the API and ensure your requests are processed significantly faster.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
|
60
|
+
messages = [
|
61
|
+
{ :to => '441234123456', :content => 'This is a test message.', :client_id => '1' },
|
62
|
+
{ :to => '441234123456', :content => 'This is a test message 2.', :client_id => '2' },
|
63
|
+
{ :to => '441234123456', :content => 'This is a test message 3.', :client_id => '3' },
|
64
|
+
{ :to => '441234123456', :content => 'This is a test message 4.', :client_id => '4' },
|
65
|
+
{ :to => '441234123456', :content => 'This is a test message 5.', :client_id => '5' },
|
66
|
+
{ :to => '441234123456', :content => 'This is a test message 6.', :client_id => '6' }
|
67
|
+
]
|
68
|
+
|
69
|
+
require 'clockwork'
|
70
|
+
api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
|
71
|
+
messages.each do |m|
|
72
|
+
api.messages.build(m)
|
73
|
+
end
|
74
|
+
|
75
|
+
responses = api.deliver_messages
|
76
|
+
responses.each do |response|
|
77
|
+
puts response.client_id
|
43
78
|
if response.success
|
44
79
|
puts response.message_id
|
45
80
|
else
|
46
81
|
puts response.error_code
|
47
82
|
puts response.error_description
|
48
83
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
You should not use the `Clockwork::Message#deliver` method for each message, but instead use the `Clockwork::API#deliver` method to send multiple messages in the same API request. This will decrease load on the API and ensure your requests are processed significantly faster.
|
53
|
-
|
54
|
-
messages = [
|
55
|
-
{ :to => '441234123456', :content => 'This is a test message.', :client_id => '1' },
|
56
|
-
{ :to => '441234123456', :content => 'This is a test message 2.', :client_id => '2' },
|
57
|
-
{ :to => '441234123456', :content => 'This is a test message 3.', :client_id => '3' },
|
58
|
-
{ :to => '441234123456', :content => 'This is a test message 4.', :client_id => '4' },
|
59
|
-
{ :to => '441234123456', :content => 'This is a test message 5.', :client_id => '5' },
|
60
|
-
{ :to => '441234123456', :content => 'This is a test message 6.', :client_id => '6' }
|
61
|
-
]
|
62
|
-
|
63
|
-
require 'clockwork'
|
64
|
-
api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
|
65
|
-
messages.each do |m|
|
66
|
-
api.messages.build(m)
|
67
|
-
end
|
68
|
-
|
69
|
-
responses = api.deliver_messages
|
70
|
-
responses.each do |response|
|
71
|
-
puts response.client_id
|
72
|
-
if response.success
|
73
|
-
puts response.message_id
|
74
|
-
else
|
75
|
-
puts response.error_code
|
76
|
-
puts response.error_description
|
77
|
-
end
|
78
|
-
end
|
84
|
+
end
|
85
|
+
```
|
79
86
|
|
80
87
|
### Check balance
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
```ruby
|
90
|
+
require 'clockwork'
|
91
|
+
api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
|
92
|
+
balance = Clockwork::API.balance
|
93
|
+
puts balance # => { :account_type => "PAYG", :balance => 575.23, :currency => { :code => "GBP", :symbol => "£" } }
|
94
|
+
```
|
86
95
|
|
87
96
|
## License
|
88
97
|
|
@@ -131,4 +140,11 @@ Then, run `rspec`.
|
|
131
140
|
|
132
141
|
### 1.2.0 (30th June, 2014)
|
133
142
|
|
134
|
-
* Compatability fixes for Ruby 1.8, 2.0 and 2.1 (Tested with 1.8.7-p375, 1.9.3-p547, 2.0.0-p481 and 2.1.2)
|
143
|
+
* Compatability fixes for Ruby 1.8, 2.0 and 2.1 (Tested with 1.8.7-p375, 1.9.3-p547, 2.0.0-p481 and 2.1.2).
|
144
|
+
Thanks to [Paul Volpato](https://github.com/volpe), [Todd Bealmear](https://github.com/todd) and [Fawad](https://github.com/fawad) for the pull requests.
|
145
|
+
|
146
|
+
### 1.2.1 (28th September, 2014)
|
147
|
+
|
148
|
+
* Add some tests for the invalid_char_action and truncate parameters.
|
149
|
+
* Fix invalid_char_action parameter as it was passing invalid values to the Clockwork API.
|
150
|
+
Thanks to [Tom Pesman](https://github.com/tompesman) for the fix.
|
data/lib/clockwork/api.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Clockwork
|
3
3
|
|
4
4
|
# Current API wrapper version
|
5
|
-
VERSION = '1.1
|
5
|
+
VERSION = '1.2.1'
|
6
6
|
|
7
7
|
# @author James Inman <james@mediaburst.co.uk>
|
8
8
|
# You must create an instance of Clockwork::API to begin using the API.
|
@@ -58,7 +58,7 @@ module Clockwork
|
|
58
58
|
# @return [boolean]
|
59
59
|
# @note This can be overriden for specific Clockwork::SMS objects; if it is not set your account default will be used.
|
60
60
|
attr_accessor :truncate
|
61
|
-
|
61
|
+
|
62
62
|
# Whether to use SSL when connecting to the API.
|
63
63
|
# Defaults to +true+
|
64
64
|
# @return [boolean]
|
@@ -76,7 +76,8 @@ module Clockwork
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def invalid_char_action= symbol
|
79
|
-
raise( ArgumentError, "#{symbol} must be one of :error, :replace, :remove" ) unless [:error, :
|
79
|
+
raise( ArgumentError, "#{symbol} must be one of :error, :replace, :remove" ) unless [:error, :remove, :replace].include?(symbol.to_sym)
|
80
|
+
@invalid_char_action = [nil, :error, :remove, :replace].index(symbol.to_sym)
|
80
81
|
end
|
81
82
|
|
82
83
|
def concat= number
|
@@ -111,6 +112,8 @@ module Clockwork
|
|
111
112
|
@use_ssl = true if @use_ssl.nil?
|
112
113
|
@concat = 3 if @concat.nil? && @long
|
113
114
|
@messages ||= Clockwork::MessageCollection.new( :api => self )
|
115
|
+
@invalid_char_action = [nil, :error, :remove, :replace].index(@invalid_char_action) if @invalid_char_action
|
116
|
+
@truncate = @truncate ? true : false unless @truncate.nil?
|
114
117
|
end
|
115
118
|
|
116
119
|
# Check the remaining credit for this account.
|
data/lib/clockwork/sms.rb
CHANGED
@@ -36,7 +36,7 @@ module Clockwork
|
|
36
36
|
# @return [boolean]
|
37
37
|
# @note If this option is set it overrides the global option specified in Clockwork::API for this SMS, if neither option is set your account default will be used.
|
38
38
|
attr_accessor :truncate
|
39
|
-
|
39
|
+
|
40
40
|
# What to do with any invalid characters in the message content. +:error+ will raise a Clockwork::InvalidCharacterException, +:replace+ will replace a small number of common invalid characters, such as the smart quotes used by Microsoft Office with a similar match, +:remove+ will remove invalid characters.
|
41
41
|
# @raise ArgumentError - if value is not one of +:error+, +:replace+, +:remove+
|
42
42
|
# @return [symbol] One of +error+, +:replace+, +:remove+
|
@@ -51,13 +51,15 @@ module Clockwork
|
|
51
51
|
attr_writer :wrapper_id
|
52
52
|
|
53
53
|
def invalid_char_action= symbol
|
54
|
-
raise( ArgumentError, "#{symbol} must be one of :error, :replace, :remove" ) unless [:error, :
|
54
|
+
raise( ArgumentError, "#{symbol} must be one of :error, :replace, :remove" ) unless [:error, :remove, :replace].include?(symbol.to_sym)
|
55
55
|
end
|
56
56
|
|
57
57
|
# @param [hash] options Optional hash of attributes on Clockwork::SMS
|
58
58
|
# Create a new SMS message.
|
59
59
|
def initialize options = {}
|
60
60
|
options.each { |k, v| instance_variable_set "@#{k}", v } if options.kind_of?(Hash)
|
61
|
+
@invalid_char_action = [nil, :error, :remove, :replace].index(@invalid_char_action) if @invalid_char_action
|
62
|
+
@truncate = @truncate ? true : false unless @truncate.nil?
|
61
63
|
end
|
62
64
|
|
63
65
|
# Deliver the SMS message.
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clockworksms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mediaburst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.5.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake-compiler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '3.1'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '3.1'
|
55
69
|
description: Ruby Gem for the Clockwork API. Send text messages with the easy to use
|
56
70
|
SMS API from Mediaburst.
|
57
71
|
email: hello@mediaburst.co.uk
|
@@ -59,21 +73,21 @@ executables: []
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- Gemfile
|
77
|
+
- Gemfile.lock
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- lib/clockwork.rb
|
62
81
|
- lib/clockwork/api.rb
|
63
82
|
- lib/clockwork/error.rb
|
64
83
|
- lib/clockwork/http.rb
|
65
84
|
- lib/clockwork/message_collection.rb
|
66
|
-
- lib/clockwork/sms/response.rb
|
67
85
|
- lib/clockwork/sms.rb
|
86
|
+
- lib/clockwork/sms/response.rb
|
68
87
|
- lib/clockwork/xml/balance.rb
|
69
88
|
- lib/clockwork/xml/credit.rb
|
70
89
|
- lib/clockwork/xml/sms.rb
|
71
90
|
- lib/clockwork/xml/xml.rb
|
72
|
-
- lib/clockwork.rb
|
73
|
-
- Gemfile
|
74
|
-
- Gemfile.lock
|
75
|
-
- LICENSE
|
76
|
-
- README.md
|
77
91
|
homepage: http://www.clockworksms.com/
|
78
92
|
licenses:
|
79
93
|
- MIT
|
@@ -84,17 +98,17 @@ require_paths:
|
|
84
98
|
- lib
|
85
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
105
|
requirements:
|
92
|
-
- -
|
106
|
+
- - ">="
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: '0'
|
95
109
|
requirements: []
|
96
110
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.2.2
|
98
112
|
signing_key:
|
99
113
|
specification_version: 4
|
100
114
|
summary: Ruby Gem for the Clockwork API.
|