Skip to content

Commit

Permalink
Merge pull request #69 from apptreesoftware/eyu_0816
Browse files Browse the repository at this point in the history
Add more api for Labor and Inspection
  • Loading branch information
alexisandreason committed Sep 8, 2023
2 parents 412e4f2 + f777949 commit 161415c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 7 deletions.
30 changes: 30 additions & 0 deletions famis_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import {
UdfField,
UnitOfMeasure,
UserActivityGroupAssociations,
UserInspectionClassAssoc,
UserPropertyAssociation,
UserRegionAssociation,
UserType,
Expand All @@ -90,10 +91,12 @@ import * as AxiosLogger from 'axios-logger';
import { Result } from './model/common';
import {
AssetCreateRequest,
AssetUpdateRequest,
CreateCompanyRequest,
CreateInspectionAttachment,
FamisOAuthCredential,
InspectionTransactionRequest,
LaborEntryApprovalRequest,
LoginResponse,
PatchCompanyRequest,
PatchSpaceAreaRequest,
Expand Down Expand Up @@ -347,6 +350,12 @@ export class FamisClient {
return this.createObject<AssetCreateRequest, Asset>(asset, 'assets');
}

async updateAsset(id: number, asset: AssetUpdateRequest) {
return this.patchObject<AssetUpdateRequest, Asset>(asset, 'assets', id.toString());
}

// This call should not work. But not sure why it here
// Left it here, Just in case it used by any
async patchAsset(asset: Asset): Promise<Asset> {
return this.patchObject<Asset, Asset>(asset, 'assets', asset.Id.toString());
}
Expand Down Expand Up @@ -996,6 +1005,10 @@ export class FamisClient {
return this.getAll<InspectionClass>(context, 'inspectionclasses');
}

async getUserInspectionClassAssocs(context: QueryContext): Promise<Result<UserInspectionClassAssoc>> {
return this.getAll<UserInspectionClassAssoc>(context, 'userinspectionclassassociations');
}

async createInspectionTransaction(request: InspectionTransactionRequest): Promise<Inspection> {
return this.createObject<InspectionTransactionRequest, Inspection>(request, 'inspectiontransactions');
}
Expand Down Expand Up @@ -1095,6 +1108,23 @@ export class FamisClient {
return this.patchObject<PostLaborEntryRequest, LaborEntry>(patchRequest, 'laborentries', laborId);
}

async submitLaborEntry(postRequest: LaborEntryApprovalRequest, userId: number): Promise<LaborEntry> {
const entity = `users(${userId})/SubmitTimeCard`;
return this.createObject<LaborEntryApprovalRequest, LaborEntry>(postRequest, entity);
}

async rejectLaborEntry(postRequest: LaborEntryApprovalRequest, userId: number): Promise<LaborEntry> {
const entity = `users(${userId})/RejectTimeCard`;
return this.createObject<LaborEntryApprovalRequest, LaborEntry>(postRequest, entity);
}

async approveLaborEntry(postRequest: LaborEntryApprovalRequest, userId: number): Promise<LaborEntry> {
const entity = `users(${userId})/ApproveTimeCard`;
return this.createObject<LaborEntryApprovalRequest, LaborEntry>(postRequest, entity);
}

//LaborEntryApprovalRequest

//#endregion

//#region materialcosts
Expand Down
20 changes: 16 additions & 4 deletions model/famis_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,18 @@ export interface InspectionClass {
RequestSubTypeExternalId: string;
}

export interface UserInspectionClassAssoc {
Id: number;
EmployeeId: number;
InspectionClassId: number;
InspectionTypeId: number;
DefaultFlag: boolean;
TabOrder: number;
UpdateDate: Date;
UpdatedbyId: number;
UpdatedByExternalId: string;
}

export interface InspectionType {
Id: number;
Description: string;
Expand Down Expand Up @@ -1247,14 +1259,14 @@ export interface Asset {
WarrantyContractNumber?: string;
WarrantyEffectiveDate?: Date;
WarrantyExpirationDate?: Date;
WarrantyExpirationContact?: number;
WarrantyExpirationContact?: string;
WarrantyExpirationContactPhone?: string;
WarrantyVendorId?: number;
WarrantyPoNumberId?: number;
MaintenanceContractNumber?: number;
MaintenanceContractNumber?: string;
MaintenanceContractVendorId?: number;
MaintenanceContractExpirationDate?: Date;
MaintenanceContractNotificationDays?: string;
MaintenanceContractNotificationDays?: number;
PurchaseDate?: Date;
PurchaseAmount?: number;
ExternalCostCenterId?: number;
Expand Down Expand Up @@ -2049,7 +2061,7 @@ export interface LaborEntry {
RequestExternalId: string;
UserId: number;
UserExternalId: string;
EntryDate: string;
EntryDate: Date;
PayPeriodId: number;
PayYear: number;
CrewId: number;
Expand Down
52 changes: 50 additions & 2 deletions model/request_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface LoginResponse {
Message: string;
}

//Region Asset
export interface AssetCreateRequest {
Name: string;
Description: string;
Expand All @@ -56,6 +57,49 @@ export interface AssetCreateRequest {
FloorExternalId: string;
}

export interface AssetUpdateRequest {
Name: string;
Description: string;
AssetNumber: string;
SerialNumber: string;
AssetClassId: number;
AssetRankId: number;
EcriCodeId: number;
MakeId: number;
ModelId: number;
InServiceDate: Date;
AssetStatusId: number;
StatusComment: string;
BarcodeNumber: string;
AssetSafetyComments: string;
AssetKeywordId: number;
AssetTypeId: number;
RiskAssessment: string;
SpaceId: number;
EmployeeId: number;
Room: string;
QuantityAvailable: number;
Comments: string;
ActiveFlag: boolean;
FloorId: number;
WarrantyContractNumber: string;
WarrantyEffectiveDate: Date;
WarrantyExpirationDate: Date;
WarrantyExpirationContact: string;
WarrantyExpirationContactPhone: string;
WarrantyVendorId: number;
WarrantyPoNumberId: number;
MaintenanceContractNumber: string;
MaintenanceContractVendorId: number;
MaintenanceContractExpirationDate: Date;
MaintenanceContractNotificationDays: number;
UomId: number;
FcaRankId: number;
}


//End Region Asset

export interface CreateCompanyRequest {
Name: string;
Addr1: string;
Expand Down Expand Up @@ -712,7 +756,7 @@ export interface PostLaborEntryRequest {
RequestExternalId?: string;
UserId?: number;
UserExternalId?: string;
EntryDate?: string;
EntryDate?: Date;
CrewId?: number;
CrewExternalId?: string;
StartTime?: Date;
Expand All @@ -722,6 +766,11 @@ export interface PostLaborEntryRequest {
LaborReasonId?: number;
}

export interface LaborEntryApprovalRequest {
LaborEntryIds: number[];
LaborEntryComment?: string;
}

export interface PostOtherCostRequest {
OtherCostTypeId?: number;
OtherCostType?: OtherCostType;
Expand Down Expand Up @@ -830,5 +879,4 @@ export interface CreateInspectionAttachment {
Description: string;
}


//End Region Inspection
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "facility360",
"version": "1.0.6",
"version": "1.0.7",
"description": "A Node based 360Facility client SDK",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 161415c

Please sign in to comment.