mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
[EC-376] Extract API logic from PolicyService to PolicyApiService (#3203)
* Added abstractions for PolicyApiService and PolicyService * Added implementations for PolicyApiService and PolicyService * Updated all references to new PolicyApiService and PolicyService * Deleted old PolicyService abstraction and implementation * Fixed CLI import path for policy.service * Fixed main.background.ts policyApiService dependency for policyService * Updated policy-api.service with the correct imports * [EC-376] Sorted methods order in PolicyApiService * [EC-376] Removed unused clearCache method from PolicyService * [EC-376] Added upsert method to PolicyService * [EC-376] PolicyApiService putPolicy method now upserts data to PolicyService
This commit is contained in:
@@ -6,7 +6,6 @@ import { TokenService } from "../abstractions/token.service";
|
||||
import { DeviceType } from "../enums/deviceType";
|
||||
import { OrganizationApiKeyType } from "../enums/organizationApiKeyType";
|
||||
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
|
||||
import { PolicyType } from "../enums/policyType";
|
||||
import { Utils } from "../misc/utils";
|
||||
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
||||
import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
|
||||
@@ -67,7 +66,6 @@ import { OrganizationUserUpdateRequest } from "../models/request/organizationUse
|
||||
import { PasswordHintRequest } from "../models/request/passwordHintRequest";
|
||||
import { PasswordRequest } from "../models/request/passwordRequest";
|
||||
import { PaymentRequest } from "../models/request/paymentRequest";
|
||||
import { PolicyRequest } from "../models/request/policyRequest";
|
||||
import { PreloginRequest } from "../models/request/preloginRequest";
|
||||
import { ProviderAddOrganizationRequest } from "../models/request/provider/providerAddOrganizationRequest";
|
||||
import { ProviderOrganizationCreateRequest } from "../models/request/provider/providerOrganizationCreateRequest";
|
||||
@@ -1024,83 +1022,6 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
);
|
||||
}
|
||||
|
||||
// Policy APIs
|
||||
|
||||
async getPolicy(organizationId: string, type: PolicyType): Promise<PolicyResponse> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/policies/" + type,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new PolicyResponse(r);
|
||||
}
|
||||
|
||||
async getPolicies(organizationId: string): Promise<ListResponse<PolicyResponse>> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/policies",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, PolicyResponse);
|
||||
}
|
||||
|
||||
async getPoliciesByToken(
|
||||
organizationId: string,
|
||||
token: string,
|
||||
email: string,
|
||||
organizationUserId: string
|
||||
): Promise<ListResponse<PolicyResponse>> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" +
|
||||
organizationId +
|
||||
"/policies/token?" +
|
||||
"token=" +
|
||||
encodeURIComponent(token) +
|
||||
"&email=" +
|
||||
encodeURIComponent(email) +
|
||||
"&organizationUserId=" +
|
||||
organizationUserId,
|
||||
null,
|
||||
false,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, PolicyResponse);
|
||||
}
|
||||
|
||||
async getPoliciesByInvitedUser(
|
||||
organizationId: string,
|
||||
userId: string
|
||||
): Promise<ListResponse<PolicyResponse>> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/policies/invited-user?" + "userId=" + userId,
|
||||
null,
|
||||
false,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, PolicyResponse);
|
||||
}
|
||||
|
||||
async putPolicy(
|
||||
organizationId: string,
|
||||
type: PolicyType,
|
||||
request: PolicyRequest
|
||||
): Promise<PolicyResponse> {
|
||||
const r = await this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/policies/" + type,
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new PolicyResponse(r);
|
||||
}
|
||||
|
||||
// Organization User APIs
|
||||
|
||||
async getOrganizationUser(
|
||||
|
||||
Reference in New Issue
Block a user