8
gitpush
7y

!rant && isSorry = true
this aint StackOverFlow but I need a tiny help here, I'm receiving data result from an API that is formatted as x-www-form-urlencoded, do I add a valid url at the beginning and use URI parser in Android or is there some other solution for it?

Sample of the result I'm receiving:

repositoryId=TEST&response.gatewayCode=BASIC_VERIFICATION_SUCCESSFUL&result=SUCCESS&sourceOfFunds.provided.card.brand=MASTERCARD

Comments
  • 2
  • 1
    Why not just split by & then by = and url decode the fields?
  • 0
    @hash-table unfortunately this is for Java and also for Swift
    I could convert that JavaScript code, but it is not worth the trouble unless there is no solution for it unless I convert it to JSON
  • 1
    @kurtr that's what I'm doing right now, but thought there is a better way. But my concern is I need to add multiple "If/else" to reach what I want, while if it is a "getByName("")" I think would be faster or at least easier to maintain than many ifs
  • 0
    @hash-table That's what I'm thinking of, I don't understand why they'd return such format for a long result, if I split it to lines, it takes 65 lines, think it is easier to handle when in JSON
  • 1
    @gitpush If you can't find a built in function it's better to just cook up your own and wrap it in a small library. Shame man you've been fighting mastercard for a while now! Looking at your excerpts it's safe to say the dev who wrote that "API"-cough might have a teeny meth problem.
  • 0
    @hash-table I've been noticing that lol hope I don't have to work with it again ...
  • 1
    @kurtr The problem with Mastercard is they have either a REST API or an NVP API (Name value pair)
    I've been trying to integrate with the REST API to end up after a month knowing that client requested the NVP approach and the provider didn't tell us that until last week -.-

    What I even don't understand is, I have set Content-Type as JSON in-hope they'd see it and return in the same format, but I guess no. I have no clue why they are returning it like that. Unless I'm missing something in their docs
  • 1
    @gitpush Sadly I haven't done an integration directly with someone like mastercard in around 6 years but honestly thats a fucked up way to return data - especially for a payment provider.
  • 1
    @kurtr true, though they were kind enough to include a dot for example: sourceOfFunds.Type
    instead of
    sourceOfFundsType
  • 0
    @GodHatesMe I was hoping for another because that response is huge for a URL if I split it into lines it takes 65, but I'll give it a go and hope it doesn't crash
  • 1
    @GodHatesMe a clean desktop is more important than a clean room :P
  • 1
    @GodHatesMe take your time my friend I was just joking about the clean desktop thing 😅😀
  • 0
    Build a parser in Python or Node and upload it to a middle server.
  • 1
    @clovisIrex ain't no engineering like over engineering 😂
Add Comment