-
Notifications
You must be signed in to change notification settings - Fork 21
add PaymentRequest#total_payed and PaymentRequest#status #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
c4cbc9f
c4971be
fccd19c
fe8d76c
8c42e5c
2876db9
5d34a62
0c79c5d
5545861
a4bad6b
80e6503
0341af6
34ea2d9
cced22f
cca4657
997bd83
cbf0bda
054b6a1
9639fa7
db1f187
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| module MyMoip | ||
| class ConsultationRequest < Request | ||
|
|
||
| HTTP_METHOD = :get | ||
| PATH = '/ws/alpha/ConsultarInstrucao' | ||
| REQUIRES_AUTH = true | ||
|
|
||
| def api_call(opts = {}) | ||
| params = { | ||
| http_method: HTTP_METHOD, | ||
| requires_auth: REQUIRES_AUTH, | ||
| path: [PATH, id].join('/') | ||
| } | ||
|
|
||
| super(params, opts) | ||
| end | ||
|
|
||
| def xml_str | ||
| @response.body | ||
| end | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at body end. |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,16 @@ class PaymentRequest < Request | |
| REQUIRES_AUTH = false | ||
| FORMAT = :json | ||
| PAYMENT_SLIP_PATH = "/Instrucao.do?token=" | ||
| STATUSES = { | ||
| "Autorizado" => 1, | ||
| "Iniciado" => 2, | ||
| "BoletoImpresso" => 3, | ||
| "Concluido" => 4, | ||
| "Cancelado" => 5, | ||
| "EmAnalise" => 6, | ||
| "Estornado" => 7, | ||
| "Reembolsado" => 9 | ||
| } | ||
|
|
||
| attr_reader :token | ||
|
|
||
|
|
@@ -45,7 +55,19 @@ def url | |
|
|
||
| def code | ||
| @response["CodigoMoIP"] | ||
| rescue NoMethodError => e | ||
| rescue NoMethodError | ||
| nil | ||
| end | ||
|
|
||
| def status | ||
| STATUSES[@response["Status"]] | ||
| rescue NoMethodError | ||
| nil | ||
| end | ||
|
|
||
| def total_payed | ||
| @response["TotalPago"] | ||
| rescue NoMethodError | ||
| nil | ||
| end | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at body end. |
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| require_relative '../test_helper' | ||
|
|
||
| class TestConsultationRequest < Test::Unit::TestCase | ||
| def test_http_method_as_post | ||
| assert_equal :get, MyMoip::ConsultationRequest::HTTP_METHOD | ||
| end | ||
|
|
||
| def test_path | ||
| assert_equal '/ws/alpha/ConsultarInstrucao', MyMoip::ConsultationRequest::PATH | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [82/80] |
||
| end | ||
|
|
||
| def test_auth_requirement | ||
| assert_equal true, MyMoip::ConsultationRequest::REQUIRES_AUTH | ||
| end | ||
|
|
||
| def test_should_provide_the_xml_str_get_by_the_request | ||
| request = MyMoip::ConsultationRequest.new('U260F1E2P0G4N0Z2T1S0M4T3C5E4J5M8L5U0G0I0U0M0H0Y0E3X7S9X6I783') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [109/80] |
||
|
|
||
| VCR.use_cassette('consultation_request') { request.api_call } | ||
|
|
||
| assert_block { request.xml_str.match(/^<ns1:ConsultarTokenResponse/) } | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at body beginning.