This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Create UserLite Struct and add CreatedBy field in Device Struct #312
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
12013e4
Create the UserLite struct.
cprivite a7b6595
Add CreatedBy field to the Device struct that uses UserLite.
cprivite 6710c5d
Use href type instead of pulling url into a string.
cprivite 2908145
Remove URL field and improve formatting of *Href line.
cprivite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's embed the
Href
type instead of adding theURL
field. This will allow for common methods for all resources that use the Href pattern. See #269 for more details.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things I'm finding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL field would be removed. The Href embedding will be populated.
In practice we wouldn't access
Href
viau.Href.Href
, we would use the accessor method of theHref
type,GetHref()
. (this method is in the following PR: https://github.com/packethost/packngo/pull/280/files#diff-ebde46360e5c028cc3bde9d49c49bfb6038d13cd340af1d2d61845323ec284fbR59). https://go.dev/doc/effective_go#embedding has some details on the topic.With the
Href
type methods proposed or discussed in that PR (SetHref GetHref), we will be able to fill in some gaps/inconsistencies of the API.An example of these inconsistencies:
When an object returns
{field: {href:"/field/id"}
, we can use?include=field
to return that nested object.However, the object returned in
field
may (or may not, this is inconsistent) omit thehref
field. The experience around.Href
will change based on query parameters. We can heal this with aGetHref
that could rebuild the URL based on the ID. Likewise, we can offer.GetID()
based on the basename of the path in theHref
field when the child object was not?include
'd.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, since I'm assuming we don't want to break User.URL as part of this PR, we'll just do this methodology in UserLite as it's new.