@@ -136,11 +136,18 @@ func (d *DevicesService) ListAll() ([]DeviceDetail, error) {
136136}
137137
138138// GetByID retrieves a specific device by its ID.
139- func (d * DevicesService ) GetByID (deviceID string ) (* DeviceDetail , error ) {
139+ // userID is sent as the required ?userId= query parameter.
140+ func (d * DevicesService ) GetByID (userID , deviceID string ) (* DeviceDetail , error ) {
141+ if err := validateID (userID ); err != nil {
142+ return nil , err
143+ }
140144 if err := validateID (deviceID ); err != nil {
141145 return nil , err
142146 }
143- endpoint := buildURL (d .client .GetV1Url (), "devices" , deviceID )
147+
148+ params := url.Values {}
149+ params .Set ("userId" , userID )
150+ endpoint := fmt .Sprintf ("%s?%s" , buildURL (d .client .GetV1Url (), "devices" , deviceID ), params .Encode ())
144151 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
145152 if err != nil {
146153 return nil , err
@@ -161,7 +168,11 @@ func (d *DevicesService) GetByID(deviceID string) (*DeviceDetail, error) {
161168}
162169
163170// Update updates an existing device by its ID.
164- func (d * DevicesService ) Update (deviceID string , updateRequest DeviceUpdateRequest ) (* DeviceDetail , error ) {
171+ // userID is sent as the required ?userId= query parameter.
172+ func (d * DevicesService ) Update (userID , deviceID string , updateRequest DeviceUpdateRequest ) (* DeviceDetail , error ) {
173+ if err := validateID (userID ); err != nil {
174+ return nil , err
175+ }
165176 if err := validateID (deviceID ); err != nil {
166177 return nil , err
167178 }
@@ -170,8 +181,10 @@ func (d *DevicesService) Update(deviceID string, updateRequest DeviceUpdateReque
170181 return nil , err
171182 }
172183
173- endpoint := buildURL (d .client .GetV1Url (), "devices" , deviceID )
174- req , err := http .NewRequest (http .MethodPost , endpoint , bytes .NewBuffer (requestJSON ))
184+ params := url.Values {}
185+ params .Set ("userId" , userID )
186+ endpoint := fmt .Sprintf ("%s?%s" , buildURL (d .client .GetV1Url (), "devices" , deviceID ), params .Encode ())
187+ req , err := http .NewRequest (http .MethodPut , endpoint , bytes .NewBuffer (requestJSON ))
175188 if err != nil {
176189 return nil , err
177190 }
@@ -219,22 +232,6 @@ func (d *DevicesService) ListByUserID(userID string) ([]DeviceDetail, error) {
219232 return allDevices , nil
220233}
221234
222- // UpdateName updates the name of a device.
223- func (d * DevicesService ) UpdateName (deviceID string , name string ) (* DeviceDetail , error ) {
224- updateRequest := DeviceUpdateRequest {
225- Name : name ,
226- }
227- return d .Update (deviceID , updateRequest )
228- }
229-
230- // UpdateDescription updates the description of a device.
231- func (d * DevicesService ) UpdateDescription (deviceID string , description string ) (* DeviceDetail , error ) {
232- updateRequest := DeviceUpdateRequest {
233- Description : description ,
234- }
235- return d .Update (deviceID , updateRequest )
236- }
237-
238235// Create creates a new device for the given user.
239236// userID is sent as the required ?userId= query parameter.
240237func (d * DevicesService ) Create (userID string , req DeviceCreateRequest ) (* DeviceDetail , error ) {
0 commit comments