OpenBankProject / OBPKit-iOSX

Ease access to servers offering the Open Bank Project API. OBPKit is quick to integrate into your iOS app or OSX application, and makes authorisation of sessions and marshalling of resources through the Open Bank Project API simple and easy.
MIT License
11 stars 12 forks source link

Expected to resource at path my/accounts to yield a NSDictionary, but got instead got ... #1

Open 0xTomTom opened 7 years ago

0xTomTom commented 7 years ago

When performing a default OBPMarshal request with getResourceAtAPIPath to "my/accounts", the HandleOBPMarshalError is called with the following:

Expected to resource at path my/accounts to yield a NSDictionary, but got instead got:
(
        {
        "account_routing" =         {
            address = 1233;
            scheme = OBP;
        };
        "bank_id" = rbs;
        id = 1233;
        label = "<null>";
    }
)
from body: [{"id":"1233","label":null,"bank_id":"rbs","account_routing":{"scheme":"OBP","address":"1233"}}]

The response seems valid and expected, but isn't usable as the MarshalError is called in stead of HandleOBPMarshalData

I've used the following: let serverBase = "https://apisandbox.openbankproject.com/obp/v3.0.0/" session.marshal.getResourceAtAPIPath("my/accounts", withOptions: nil, forResultHandler: resultHandler, orErrorHandler: errorHandler)

t0rst commented 7 years ago

Hi Tom,

You can easily tell OBPMarshal to expect a different container type (or no container type) using the OBPMarshalOptionExpectClass options key:

session.marshal.getResourceAtAPIPath("my/accounts", 
    withOptions: [ OBPMarshalOptionExpectClass : NSArray.self ], 
    forResultHandler: resultHandler, orErrorHandler: errorHandler)

...and there are more options for handling unusual cases here: https://github.com/OpenBankProject/OBPKit-iOSX#customising-obpmarshal-behaviour

If you find more uncatered-for edge cases, let me know. 😊