TheThingsArchive / python-app-sdk

The Things Network Application SDK for Python
MIT License
29 stars 16 forks source link

Device field names camel-cased in code but underscore-separated in docs #31

Closed jamespstrachan closed 2 years ago

jamespstrachan commented 5 years ago

The fields required for registering a new device are described in the documentation underscore separated, eg: app_eui

https://github.com/TheThingsNetwork/python-app-sdk/blob/master/DOCUMENTATION.md#device-1

The code appears to be expecting camel-cased fieldnames, eg: appEui, and this is consistent with the stub data provided for tests.

https://github.com/TheThingsNetwork/python-app-sdk/blob/master/ttn/application.py#L222

Should the docs be updated to make this consistent?

johanstokking commented 5 years ago

Indeed I guess the documentation is wrong about this. Can you provide a PR?

jamespstrachan commented 5 years ago

Sure, can submit PR, just to check before I do:

The devices section in the docs correctly describes the payload received from TTN when listing devices, in which field names are _underscoreseparated. Perhaps instead of modifying the docs to use camelCase it would be better to update the code to use underscore_separation, making docs, request and response payloads consistent.

Thoughts?

*edit: in fact is there any reason to make the payload passed to register_device() any different from the on received by devices()? Pretty much all of the fields you get back from TTN can be set at registration and it would keep the object format symmetrical.

johanstokking commented 5 years ago

Yes, good point. I'm myself not familiar enough with Python to comment on this. I'm in general very much in favor of consistency. I don't know the reason for appEui instead of app_eui; the latter is definitely more consistent with what goes over the line.

ccall48 commented 5 years ago

Any chance of adding some example code of getting this to work? I seem to be going around in circles with the API documentation of using it, even with correct parameters I seem to get timeout issues - most likely because I'm not calling properly...

htdvisser commented 2 years ago

With The Things Network V2 shut down, we're going to archive this repository. This issue will be locked.