Skip to content
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

NullReferenceException when calling CustomerStatementExport.List #96

Closed
1 task
robinvanpoppel opened this issue May 26, 2018 · 2 comments
Closed
1 task

Comments

@robinvanpoppel
Copy link
Contributor

robinvanpoppel commented May 26, 2018

Steps to reproduce:

  1. Authorize your client.
  2. Get a monetaryAccountId (account.MonetaryAccountBank.Id)
  3. Call CustomerStatementExport.List(accountId.Value)

What should happen:

  1. I should get a list of customer statement exports (or an empty list if none available)

What happens:

  1. A NullReferenceException in
    return json.GetValue(wrapper).ToString();

Traceback

Bunq.Sdk.dll!Bunq.Sdk.Model.Core.BunqModel.GetUnwrappedItemJsonString(Newtonsoft.Json.Linq.JObject json, string wrapper) Line 62
at E:\Git\sdk_csharp\BunqSdk\Model\Core\BunqModel.cs(62)
Bunq.Sdk.dll!Bunq.Sdk.Model.Core.BunqModel.FromJsonList.AnonymousMethod__0(Newtonsoft.Json.Linq.JToken unwrappedItemObject) Line 113
at E:\Git\sdk_csharp\BunqSdk\Model\Core\BunqModel.cs(113)
[External Code]
Bunq.Sdk.dll!Bunq.Sdk.Model.Core.BunqModel.FromJsonList<Bunq.Sdk.Model.Generated.Endpoint.CustomerStatementExport>(Bunq.Sdk.Http.BunqResponseRaw responseRaw, string wrapper) Line 110
at E:\Git\sdk_csharp\BunqSdk\Model\Core\BunqModel.cs(110)
Bunq.Sdk.dll!Bunq.Sdk.Model.Generated.Endpoint.CustomerStatementExport.List(int? monetaryAccountId, System.Collections.Generic.IDictionary<string, string> urlParams, System.Collections.Generic.IDictionary<string, string> customHeaders) Line 164
at E:\Git\sdk_csharp\BunqSdk\Model\Generated\Endpoint\CustomerStatementExport.cs(164)

SDK version and environment

  • Tested on 0.13.0
  • Sandbox
  • [ X] Production

Extra info:

The code at

return FromJsonList<CustomerStatementExport>(responseRaw, OBJECT_TYPE_GET);

is calling into FromJsonList with
private const string OBJECT_TYPE_GET = "CustomerStatementExport";
as a value for wrapper. The API response contains a list of "CustomerStatement" instead of "CustomerStatementExport" which causes GetUnwrappedItemJsonString to crash. Changing CustomerStatementExport.List to use "CustomerStatement" worked for my particular case.

A redacted response from the API, with just one CustomerStatement:


{
  "Response": [
    {
      "CustomerStatement": {
        "id": 123456,
        "created": "2018-05-26T07:55:07.286738",
        "updated": "2018-05-26T07:55:07.286738",
        "date_start": "2018-01-01",
        "date_end": "2018-05-26",
        "status": "COMPLETED",
        "alias_monetary_account": {
          "iban": "Redacted",
          "is_light": false,
          "display_name": "Redacted",
          "avatar": {
            "uuid": "00000000-0000-0000-0000-000000000000",
            "image": [
              {
                "attachment_public_uuid": "00000000-0000-0000-0000-000000000000",
                "height": 1023,
                "width": 1024,
                "content_type": "image/png"
              }
            ],
            "anchor_uuid": null
          },
          "label_user": {
            "uuid": "00000000-0000-0000-0000-000000000000",
            "display_name": "Redacted",
            "country": "NL",
            "avatar": {
              "uuid": "00000000-0000-0000-0000-000000000000",
              "image": [
                {
                  "attachment_public_uuid": "00000000-0000-0000-0000-000000000000",
                  "height": 210,
                  "width": 182,
                  "content_type": "image/jpeg"
                }
              ],
              "anchor_uuid": "00000000-0000-0000-0000-000000000000"
            },
            "public_nick_name": "Redacted"
          },
          "country": "NL"
        },
        "statement_format": "CSV",
        "statement_number": null,
        "regional_format": "EUROPEAN"
      }
    }   
  ],
  "Pagination": {
    "future_url": "/v1/user/123456/monetary-account/654321/customer-statement?newer_id=654321",
    "newer_url": null,
    "older_url": "/v1/user/123456/monetary-account/654321/customer-statement?older_id=123456"
  }
}
@robinvanpoppel robinvanpoppel changed the title NullReferenceException on calling CustomerStatementExport.List NullReferenceException when calling CustomerStatementExport.List May 26, 2018
@OGKevin
Copy link
Contributor

OGKevin commented May 26, 2018

@robinvanpoppel thanks for reporting.

References bunq/sdk_php#146

@OGKevin OGKevin self-assigned this May 26, 2018
@OGKevin OGKevin added this to the 0.13.5 milestone May 26, 2018
@OGKevin
Copy link
Contributor

OGKevin commented Jul 24, 2018

Fixed in #113

@OGKevin OGKevin closed this as completed Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants