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

feat: add emergency get requests #1

Merged
merged 6 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
32 changes: 32 additions & 0 deletions src/InboundGarminWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { request } from './request';
import type {
BaseGetOpts,
DevicesKey,
EmergencyState,
History,
HistoryItems,
Interval,
IPCUserCredentials,
LastKnownLocation,
LocationRequest,
LocationsKey,
Respondent,
Tracking,
Version,
} from './types';
Expand Down Expand Up @@ -127,4 +129,34 @@ export class InboundGarminWrapper {
const opts = Object.assign(this.baseGetOpts, options);
return await request<Version>(`https://${this.IPCUrl}/IPCInbound/V1/Location.svc/Version`, opts);
}

/**
* @see https://explore.garmin.com/IPCInbound/docs/#!/Emergency.svc/GetEmergencyRespondentGET
*
* @param options
*/
public async getEmergencyRespondent(options: RequestInit = {}) {
const opts = Object.assign(this.baseGetOpts, options);
return await request<Respondent>(`https://${this.IPCUrl}/IPCInbound/V1/Emergency.svc/Respondent`, opts);
}

/**
* @see https://explore.garmin.com/IPCInbound/docs/#!/Emergency.svc/StateGET
*
* @params options
*/
public async getEmergencyState(options: RequestInit = {}) {
const opts = Object.assign(this.baseGetOpts, options);
return await request<DevicesKey<EmergencyState>>(`https://${this.IPCUrl}/IPCInbound/V1/Emergency.svc/State`, opts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emergency state requires a query param for IMEI. See docs.

}

/**
* @see https://explore.garmin.com/IPCInbound/docs/#!/Emergency.svc/VersionGET
*
* @params options
*/
public async getEmergencyVersion(options: RequestInit = {}) {
const opts = Object.assign(this.baseGetOpts, options);
return await request<Version>(`https://${this.IPCUrl}/IPCInbound/V1/Emergency.svc/Version`, opts);
}
}
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ export type LocationRequest = {
StartDate: string;
ExpirationDate: string;
};

export type Respondent = {
Respondent: string;
};

export type EmergencyState = {
IMEI: number;
State: string;
};
Loading