big update
This commit is contained in:
22
Snapshot.go
22
Snapshot.go
@@ -7,11 +7,19 @@ import (
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type SnapshotPayload struct {
|
||||
Snapshots []*SnapshotRecord `json:"snapshots"`
|
||||
type UnixSnapshotPayload struct {
|
||||
Snapshots []*UnixSnapshotRecord `json:"snapshots"`
|
||||
}
|
||||
|
||||
type SnapshotRecord struct {
|
||||
type DatetimeSnapshotPayload struct {
|
||||
Snapshots []*DatetimeSnapshotRecord `json:"snapshots"`
|
||||
}
|
||||
|
||||
type UnixSnapshotRecord struct {
|
||||
|
||||
}
|
||||
|
||||
type DatetimeSnapshotRecord struct {
|
||||
Id int `json:"id"`
|
||||
JsonSnapshotSubmission
|
||||
}
|
||||
@@ -30,8 +38,8 @@ type SnapshotSubmission struct {
|
||||
Co2 interface{}
|
||||
}
|
||||
|
||||
func createSnapshotSubFromJsonBodyStream(jsonBodyStream io.ReadCloser) (*SnapshotSubmission, error) {
|
||||
var snapshotSub SnapshotSubmission
|
||||
func createSnapshotSubFromJsonBodyStream(jsonBodyStream io.ReadCloser) (*JsonSnapshotSubmission, error) {
|
||||
var snapshotSub JsonSnapshotSubmission
|
||||
body, err := ioutil.ReadAll(jsonBodyStream)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading body stream: %w", err)
|
||||
@@ -47,8 +55,8 @@ func createSnapshotSubFromJsonBodyStream(jsonBodyStream io.ReadCloser) (*Snapsho
|
||||
return &snapshotSub, nil
|
||||
}
|
||||
|
||||
func createJsonFromSnapshotRecords(records []*SnapshotRecord) ([]byte, error) {
|
||||
jsonResult, err := json.Marshal(SnapshotPayload{records})
|
||||
func createJsonFromSnapshotRecords(records []*DatetimeSnapshotRecord) ([]byte, error) {
|
||||
jsonResult, err := json.Marshal(DatetimeSnapshotPayload{records})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't marshal json: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user