0
0
mirror of https://github.com/mueller-ma/PrepaidBalance.git synced 2024-09-19 16:02:14 +02:00

Parse Sunrise Switzerland (#140)

Fixes #136
This commit is contained in:
mueller-ma 2022-10-02 22:12:14 +02:00 committed by GitHub
parent fab4399221
commit 4ee88a7fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,9 @@ class ResponseParser {
Matcher("Generic PLN", "^(.*?)((\\d)+\\.(\\d){1,2}) PLN(.*?)\$".toRegex()) { groups ->
return@Matcher parseRegexGroupAsDouble(groups, 2)
},
Matcher("Generic CHF", "^(.*?)((\\d)+\\.(\\d){1,2}) CHF(.*?)\$".toRegex()) { groups ->
return@Matcher parseRegexGroupAsDouble(groups, 2)
},
Matcher("Generic", "^(.*?)((\\d)+\\.?(\\d)?(\\d)?)(.*)\$".toRegex()) { groups ->
return@Matcher parseRegexGroupAsDouble(groups, 2)
},

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Sunrise Switzerland -->
<string name="ussd_code_default" translatable="false">*121#</string>
</resources>

View File

@ -95,5 +95,11 @@ class ResponseParserTest {
56.78,
ResponseParser.getBalance("Current plan active until 08/10/2022 and will renew for \$12.34. Account Balance \$56.78. Add money by dialing *233 or redeem a refill card.")
)
// Sunrise Switzerland
assertEquals(
12.34,
ResponseParser.getBalance("Ihr Guthaben beträgt CHF 12.34")
)
}
}