Skip to content

Commit

Permalink
IAM Device: fix meta parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed Sep 13, 2022
1 parent 9b6174b commit 5503654
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 2 additions & 5 deletions iam/devices_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ type Device struct {
GlobalReferenceID string `json:"globalReferenceId" validate:"required,min=3,max=50"`
Text string `json:"text,omitempty"`
ApplicationID string `json:"applicationId" validate:"required"`
Meta struct {
VersionID string `json:"versionId,omitempty"`
LastUpdated *time.Time `json:"lastUpdated,omitempty"`
} `json:"meta,omitempty"`
Meta *Meta `json:"meta,omitempty"`
}

// GetDevicesOptions describes search criteria for looking up devices
Expand Down Expand Up @@ -100,7 +97,7 @@ func (p *DevicesService) GetDeviceByID(deviceID string) (*Device, *Response, err
ID: &deviceID,
})
if devices == nil || len(*devices) == 0 {
return nil, resp, ErrNotFound
return nil, resp, fmt.Errorf("GetDeviceByID: %v %w", err, ErrNotFound)
}
return &(*devices)[0], resp, err
}
Expand Down
15 changes: 8 additions & 7 deletions iam/devices_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ func TestDevicesCRUD(t *testing.T) {
"applicationId": "711171ab-d28c-4616-a314-f95584e280c3",
"deviceExtId": {
"type": {
"code": "ID"
"code": "ID",
"text": "Device Identifier"
},
"system": "http://www.philips.co.id/c-m-ho/fake/fakedevice",
"system": "https://www.philips.co.id/c-m-ho/fake/fakedevice",
"value": "0001"
},
"type": "Device",
"isActive": true,
"globalReferenceId": "c157bd2e-e992-4b5e-88ab-911766b7b8f4",
"id": "`+deviceID+`",
"meta": {
"versionId": "0",
"lastModified": "2020-08-23T20:47:374.040Z"
"versionId": "1",
"lastModified": "2022-09-13T20:35:52Z"
}
}
]
Expand All @@ -63,7 +64,7 @@ func TestDevicesCRUD(t *testing.T) {
"type": {
"code": "ID"
},
"system": "http://www.philips.co.id/c-m-ho/fake/fakedevice",
"system": "https://www.philips.co.id/c-m-ho/fake/fakedevice",
"value": "0001"
},
"type": "Device",
Expand All @@ -72,7 +73,7 @@ func TestDevicesCRUD(t *testing.T) {
"id": "`+deviceID+`",
"meta": {
"versionId": "1",
"lastModified": "2020-08-23T20:47:374.040Z"
"lastModified": "2022-09-13T20:35:52Z"
}
}`)
case "DELETE":
Expand Down Expand Up @@ -102,7 +103,7 @@ func TestDevicesCRUD(t *testing.T) {
Code: "ID",
Text: "Device identification",
},
System: "http://www.philips.co.id/c-m-ho/fake/fakedevice",
System: "https://www.philips.co.id/c-m-ho/fake/fakedevice",
Value: "0001",
},
}
Expand Down
4 changes: 3 additions & 1 deletion iam/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ type OrgAddress struct {
type Meta struct {
ResourceType string `json:"resourceType,omitempty"`
LastModified *time.Time `json:"lastModified,omitempty"`
LastUpdated *time.Time `json:"lastUpdated,omitempty"`
Created *time.Time `json:"created,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
Location string `json:"location,omitempty"`
Version string `json:"version,omitempty"`
Version string `json:"version,omitempty"` // No
VersionID string `json:"versionId,omitempty"` // Consistency
}

type Attribute struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package internal

const (
LibraryVersion = "0.73.3"
LibraryVersion = "0.73.4"
)

0 comments on commit 5503654

Please sign in to comment.