MeltwaterArchive/datasift-python

account identity list unexpected data type

sojojo opened this issue · 2 comments

The dictionary that we get from client.account.identity.list() has an updated_at value that is an integer, not a datetime object as would be expected.

    {
        "api_key": "dff990e42c14ef5d5aa280b0e9fea9e2",
        "created_at": "Wed, 13 May 2015 10:46:05 GMT",
        "expires_at": null,
        "id": "5dbb799eea004fcb3e2d999d767e0a20",
        "label": "DataSift",
        "master": true,
        "status": "active",
        "updated_at": 1440604653
    }

Calling the API via curl returns all timestamps as integers; I believe this should be the new standard across all new endpoints that are implemented:

➜  ~  curl -X GET 'https://api.datasift.com/v1.2/account/identity' -H 'Auth: USERNAME:API_KEY' | jq .
{
  "count": 2,
  "page": 1,
  "pages": 1,
  "per_page": 25,
  "identities": [
    {
      "id": "ef554f96b...",
      "label": "...",
      "api_key": "1cefe96f4...",
      "status": "active",
      "master": true,
      "created_at": 1431529262,
      "updated_at": 1431535636,
      "expires_at": null
    },
    {
      "id": "a55677c3f622...",
      "label": "...",
      "api_key": "85fcd26e0...",
      "status": "active",
      "master": false,
      "created_at": 1432230266,
      "updated_at": 1432230266,
      "expires_at": null
    }
  ]
}

I'm not sure why created_at would be returned as a DateTime object

The output mapper determines which fields are converted in to DateTime objects. updated_at has now been added to this file and should be available on the next release.

If you wanted all fields to return as timestamps instead of datetimes you just need to edit the output_mapper.py and rebuild.