Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add examples and disable verify mode for ssl

  • Loading branch information...
commit ad1d3d628c2adb1dcd871b6a9c07c3ab52629e48 1 parent d8ba2d1
@alloy alloy authored
Showing with 48 additions and 3 deletions.
  1. +1 −1  Rakefile
  2. +46 −1 lib/mollie/sms.rb
  3. +1 −1  mollie-sms.gemspec
View
2  Rakefile
@@ -13,7 +13,7 @@ end
task :default => :spec
begin
- require 'yard/rake/yardoc_task'
+ require 'yard'
YARD::Rake::YardocTask.new do |t|
t.options = %w{ --no-private }
end
View
47 lib/mollie/sms.rb
@@ -32,7 +32,49 @@ module Mollie
#
# = Examples
#
- # @todo Add examples!
+ # == Normal usage
+ #
+ # require 'mollie/sms'
+ #
+ # sms = Mollie::SMS.new('+31681664814', 'You have won a bowl of chicken noodle soup!')
+ # # => #<Mollie::SMS from: <fngtps.nl> to: <+31681664814> body: "You have won a bowl of chicken noodle soup!">
+ #
+ # response = sms.deliver # => #<Mollie::SMS::Response succeeded (10) `Message successfully sent.'>
+ #
+ # response.success? # => true
+ # response.result_code # => 10
+ # response.message # => "Message successfully sent."
+ #
+ # == Test usage
+ #
+ # require 'mollie/sms/test_helper'
+ #
+ # Mollie::SMS.http_failure!
+ #
+ # response = sms.deliver # => #<Mollie::SMS::Response failed (400) `[HTTP: 400] Bad request'>
+ # response.success? # => false
+ # response.result_code # => 400
+ # response.message # => "[HTTP: 400] Bad request"
+ #
+ # Mollie::SMS.gateway_failure! # => #<Mollie::SMS::Response failed (20) `No username given.'>
+ #
+ # response = sms.deliver # => #<Mollie::SMS::Response failed (20) `No username given.'>
+ # response.success? # => false
+ # response.result_code # => 20
+ # response.message # => "No username given."
+ #
+ # Mollie::SMS.deliveries
+ # # => [#<Mollie::SMS from: <fngtps.nl> to: <+31681664814> body: "You have won a bowl of chicken noodle soup!">,
+ # # #<Mollie::SMS from: <fngtps.nl> to: <+31681664814> body: "You have won a bowl of chicken noodle soup!">]
+ #
+ # = Rails
+ #
+ # If you are using Rails and load the Mollie::SMS gem, it will automatically
+ # require the test helper in test mode.
+ #
+ # It also requires the test helper in development mode, so no actual SMS
+ # messages can be send. Instead, the messages are logged to the
+ # development.log.
#
class SMS
# A collection of exception classes raised by Mollie::SMS.
@@ -67,6 +109,8 @@ def message
end
# The SSL URI to which the parameters of a SMS are posted.
+ #
+ # Note that the certificate is *not* verified.
GATEWAY_URI = URI.parse("https://secure.mollie.nl/xml/sms")
# The possible values that indicate which {SMS.gateway= SMS gateway} should
@@ -238,6 +282,7 @@ def deliver
post.form_data = params
request = Net::HTTP.new(GATEWAY_URI.host, GATEWAY_URI.port)
request.use_ssl = true
+ request.verify_mode = OpenSSL::SSL::VERIFY_NONE
request.start do |http|
response = http.request(post)
Response.new(response)
View
2  mollie-sms.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Eloy Duran"]
- s.date = %q{2010-08-03}
+ s.date = %q{2010-08-06}
s.description = %q{Send SMS text messages via the Mollie.nl SMS gateway.}
s.email = ["eloy@fngtps.com"]
s.extra_rdoc_files = [
Please sign in to comment.
Something went wrong with that request. Please try again.