openmarket 0.0.2 → 0.0.3
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 +4 -4
- data/lib/open_market/mo.rb +1 -1
- data/lib/open_market/version.rb +1 -1
- data/open_market.gemspec +2 -2
- metadata +56 -159
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa601bc338b17634fd3ac357b38ee510bd591dde
|
4
|
+
data.tar.gz: aea71451673ef6ab36b970c2f70221c0f8a3de93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24cdeaa397895a7d0e5cce156ed698b9d5856c491bced4ae8a5e12e10cbcbb26f11fa6eacaefa5e90512ae805b2449f23baf0d0723d4439ee1d35f9ed0e89ef
|
7
|
+
data.tar.gz: 7c1c90e79b09ec61d0a2adc309620695a2b1836d278e7d80db1f5e1a08ab428120449cf2959ef66574a2b78e0d0bad1ddd5e56de065be67274ebf6566887155b
|
data/lib/open_market/mo.rb
CHANGED
data/lib/open_market/version.rb
CHANGED
data/open_market.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = OpenMarket::VERSION
|
9
9
|
spec.authors = ["Isaac Betesh"]
|
10
10
|
spec.email = ["iybetesh@gmail.com"]
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = `cat README.md`
|
12
|
+
spec.description = "Send SMS messages using the OpenMarket API"
|
13
13
|
spec.homepage = "https://github.com/betesh/open_market"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openmarket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Betesh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,162 +94,7 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
98
|
-
# OpenMarket
|
99
|
-
|
100
|
-
We use HTTParty to send SMS messages using the OpenMarket API. See USAGE below for details.
|
101
|
-
|
102
|
-
## Installation
|
103
|
-
|
104
|
-
Add this line to your application's Gemfile:
|
105
|
-
|
106
|
-
```ruby
|
107
|
-
gem 'openmarket'
|
108
|
-
```
|
109
|
-
|
110
|
-
And then execute:
|
111
|
-
|
112
|
-
$ bundle
|
113
|
-
|
114
|
-
Or install it yourself as:
|
115
|
-
|
116
|
-
$ gem install openmarket
|
117
|
-
|
118
|
-
## Usage
|
119
|
-
|
120
|
-
### Configuration
|
121
|
-
|
122
|
-
The openmarket gem requires you to provide an id, password, program_id and short_code. Configure them before attempting any API calls.
|
123
|
-
|
124
|
-
```ruby
|
125
|
-
OpenMarket.configure do |config|
|
126
|
-
config.id = "000-000-000-00000"
|
127
|
-
config.password = "Re@llyL0ngR&om$tr1ng"
|
128
|
-
config.program_id = "ABC"
|
129
|
-
config.short_code = 99999 # You can override this on an individual message if necessary
|
130
|
-
end
|
131
|
-
```
|
132
|
-
|
133
|
-
Since the openmarket gem depends on sms_validation (https://github.com/betesh/sms_validation/), it is also recommended that you configure sms_validation.
|
134
|
-
openmarket uses sms_validation's logger. In a Rails environment, you will probably want to rely on the default configuration,
|
135
|
-
but outside of Rails, you will need to configure it if you want any logging:
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
SmsValidation.configure do |config|
|
139
|
-
config.logger = ::Logger.new(STDOUT)
|
140
|
-
end
|
141
|
-
```
|
142
|
-
|
143
|
-
### API calls
|
144
|
-
|
145
|
-
`OpenMarket::API` supports 3 API calls: `carrier_lookup`, `send_sms`, and `status`.
|
146
|
-
|
147
|
-
#### carrier_lookup
|
148
|
-
|
149
|
-
```ruby
|
150
|
-
require 'openmarket'
|
151
|
-
phone = 2125551212
|
152
|
-
result = OpenMarket::API.carrier_lookup(phone)
|
153
|
-
|
154
|
-
# First, make sure the call succeeded
|
155
|
-
puts result.code # should be 0
|
156
|
-
puts result.description # should be 'No Error'
|
157
|
-
|
158
|
-
# If the call succeeded, you can check the carrier_id:
|
159
|
-
puts result.carrier_id # You are probably most interested in the carrier_id
|
160
|
-
puts result.inspect # But there are a lot of other attributes returned by this API call as well
|
161
|
-
```
|
162
|
-
|
163
|
-
#### send_sms
|
164
|
-
|
165
|
-
```ruby
|
166
|
-
require 'openmarket'
|
167
|
-
phone = 2125551212
|
168
|
-
message = "Hello, this is a test of the OpenMarket API"
|
169
|
-
result = OpenMarket::API.send_sms(phone, message)
|
170
|
-
|
171
|
-
# First, make sure the call succeeded
|
172
|
-
puts result.code # should be 2
|
173
|
-
puts result.description # should be 'Message received.'
|
174
|
-
|
175
|
-
# Save the ticket ID for later. We'll use this to query the status of the ticket.
|
176
|
-
ticket_id = result.ticket_id
|
177
|
-
|
178
|
-
# Save the carrier ID for later. We'll use this next time we send an SMS to this number.
|
179
|
-
carrier_id = result.carrier_id
|
180
|
-
|
181
|
-
# There are some options you can pass along as well:
|
182
|
-
result = OpenMarket::API.send_sms(
|
183
|
-
phone,
|
184
|
-
message,
|
185
|
-
|
186
|
-
# If you want to receive DR's, you must pass a dr_url option. If you don't pass a URL, no DR will be sent to the default URL.
|
187
|
-
dr_url: "http://www.example.com/drs",
|
188
|
-
|
189
|
-
# It is highly recommended to pass a carrier_id. If you don't, the openmarket gem will make an extra API call to look up the carrier before sending the message.
|
190
|
-
carrier_id: carrier_id, # Remember the carrier ID we saved from the previous SMS?
|
191
|
-
|
192
|
-
# If you don't want to the short_code you configured above, provide another short_code to send to:
|
193
|
-
short_code: 33333,
|
194
|
-
|
195
|
-
# By default, OpenMarket re-attempts delivery for 3 days. To make OpenMarket give up and report it as a failure sooner, pass a number of minutes you would like to retry for:
|
196
|
-
minutes_to_retry: 120, # 2 hours
|
197
|
-
|
198
|
-
note: "Information that will be passed on to the DR",
|
199
|
-
|
200
|
-
ticket_id_for_retry: ticket_id # If this is a re-try of a failed ticket.
|
201
|
-
)
|
202
|
-
```
|
203
|
-
#### status
|
204
|
-
|
205
|
-
```ruby
|
206
|
-
require 'openmarket'
|
207
|
-
result = OpenMarket::API.status(ticket_id) # Remember the ticket ID we saved from #send_sms?
|
208
|
-
|
209
|
-
# First, make sure the call succeeded
|
210
|
-
puts result.code # should be 0
|
211
|
-
puts result.description # should be 'No Error'
|
212
|
-
|
213
|
-
# Check the result of the SMS message
|
214
|
-
puts result.status_code
|
215
|
-
puts result.status_description
|
216
|
-
```
|
217
|
-
|
218
|
-
### Processing MO's
|
219
|
-
|
220
|
-
```ruby
|
221
|
-
require 'openmarket/mo'
|
222
|
-
# In a Rails controller or Sinatra app environment, params will be defined
|
223
|
-
mo = OpenMarket::MO.new(params['xml'])
|
224
|
-
puts mo.inspect
|
225
|
-
# Do something with the MO...
|
226
|
-
|
227
|
-
# Just send a HTTP 200
|
228
|
-
render nothing: true # Rails
|
229
|
-
return [200] # Sinatra
|
230
|
-
```
|
231
|
-
|
232
|
-
### Processing DR's
|
233
|
-
|
234
|
-
```ruby
|
235
|
-
require 'openmarket/dr'
|
236
|
-
# In a Rails controller or Sinatra app environment, params will be defined
|
237
|
-
dr = OpenMarket::DR.new(params['xml'])
|
238
|
-
puts dr.inspect
|
239
|
-
# Do something with the DR...
|
240
|
-
|
241
|
-
# Just send a HTTP 200
|
242
|
-
render nothing: true # Rails
|
243
|
-
return [200] # Sinatra
|
244
|
-
```
|
245
|
-
|
246
|
-
## Contributing
|
247
|
-
|
248
|
-
1. Fork it ( https://github.com/betesh/open_market/fork )
|
249
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
250
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
251
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
252
|
-
5. Create a new Pull Request
|
97
|
+
description: Send SMS messages using the OpenMarket API
|
253
98
|
email:
|
254
99
|
- iybetesh@gmail.com
|
255
100
|
executables: []
|
@@ -298,7 +143,59 @@ rubyforge_project:
|
|
298
143
|
rubygems_version: 2.4.3
|
299
144
|
signing_key:
|
300
145
|
specification_version: 4
|
301
|
-
summary:
|
146
|
+
summary: '# OpenMarket We use HTTParty to send SMS messages using the OpenMarket
|
147
|
+
API. See USAGE below for details. ## Installation Add this line to your application''s
|
148
|
+
Gemfile: ```ruby gem ''openmarket'' ``` And then execute: $ bundle Or install
|
149
|
+
it yourself as: $ gem install openmarket ## Usage ### Configuration The openmarket
|
150
|
+
gem requires you to provide an id, password, program_id and short_code. Configure
|
151
|
+
them before attempting any API calls. ```ruby OpenMarket.configure do |config|
|
152
|
+
config.id = "000-000-000-00000" config.password = "Re@llyL0ngR&om$tr1ng" config.program_id
|
153
|
+
= "ABC" config.short_code = 99999 # You can override this on an individual message
|
154
|
+
if necessary end ``` Since the openmarket gem depends on sms_validation (https://github.com/betesh/sms_validation/),
|
155
|
+
it is also recommended that you configure sms_validation. openmarket uses sms_validation''s
|
156
|
+
logger. In a Rails environment, you will probably want to rely on the default configuration,
|
157
|
+
but outside of Rails, you will need to configure it if you want any logging: ```ruby
|
158
|
+
SmsValidation.configure do |config| config.logger = ::Logger.new(STDOUT) end ``` ###
|
159
|
+
API calls `OpenMarket::API` supports 3 API calls: `carrier_lookup`, `send_sms`,
|
160
|
+
and `status`. #### carrier_lookup ```ruby require ''openmarket'' phone = 2125551212
|
161
|
+
result = OpenMarket::API.carrier_lookup(phone) # First, make sure the call succeeded
|
162
|
+
puts result.code # should be 0 puts result.description # should be ''No Error'' #
|
163
|
+
If the call succeeded, you can check the carrier_id: puts result.carrier_id # You
|
164
|
+
are probably most interested in the carrier_id puts result.inspect # But there are
|
165
|
+
a lot of other attributes returned by this API call as well ``` #### send_sms ```ruby
|
166
|
+
require ''openmarket'' phone = 2125551212 message = "Hello, this is a test of the
|
167
|
+
OpenMarket API" result = OpenMarket::API.send_sms(phone, message) # First, make
|
168
|
+
sure the call succeeded puts result.code # should be 2 puts result.description #
|
169
|
+
should be ''Message received.'' # Save the ticket ID for later. We''ll use this
|
170
|
+
to query the status of the ticket. ticket_id = result.ticket_id # Save the carrier
|
171
|
+
ID for later. We''ll use this next time we send an SMS to this number. carrier_id
|
172
|
+
= result.carrier_id # There are some options you can pass along as well: result
|
173
|
+
= OpenMarket::API.send_sms( phone, message, # If you want to receive DR''s, you
|
174
|
+
must pass a dr_url option. If you don''t pass a URL, no DR will be sent to the
|
175
|
+
default URL. dr_url: "http://www.example.com/drs", # It is highly recommended to
|
176
|
+
pass a carrier_id. If you don''t, the openmarket gem will make an extra API call
|
177
|
+
to look up the carrier before sending the message. carrier_id: carrier_id, # Remember
|
178
|
+
the carrier ID we saved from the previous SMS? # If you don''t want to the short_code
|
179
|
+
you configured above, provide another short_code to send to: short_code: 33333, #
|
180
|
+
By default, OpenMarket re-attempts delivery for 3 days. To make OpenMarket give
|
181
|
+
up and report it as a failure sooner, pass a number of minutes you would like to
|
182
|
+
retry for: minutes_to_retry: 120, # 2 hours note: "Information that will be passed
|
183
|
+
on to the DR", ticket_id_for_retry: ticket_id # If this is a re-try of a failed
|
184
|
+
ticket. ) ``` #### status ```ruby require ''openmarket'' result = OpenMarket::API.status(ticket_id)
|
185
|
+
# Remember the ticket ID we saved from #send_sms? # First, make sure the call succeeded
|
186
|
+
puts result.code # should be 0 puts result.description # should be ''No Error'' #
|
187
|
+
Check the result of the SMS message puts result.status_code puts result.status_description
|
188
|
+
``` ### Processing MO''s ```ruby require ''openmarket/mo'' # In a Rails controller
|
189
|
+
or Sinatra app environment, params will be defined mo = OpenMarket::MO.new(params[''xml''])
|
190
|
+
puts mo.inspect # Do something with the MO... # Just send a HTTP 200 render nothing:
|
191
|
+
true # Rails return [200] # Sinatra ``` ### Processing DR''s ```ruby require ''openmarket/dr''
|
192
|
+
# In a Rails controller or Sinatra app environment, params will be defined dr =
|
193
|
+
OpenMarket::DR.new(params[''xml'']) puts dr.inspect # Do something with the DR... #
|
194
|
+
Just send a HTTP 200 render nothing: true # Rails return [200] # Sinatra ``` ##
|
195
|
+
Contributing 1. Fork it ( https://github.com/betesh/open_market/fork ) 2. Create
|
196
|
+
your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git
|
197
|
+
commit -am ''Add some feature''`) 4. Push to the branch (`git push origin my-new-feature`)
|
198
|
+
5. Create a new Pull Request'
|
302
199
|
test_files:
|
303
200
|
- spec/api_spec.rb
|
304
201
|
- spec/configuration_spec.rb
|