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

Automatically fill missing fields in incomplete objects #14

Open
Balletie opened this issue Dec 21, 2015 · 2 comments
Open

Automatically fill missing fields in incomplete objects #14

Balletie opened this issue Dec 21, 2015 · 2 comments
Labels

Comments

@Balletie
Copy link
Collaborator

In several parts of the API GitHub responds with incomplete representations when it is part of another response. They probably do this to save bandwidth.

For example, when one gets the JSON representation of an issue, the API responds with a JSON object containing a "user" key which contains an incomplete JSON representation of a user. When parsed into a GHUser, it contains a lot of nil fields.

To resolve this, there needs to be a check against this, and the fields should be filled lazily using the API url of the object itself. That is, in the case of GHUser, it should do something like this when a field is not filled:

fillFields
| updated |
updated := self
    get: self url;
    responseAs: self class.
self mergeFieldsFrom: updated.
@Balletie
Copy link
Collaborator Author

Pull request #22 came with GHObject>>update which updates an object if it is outdated.

Any object that is incomplete does not have an ETag and GHObject>>isOutdated will respond with true.

This is not done lazily, i.e. if one accesses a nil field it will still return nil. One has to explicitly update its contents for it to be filled.

@Balletie
Copy link
Collaborator Author

In the case of a User nested within an Issue, sending update does not yet work as #propagateTo does not yet propagate to nested domain objects (such as a User nested in an Issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant