Permalink
Browse files

Return the result code and message.

  • Loading branch information...
1 parent f3b2cf0 commit ae77249f85f0ecf22348b14a86858f3c03eb1302 @alloy alloy committed Jul 30, 2010
Showing with 17 additions and 1 deletion.
  1. +1 −0 TODO
  2. +8 −0 lib/mollie/sms.rb
  3. +8 −1 spec/sms_spec.rb
View
1 TODO
@@ -1 +1,2 @@
* do we need the charged amount after each sms?
+* use HTTPS?
View
@@ -62,6 +62,14 @@ def params
@params ||= Hash.from_xml(@http_response.read_body)['response']['item']
end
+ def result_code
+ params['resultcode'].to_i
+ end
+
+ def message
+ params['resultmessage']
+ end
+
def success?
@http_response.is_a?(Net::HTTPSuccess) && params['success'] == 'true'
end
View
@@ -153,8 +153,15 @@ class ResponseStub
it "returns whether or not it was a success" do
@response.should.be.success
- @response.stubs(:params).returns('resultcode' => '20', 'success' => 'false')
+ @response.stubs(:params).returns('success' => 'false')
@response.should.not.be.success
end
+ it "returns the result code" do
+ @response.result_code.should == 10
+ end
+
+ it "returns the message corresponding to the result code" do
+ @response.message.should == "Message successfully sent."
+ end
end

0 comments on commit ae77249

Please sign in to comment.