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

Add SelectionOptions type and refactor GetThermostat to use them #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cvvs
Copy link

@cvvs cvvs commented Apr 21, 2024

I wanted to be able to configure GetThemostat selection data, and you have a TODO to allow for this, so I created a SelectionOption type which can be passed into GetThermostat to set specific selection options when making a request.

I modified the GetThermostat to take the options as a variadic parameter, so the change should be backwards compatible.

Originally, the option funcs were all With<SettingName> but that seemed redundant, so removed the With.

I can undo the formatting changes made by gofmt if you prefer.

Copy link
Owner

@rspier rspier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed review, April and early May were something special...

Anyway, thank you for the PR. A few very minor tweaks if you don't mind...

Originally, the option funcs were all With but that seemed redundant, so removed the With.

I agree the With is providing much value, but the option func pattern generally uses it, so in the name of consistency, maybe add them back? (Or you could probably convince me I'm being silly about that.)

I can undo the formatting changes made by gofmt if you prefer.

Yes please. I'm not opposed to the changes, but let's make them outside the scope of this PR. Also, what version of gofmt are you using? 1.22 isn't making those changes for me.

@@ -82,6 +81,11 @@ func (c *Client) GetThermostat(thermostatID string) (*Thermostat, error) {
IncludeSensors: true,
IncludeWeather: false,
}

for _, optfn := range opts {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just o is ok here. Or opt if you'd prefer. The scope is one line, there won't be any confusion.

I try to follow the Google Go style guide

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

Successfully merging this pull request may close these issues.

None yet

2 participants