Class: Moiper::Response
- Inherits:
-
Object
- Object
- Moiper::Response
- Defined in:
- lib/moiper/response.rb
Instance Method Summary collapse
-
#checkout_url ⇒ String?
The URL which the user should be redirected to finish payment process or nil if the request was not successfully.
-
#errors ⇒ Array<String>
List the possible errors returned by Moip.
-
#initialize(body) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Detects if the response was successfully.
-
#token ⇒ String
The response token.
Constructor Details
#initialize(body) ⇒ Response
Returns a new instance of Response.
4 5 6 |
# File 'lib/moiper/response.rb', line 4 def initialize(body) @body = body end |
Instance Method Details
#checkout_url ⇒ String?
Returns the URL which the user should be redirected to finish payment process or nil if the request was not successfully.
16 17 18 |
# File 'lib/moiper/response.rb', line 16 def checkout_url Moiper.api_entrypoint + "Instrucao.do?token=" + token if success? end |
#errors ⇒ Array<String>
List the possible errors returned by Moip
27 28 29 |
# File 'lib/moiper/response.rb', line 27 def errors parsed_body.css("Erro").map(&:text) end |
#success? ⇒ Boolean
Detects if the response was successfully
10 11 12 |
# File 'lib/moiper/response.rb', line 10 def success? parsed_body.css("Status").text == "Sucesso" end |
#token ⇒ String
Returns the response token.
21 22 23 |
# File 'lib/moiper/response.rb', line 21 def token parsed_body.css("Token").text end |