kevbite / CompaniesHouse.NET

A simple .NET client wrapper for CompaniesHouse API
MIT License
37 stars 44 forks source link

Deal with null company status when searching for a company #74

Closed kevbite closed 6 years ago

kevbite commented 6 years ago

We seem to be getting null back for some companies within a search, we need to be able to deal with receiving a null value

{
      "company_status": null,
      "matches": {
        "snippet": [],
        "title": [
          10,
          18
        ]
      },
      "kind": "searchresults#company",
      "description_identifier": [
        "registered-externally"
      ],
      "address": {},
      "address_snippet": null,
      "date_of_creation": null,
      "company_type": "charitable-incorporated-organisation",
      "links": {
        "self": "/company/CE006639"
      },
      "description": "CE006639 - Registered externally as ",
      "title": "ARTS FOR BRIGHOUSE",
      "snippet": "",
      "company_number": "CE006639"
    },
darrenc83 commented 6 years ago

Hi Kev, any update on the above, i was going to try catch this particular error and handle it and set company status to none in this instance, however the error is thrown in the json de-serialization so cannot grab it unfortunately


Quick update, i just cloned a copy of the code and fixed this by updating the following in Company.cs file:

from: public CompanyStatus CompanyStatus { get; set; }

to: public CompanyStatus? CompanyStatus { get; set; }

kevbite commented 6 years ago

OK I've fixed it another way so we don't have breaking changes in the Libary API. I'll push it in a moment.

darrenc83 commented 6 years ago

was contemplating doing that but by default if its null it seems to set it to None anyway with the change i made :)

kevbite commented 6 years ago

Should be all fixed now in version 4.0.3

Please check it out, and if you have any other problems just raise another issue.

Thanks.

darrenc83 commented 6 years ago

will do cheers