Skip to content

Commit

Permalink
set include url param
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetancollaud committed Dec 19, 2023
1 parent a4f8a9a commit f6cd854
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/api/apartment.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @no-cookie-jar
GET {{host}}/api/v1/apartment
GET {{host}}/api/v1/apartment?include=installation,dsDevices,submodules,functionBlocks,zones,clusters,applications,dsServer,controllers,apiRevision,meterings
Authorization: Bearer {{api-key}}

###
Expand Down
12 changes: 3 additions & 9 deletions pkg/digitalstrom/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@ type ApartmentAttributes struct {
}

type ApartmentIncluded struct {
// Before mapping this, you need to add the "include" in the query
Installation Installation `mapstructure:"installation"`
Devices []Device `mapstructure:"dsDevices"`
Submodules []Submodule `mapstructure:"submodules"`
FunctionBlocks []FunctionBlock `mapstructure:"functionBlocks"`
Zones []Zone `mapstructure:"zones"`
//Scenarios []Scenarios `mapstructure:"scenarios"`
// floors
// clusters
// dsServer
Controllers []Controller `mapstructure:"controllers"`
// apiRevision
Meterings []Metering `mapstructure:"meterings"`
// userDefinedStates
// applications
Controllers []Controller `mapstructure:"controllers"`
Meterings []Metering `mapstructure:"meterings"`
}

type Installation struct {
Expand Down
8 changes: 6 additions & 2 deletions pkg/digitalstrom/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ func (c *client) Disconnect() error {
}

func (c *client) GetApartment() (*Apartment, error) {
response, err := c.getRequest("api/v1/apartment", nil)
params := url.Values{}
params.Set("include", "installation,dsDevices,submodules,functionBlocks,zones,controllers,meterings")
response, err := c.getRequest("api/v1/apartment", params)
return wrapApiResponse[Apartment](response, err)
}

func (c *client) GetApartmentStatus() (*ApartmentStatus, error) {
response, err := c.getRequest("api/v1/apartment/status", nil)
params := url.Values{}
params.Set("include", "dsDevices,zones")
response, err := c.getRequest("api/v1/apartment/status", params)
return wrapApiResponse[ApartmentStatus](response, err)
}

Expand Down

0 comments on commit f6cd854

Please sign in to comment.