UNPKG

@bit-ui-libs/common

Version:
55 lines (46 loc) 1.8 kB
import { BaseService, BaseServiceOptions } from '../api/services/base-service'; import { UpdateLocationPrivacyRequest } from '../asset'; import { PagedRequest, PagedResponse, UpdateAttachmentResponse, ViewAttachmentResponse, createQueryParams, } from '../common'; import { CreateCheckInEventRequest, GetCheckInEventsRequest, UpdateCheckInAttachmentRequest, } from './check-in-service.interfaces'; import { CheckInEvent } from './interfaces'; export class CheckInService extends BaseService { checkinApiUrl: string; constructor(opts: BaseServiceOptions) { super(opts); this.checkinApiUrl = `${this.coreApiUrl}/v1/checkin`; } createCheckIn(req: CreateCheckInEventRequest) { return this.post<CheckInEvent, CreateCheckInEventRequest>(this.checkinApiUrl, req); } getEvent(eventId: string) { return this.get<CheckInEvent>(`${this.checkinApiUrl}/${eventId}`); } getCheckInEvents(req?: PagedRequest<GetCheckInEventsRequest>) { return this.get<PagedResponse<CheckInEvent>, PagedRequest<GetCheckInEventsRequest>>( this.checkinApiUrl + `?${createQueryParams(req)}` ); } updateAttachment(req: UpdateCheckInAttachmentRequest) { return this.put<UpdateAttachmentResponse, UpdateCheckInAttachmentRequest>( `${this.checkinApiUrl}/${req.eventId}/attachments`, req ); } getAttachmentImage(attId: string, thumb?: boolean) { const query = createQueryParams({ id: attId, thumb: thumb ? 'true' : undefined }); return this.get<ViewAttachmentResponse, { path: string }>(`${this.checkinApiUrl}/attachments/view?${query}`); } updateLocationPrivacy(eventId: string, req: UpdateLocationPrivacyRequest) { return this.patch<void, UpdateLocationPrivacyRequest>(`${this.checkinApiUrl}/${eventId}/privacy`, req); } }