Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ test and release checks. No API token, live backend or sibling checkout is neede
header names case-insensitively; additional transport headers are allowed.
Query key order and JSON object key order are irrelevant; extra query/body
fields and duplicate query keys are not allowed.
- Meter-reading CSV exports default to `semicolon`. Explicit `comma`, `semicolon`
and `tab` selections override the default.
- `response` is the local server's synthetic HTTP response. Bodies use exactly
one of `json`, UTF-8 `text`, or `base64`; `{}` means no body. A `json: null`
body is distinct from no body. Base64 preserves exact CSV bytes, including BOM
Expand Down
4 changes: 2 additions & 2 deletions contracts/cases/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"body": {
"json": {
"includeHeader": true,
"delimiter": "comma",
"delimiter": "semicolon",
"dateFormat": "iso",
"columns": [
"date",
Expand Down Expand Up @@ -1285,7 +1285,7 @@
"body": {
"json": {
"includeHeader": true,
"delimiter": "comma",
"delimiter": "semicolon",
"dateFormat": "iso",
"columns": [
"date",
Expand Down
104 changes: 100 additions & 4 deletions contracts/cases/meter-readings.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
"body": {
"json": {
"includeHeader": true,
"delimiter": "comma",
"delimiter": "semicolon",
"dateFormat": "iso",
"columns": [
"date",
Expand All @@ -367,12 +367,12 @@
"Content-Type": "text/csv; charset=utf-8"
},
"body": {
"base64": "77u/ZGF0ZSx2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaLDEyMy40NQ0K"
"base64": "77u/ZGF0ZTt2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaOzEyMy40NQ0K"
}
},
"expected": {
"result": {
"base64": "77u/ZGF0ZSx2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaLDEyMy40NQ0K"
"base64": "77u/ZGF0ZTt2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaOzEyMy40NQ0K"
}
}
},
Expand Down Expand Up @@ -462,7 +462,7 @@
"body": {
"json": {
"includeHeader": false,
"delimiter": "comma",
"delimiter": "semicolon",
"dateFormat": "iso",
"columns": [
"value"
Expand All @@ -484,6 +484,102 @@
"base64": "MTIz"
}
}
},
{
"id": "readings-export-explicit-comma",
"operation": "meterReadings.export",
"input": {
"deviceId": "11111111-1111-4111-8111-111111111111",
"config": {
"columns": [
"date",
"value"
],
"delimiter": "comma"
}
},
"request": {
"method": "POST",
"path": "/v3/devices/standard/11111111-1111-4111-8111-111111111111/meter-readings/export",
"query": {},
"headers": {
"Authorization": "Bearer contract-test-token",
"Content-Type": "application/json"
},
"body": {
"json": {
"includeHeader": true,
"delimiter": "comma",
"dateFormat": "iso",
"columns": [
"date",
"value"
]
}
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "text/csv; charset=utf-8"
},
"body": {
"base64": "77u/ZGF0ZSx2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaLDEyMy40NQ0K"
}
},
"expected": {
"result": {
"base64": "77u/ZGF0ZSx2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaLDEyMy40NQ0K"
}
}
},
{
"id": "readings-export-explicit-tab",
"operation": "meterReadings.export",
"input": {
"deviceId": "11111111-1111-4111-8111-111111111111",
"config": {
"columns": [
"date",
"value"
],
"delimiter": "tab"
}
},
"request": {
"method": "POST",
"path": "/v3/devices/standard/11111111-1111-4111-8111-111111111111/meter-readings/export",
"query": {},
"headers": {
"Authorization": "Bearer contract-test-token",
"Content-Type": "application/json"
},
"body": {
"json": {
"includeHeader": true,
"delimiter": "tab",
"dateFormat": "iso",
"columns": [
"date",
"value"
]
}
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "text/csv; charset=utf-8"
},
"body": {
"base64": "77u/ZGF0ZQl2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaCTEyMy40NQ0K"
}
},
"expected": {
"result": {
"base64": "77u/ZGF0ZQl2YWx1ZQ0KMjAyNi0wOS0wMVQxMDozNDo1Ni4xMjNaCTEyMy40NQ0K"
}
}
}
]
}
8 changes: 4 additions & 4 deletions contracts/source.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"repository": "https://github.com/energy-tracker/api-client-python",
"commit": "2515b00b00bdc61b487ef0c191c13646a6cc91d1",
"commit": "54ff998357ffa7c191f4538b5b3c49308b777d49",
"sha256": {
"README.md": "a88ee2b3e2e64d811a964cdc4a42fb2b7741b10d6d0037be1f60c23ed0a066cd",
"README.md": "985242aa12e06502b0dcbdf75ec3b95c8fd840dee4a1f309620f1b338e64a59a",
"cases/calculations.json": "0065dc017f173c15b21dbc3b40c3e37d1f1ea80b957669ad50df20f9e888efe0",
"cases/devices.json": "7324964ac126b43b1d6070cf685ddae4e5659f6edbc8c934af34a796453bf15b",
"cases/environments.json": "c069c180405e1414029fe496e46f0272242e6f4d421b1754f16e442307f5cdd8",
"cases/errors.json": "8e19323b83432e47d166f1801e4c37f52f21dbe2c8d26b29eb5e8b3e8d458c0d",
"cases/meter-readings.json": "45be9712d29bbcc373fe564f9771cbf7532194e5a2c47d38fc1e5bf234d92a36",
"cases/errors.json": "5bdeeaa2bdfe5b042ef2fa15bc53d06b422547a9a5535c85cc82c09b382fe721",
"cases/meter-readings.json": "f6ab1fd908cdabc69c2238c8c91188e5e862186716cb4bdc63f7f4195ffd115c",
"schema.json": "e91982f7d62a1bae6d48f5c1614fcf1cda9f3e27c32249aee602c2cfa5c9dc2d"
}
}
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const csv = await client.meterReadings.export(
{
columns: [ExportColumn.DATE, ExportColumn.VALUE],
includeHeader: true,
delimiter: 'comma', // Also semicolon, tab
delimiter: 'semicolon', // Default; also comma, tab
dateFormat: 'iso', // Also date_time, unix, unix_ms
},
{ sort: SortDirection.ASC },
Expand Down
1 change: 1 addition & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface TimestampDto {
export interface ExportMeterReadingsDto {
columns: readonly ExportColumn[];
includeHeader?: boolean;
/** Defaults to semicolon; comma and tab can be selected explicitly. */
delimiter?: CsvDelimiter;
dateFormat?: DateFormat;
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/meter-readings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class MeterReadingResource {
const body = {
columns: [...config.columns],
includeHeader: config.includeHeader ?? true,
delimiter: config.delimiter ?? CsvDelimiter.COMMA,
delimiter: config.delimiter ?? CsvDelimiter.SEMICOLON,
dateFormat: config.dateFormat ?? DateFormat.ISO,
};
return this.transport.request(
Expand Down