Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added conditions support #3

Merged
merged 2 commits into from
Jul 25, 2024
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weather-plus",
"version": "0.0.15",
"version": "0.0.16",
"description": "Weather Plus is a powerful wrapper around various Weather APIs that simplifies adding weather data to your application",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/weatherPlus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('WeatherPlus Library', () => {
unitCode: "wmoUnit:degC",
qualityControl: "V",
},
textDescription: "Sunny",
}
},
]
Expand All @@ -112,6 +113,10 @@ describe('WeatherPlus Library', () => {
value: 20,
unit: 'C',
},
conditions: {
value: 'Sunny',
unit: 'string',
}
}
expect(response).toEqual(expectedResponse);
});
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface IWeatherData {
dewPoint: IDewPoint;
humidity: IRelativeHumidity;
temperature: ITemperature;
conditions: IConditions;
}

export interface ITemperature {
Expand All @@ -17,4 +18,9 @@ export interface IRelativeHumidity {
export interface IDewPoint {
value: number;
unit: 'C' | 'F';
}

export interface IConditions {
value: string;
unit: 'string';
}
5 changes: 5 additions & 0 deletions src/providers/nws/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('convertToWeatherData', () => {
dewpoint: { value: 20, unitCode: "wmoUnit:degC" },
temperature: { value: 20, unitCode: "wmoUnit:degC" },
relativeHumidity: { value: 50, unitCode: "wmoUnit:percent" },
textDescription: "Sunny",
},
};

Expand All @@ -111,6 +112,10 @@ describe('convertToWeatherData', () => {
value: 20,
unit: 'C',
},
conditions: {
value: 'Sunny',
unit: 'string',
},
};

const result = convertToWeatherData(observation);
Expand Down
4 changes: 4 additions & 0 deletions src/providers/nws/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ export function convertToWeatherData(observation: any): IWeatherData {
value: properties.temperature.value,
unit: properties.temperature.unitCode === 'wmoUnit:degC' ? 'C' : 'F',
},
conditions: {
value: properties.textDescription,
unit: 'string',
}
};
}
Loading