Class: Mollie::Send
- Inherits:
-
Object
- Object
- Mollie::Send
- Defined in:
- lib/mollie.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
Instance Method Summary collapse
- #credits ⇒ Object
-
#initialize(query) ⇒ Send
constructor
A new instance of Send.
- #response ⇒ Object
- #resultcode ⇒ Object
- #send! ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(query) ⇒ Send
Returns a new instance of Send.
55 56 57 |
# File 'lib/mollie.rb', line 55 def initialize(query) @query = query end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
49 50 51 |
# File 'lib/mollie.rb', line 49 def query @query end |
Class Method Details
.send(query) ⇒ Object
51 52 53 |
# File 'lib/mollie.rb', line 51 def self.send(query) new(query).send! end |
Instance Method Details
#credits ⇒ Object
72 73 74 |
# File 'lib/mollie.rb', line 72 def credits $1.to_i if response.body =~ /<credits>(.*)<\/credits>/m end |
#response ⇒ Object
77 78 79 |
# File 'lib/mollie.rb', line 77 def response @response ||= Net::HTTP.get_response(query.request_uri) end |
#resultcode ⇒ Object
68 69 70 |
# File 'lib/mollie.rb', line 68 def resultcode $1.to_i if response.body =~ /<resultcode>(.*)<\/resultcode>/m end |
#send! ⇒ Object
59 60 61 62 |
# File 'lib/mollie.rb', line 59 def send! raise MollieException.new(self) unless success? self end |
#success? ⇒ Boolean
64 65 66 |
# File 'lib/mollie.rb', line 64 def success? resultcode == 10 end |