-
Notifications
You must be signed in to change notification settings - Fork 14
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
Don't send unneeded Product fields to API #75
Conversation
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.
So this is just as optimization, as the api server just ignores those fields. Are there cases when having the extra fields make the payload significantly larger?
internal/connect/product.go
Outdated
Summary string `xml:"summary,attr" json:"-"` | ||
IsBase bool `xml:"isbase,attr" json:"-"` | ||
IsBase bool `xml:"isbase,attr" json:"base"` |
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.
was changing the json tag intentional?
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.
it was but not for this PR :o)
removed.
This is more to match our payloads to API spec and original client than to save bandwidth. |
internal/connect/api.go
Outdated
@@ -75,7 +75,7 @@ func showProduct(productQuery Product) (Product, error) { | |||
func upgradeProduct(product Product) (Service, error) { | |||
// NOTE: this can add some extra attributes to json payload which |
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.
can this comment be removed now?
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.
done
internal/connect/api.go
Outdated
@@ -130,7 +126,7 @@ func activateProduct(product Product, email string) (Service, error) { | |||
func deactivateProduct(product Product) (Service, error) { | |||
// NOTE: this can add some extra attributes to json payload which |
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.
can this comment be removed now?
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.
done
@@ -5,11 +5,17 @@ import ( | |||
"strings" | |||
) | |||
|
|||
// Product represents an installed product or product information from API | |||
type Product struct { | |||
// BasicProduct represents basic information on product, mostly for API requests |
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.
maybe this comment could also mention that BasicProduct is used instead of Product to avoid sending unneeded bool json or something
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.
done
Product structure was split into two parts. BasicProduct with fields needed to identify the product and Product which embeds BasicProduct and adds more fields on top. For API calls which only need the basic fields, BasicProduct part can be used even if Product was passed.
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.
lgtm
We discussed this last week and decided the change is not necessary. Closing. |
Product structure was split into two parts. BasicProduct with fields
needed to identify the product and Product which embeds BasicProduct
and adds more fields on top.
For API calls which only need the basic fields, BasicProduct part can be
used even if Product was passed.