-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to supply a country to narrow down timezones
- Loading branch information
1 parent
cdc2f2d
commit 692ff3d
Showing
3 changed files
with
24 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
import { AxiosInstance } from 'axios'; | ||
|
||
import { Resource } from '../index'; | ||
export interface TimezoneResource { | ||
get(country?: string): Promise<any>; | ||
} | ||
|
||
export default class Timezone implements Resource { | ||
export default class Timezone implements TimezoneResource { | ||
protected client: AxiosInstance; | ||
|
||
constructor(client: AxiosInstance) { | ||
this.client = client; | ||
} | ||
|
||
public async get(): Promise<any> { | ||
return await this.client.get('timezones'); | ||
public async get(country?: string): Promise<any> { | ||
let url = 'timezones'; | ||
|
||
if (country) { | ||
url += `/${country}`; | ||
} | ||
|
||
return await this.client.get(url); | ||
} | ||
} |