Skip to content

Commit 551051d

Browse files
author
Lenny Goodell
authored
Merge pull request #756 from hahattan/uom
feat: add UoM api route and response
2 parents 7564b23 + aa36825 commit 551051d

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

common/constants.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2020-2021 IOTech Ltd
2+
// Copyright (C) 2020-2022 IOTech Ltd
33
//
44
// SPDX-License-Identifier: Apache-2.0
55

@@ -100,11 +100,12 @@ const (
100100
ApiTransmissionByStatusRoute = ApiTransmissionRoute + "/" + Status + "/{" + Status + "}"
101101
ApiTransmissionByNotificationIdRoute = ApiTransmissionRoute + "/" + Notification + "/" + Id + "/{" + Id + "}"
102102

103-
ApiConfigRoute = ApiBase + "/config"
104-
ApiMetricsRoute = ApiBase + "/metrics"
105-
ApiPingRoute = ApiBase + "/ping"
106-
ApiVersionRoute = ApiBase + "/version"
107-
ApiSecretRoute = ApiBase + "/secret"
103+
ApiConfigRoute = ApiBase + "/config"
104+
ApiMetricsRoute = ApiBase + "/metrics"
105+
ApiPingRoute = ApiBase + "/ping"
106+
ApiVersionRoute = ApiBase + "/version"
107+
ApiSecretRoute = ApiBase + "/secret"
108+
ApiUnitsOfMeasureRoute = ApiBase + "/uom"
108109

109110
ApiDeviceCallbackRoute = ApiBase + "/callback/device"
110111
ApiDeviceCallbackNameRoute = ApiBase + "/callback/device/name/{name}"
@@ -284,10 +285,12 @@ const (
284285

285286
// Constants related to the possible content types supported by the APIs
286287
const (
288+
Accept = "Accept"
287289
ContentType = "Content-Type"
288290
ContentLength = "Content-Length"
289291
ContentTypeCBOR = "application/cbor"
290292
ContentTypeJSON = "application/json"
293+
ContentTypeTOML = "application/toml"
291294
ContentTypeYAML = "application/x-yaml"
292295
ContentTypeText = "text/plain"
293296
ContentTypeXML = "application/xml"

dtos/responses/uom.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (C) 2022 IOTech Ltd
3+
//
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package responses
7+
8+
import "github.com/edgexfoundry/go-mod-core-contracts/v2/dtos/common"
9+
10+
type UnitsOfMeasureResponse struct {
11+
common.BaseResponse `json:",inline"`
12+
Uom any `json:"uom"`
13+
}
14+
15+
func NewUnitsOfMeasureResponse(requestId string, message string, statusCode int, uom any) UnitsOfMeasureResponse {
16+
return UnitsOfMeasureResponse{
17+
BaseResponse: common.NewBaseResponse(requestId, message, statusCode),
18+
Uom: uom,
19+
}
20+
}

dtos/responses/uom_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Copyright (C) 2022 IOTech Ltd
3+
//
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package responses
7+
8+
import (
9+
"testing"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func TestNewUnitsOfMeasureResponse(t *testing.T) {
15+
expectedRequestId := "d61c96fc-f33d-4294-951e-6c2488b42737"
16+
expectedStatusCode := 200
17+
expectedMessage := "unit test message"
18+
expectedUoM := struct{}{}
19+
actual := NewUnitsOfMeasureResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedUoM)
20+
21+
assert.Equal(t, expectedRequestId, actual.RequestId)
22+
assert.Equal(t, expectedStatusCode, actual.StatusCode)
23+
assert.Equal(t, expectedMessage, actual.Message)
24+
assert.Equal(t, expectedUoM, actual.Uom)
25+
}

0 commit comments

Comments
 (0)