mirror of
https://github.com/holidayapi/holidayapi-node.git
synced 2025-06-21 04:26:33 +00:00
* feat: pull country or language by code. This differs from the existing `search` functionality in that it allows you to explicitly pull back a single country or language instead of anything that matches (which could result in more items returned than expected). * refactor(types): add new types for the affected endpoints. * docs(readme): update to include examples for new functionality. * test: expand tests to include new parameters. * feat(package): upgrade dependencies to the latest versions. * fix(eslint): adjust configuration based on an updated dependency. * docs(license): bump the year of the license.
89 lines
1.7 KiB
TypeScript
89 lines
1.7 KiB
TypeScript
/**
|
|
* Copyright (c) Gravity Boulevard, LLC
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
export type Endpoint = 'countries' | 'holidays' | 'languages';
|
|
|
|
type Request = {
|
|
format?: 'csv' | 'json' | 'php' | 'tsv' | 'yaml' | 'xml',
|
|
key?: string,
|
|
pretty?: boolean,
|
|
search?: string,
|
|
};
|
|
|
|
export type Requests = CountriesRequest | HolidaysRequest | LanguagesRequest;
|
|
|
|
export type CountriesRequest = Request & {
|
|
country?: string,
|
|
};
|
|
|
|
export type HolidaysRequest = Request & {
|
|
country?: string,
|
|
day?: number,
|
|
language?: string,
|
|
month?: number,
|
|
previous?: boolean,
|
|
public?: boolean,
|
|
subdivisions?: boolean,
|
|
upcoming?: boolean,
|
|
year?: number,
|
|
};
|
|
|
|
export type LanguagesRequest = Request & {
|
|
language?: string,
|
|
};
|
|
|
|
export type Response = {
|
|
requests: {
|
|
available: number,
|
|
resets: Date,
|
|
used: number,
|
|
},
|
|
status: number,
|
|
error?: string,
|
|
};
|
|
|
|
export type Responses = (
|
|
CountriesResponse | HolidaysResponse | LanguagesResponse
|
|
);
|
|
|
|
export type CountriesResponse = Response & {
|
|
countries?: {
|
|
code: string,
|
|
codes: {
|
|
'alpha-2': string,
|
|
'alpha-3': string,
|
|
numeric: string,
|
|
},
|
|
flag: string,
|
|
languages: string[],
|
|
name: string,
|
|
subdivisions: {
|
|
code: string,
|
|
languages: string[],
|
|
name: string,
|
|
}[],
|
|
}[],
|
|
};
|
|
|
|
export type HolidaysResponse = Response & {
|
|
holidays?: {
|
|
country: string,
|
|
date: Date,
|
|
name: string,
|
|
observed: Date,
|
|
public: boolean,
|
|
uuid: string,
|
|
subdivisions?: string[],
|
|
}[],
|
|
};
|
|
|
|
export type LanguagesResponse = Response & {
|
|
languages?: {
|
|
code: string,
|
|
name: string,
|
|
}[],
|
|
};
|