Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (87 sloc) 4.365 kB
2b06bf1 @jfi Updating version to 1.0.0, README edits.
jfi authored
1 # Clockwork SMS API Ruby Gem
59f5d7c @jfi Adding things still to do to the README.
jfi authored
2
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
3 ## Install
c22094c @jfi Updating README with documentation link.
jfi authored
4
3d9f05a @jfi Updating gem name to 'clockworksms'.
jfi authored
5 Just add the following to your Gemfile:
6
7 gem 'clockworksms'
c22094c @jfi Updating README with documentation link.
jfi authored
8
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
9 ## Documentation
c22094c @jfi Updating README with documentation link.
jfi authored
10
11 Full documentation is at [http://rubydoc.info/github/mediaburst/clockwork-ruby/master/frames][1]. Alternatively, run `yard doc` and open doc/index.html.
12
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
13 ## Usage
c22094c @jfi Updating README with documentation link.
jfi authored
14
f682bb4 @jfi Further README updates.
jfi authored
15 For more information on the available optional parameters for the API (Clockwork::API), see [here][4].
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
16
f682bb4 @jfi Further README updates.
jfi authored
17 For more information on the available optional parameters for each SMS (Clockwork::SMS), see [here][5]. For more information on the response object returned from each SMS (Clockwork::SMS::Response), see [here][6].
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
18
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
19 ### Send a single SMS message
9ba9904 @jfi README updates with usage.
jfi authored
20
21 require 'clockwork'
22 api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
23 message = api.messages.build( :to => '441234123456', :content => 'This is a test message.' )
24 response = message.deliver
9ba9904 @jfi README updates with usage.
jfi authored
25
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
26 if response.success
27 puts response.message_id
28 else
29 puts response.error_code
30 puts response.error_description
9ba9904 @jfi README updates with usage.
jfi authored
31 end
32
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
33 ### Alternative usage for sending an SMS message
9ba9904 @jfi README updates with usage.
jfi authored
34
35 require 'clockwork'
36 api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
37
38 message = api.messages.build
9ba9904 @jfi README updates with usage.
jfi authored
39 message.to = '441234123456'
40 message.content = 'This is a test message.'
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
41 response = message.deliver
9ba9904 @jfi README updates with usage.
jfi authored
42
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
43 if response.success
44 puts response.message_id
45 else
46 puts response.error_code
47 puts response.error_description
9ba9904 @jfi README updates with usage.
jfi authored
48 end
49
2208f2e @jfi Matching messages up on returned result.
jfi authored
50 ### Send multiple SMS messages (with an optional client ID)
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
51
2208f2e @jfi Matching messages up on returned result.
jfi authored
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.
9ba9904 @jfi README updates with usage.
jfi authored
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
c22094c @jfi Updating README with documentation link.
jfi authored
63 require 'clockwork'
64 api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
9ba9904 @jfi README updates with usage.
jfi authored
65 messages.each do |m|
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
66 api.messages.build(m)
67 end
9ba9904 @jfi README updates with usage.
jfi authored
68
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
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
9ba9904 @jfi README updates with usage.
jfi authored
77 end
78 end
6c8b37b @jfi Adding check credit, dummy test details, HTTP library.
jfi authored
79
6774dfe @jfi [RELEASE] 1.1 Update to use API#balance.
jfi authored
80 ### Check balance
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
81
82 require 'clockwork'
83 api = Clockwork::API.new( 'API_KEY_GOES_HERE' )
6774dfe @jfi [RELEASE] 1.1 Update to use API#balance.
jfi authored
84 balance = Clockwork::API.balance
85 puts balance # => { :account_type => "PAYG", :balance => 575.23, :currency => { :code => "GBP", :symbol => "£" } }
6c8b37b @jfi Adding check credit, dummy test details, HTTP library.
jfi authored
86
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
87 ## License
bb39934 @jfi README updates.
jfi authored
88
89 This project is licensed under the ISC open-source license.
90
91 A copy of this license can be found in LICENSE.
92
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
93 ## Contributing
bb39934 @jfi README updates.
jfi authored
94
c22094c @jfi Updating README with documentation link.
jfi authored
95 If you have any feedback on this wrapper drop us an email to [hello@clockworksms.com][2].
bb39934 @jfi README updates.
jfi authored
96
c22094c @jfi Updating README with documentation link.
jfi authored
97 The project is hosted on GitHub at [http://www.github.com/mediaburst/clockwork-ruby][3].
bb39934 @jfi README updates.
jfi authored
98
99 If you would like to contribute a bug fix or improvement please fork the project
c22094c @jfi Updating README with documentation link.
jfi authored
100 and submit a pull request. Please add RSpec tests for your use case.
56a8f43 @jfi Adding links to README.
jfi authored
101
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
102 ### Test Setup
103
104 First, create a file at spec/spec_authentication_details containing the following:
105
d5c32ad @jfi Removing legacy tests.
jfi authored
106 YOUR_API_KEY_HERE
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
107
6774dfe @jfi [RELEASE] 1.1 Update to use API#balance.
jfi authored
108 Substitute your own API key on line 1 of the file and replace the telephone numbers in the spec files with your own.
e39930b @jfi Tidying up README formatting, adding usage for credit checking.
jfi authored
109
110 Then, run `rspec`.
111
c22094c @jfi Updating README with documentation link.
jfi authored
112 [1]: http://rubydoc.info/github/mediaburst/clockwork-ruby/master/frames
113 [2]: mailto:hello@clockworksms.com
6792cfb @jfi Adding legacy API#send_message and new SMS::Response object.
jfi authored
114 [3]: http://www.github.com/mediaburst/clockwork-ruby
115 [4]: http://rubydoc.info/github/mediaburst/clockwork-ruby/master/Clockwork/API
97ef58f @jfi README updates.
jfi authored
116 [5]: http://rubydoc.info/github/mediaburst/clockwork-ruby/master/Clockwork/SMS
6774dfe @jfi [RELEASE] 1.1 Update to use API#balance.
jfi authored
117 [6]: http://rubydoc.info/github/mediaburst/clockwork-ruby/master/Clockwork/SMS/Response
118
119 ## Changelog
120
121 ### 1.0.0 (18th July, 2012)
122
123 * Initial release of wrapper [JI]
124
125 ### 1.1.0 (10th September, 2012)
126
127 * API#credit is now deprecated: use API#balance instead.
Something went wrong with that request. Please try again.