Skip to content

Commit

Permalink
Move SMS provider related endpoints to the feature
Browse files Browse the repository at this point in the history
  • Loading branch information
brionmario committed Sep 11, 2024
1 parent 9c44418 commit 7fe5d52
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 19 deletions.
2 changes: 2 additions & 0 deletions features/admin.core.v1/configs/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { getRemoteFetchConfigResourceEndpoints } from "@wso2is/admin.remote-repo
import { getRolesResourceEndpoints } from "@wso2is/admin.roles.v2/configs/endpoints";
import { getSecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/configs/endpoints";
import { getServerConfigurationsResourceEndpoints } from "@wso2is/admin.server-configurations.v1";
import { getSMSProvidersResourceEndpoints } from "@wso2is/admin.sms-providers.v1/configs/endpoints";
import { getExtensionTemplatesEndpoints } from "@wso2is/admin.template-core.v1/configs/endpoints";
import { getTenantResourceEndpoints } from "@wso2is/admin.tenants.v1/configs/endpoints";
import { getUsersResourceEndpoints } from "@wso2is/admin.users.v1/configs/endpoints";
Expand Down Expand Up @@ -266,6 +267,7 @@ export class Config {
...getExtensionTemplatesEndpoints(this.resolveServerHost()),
...getApplicationTemplatesResourcesEndpoints(this.resolveServerHost()),
...getActionsResourceEndpoints(this.resolveServerHost()),
...getSMSProvidersResourceEndpoints(this.resolveServerHost()),
CORSOrigins: `${ this.getDeploymentConfig()?.serverHost }/api/server/v1/cors/origins`,
// TODO: Remove this endpoint and use ID token to get the details
me: `${ this.getDeploymentConfig()?.serverHost }/scim2/Me`,
Expand Down
4 changes: 3 additions & 1 deletion features/admin.core.v1/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { OrganizationResourceEndpointsInterface } from "@wso2is/admin.organizati
import { RolesResourceEndpointsInterface } from "@wso2is/admin.roles.v2/models/endpoints";
import { SecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/models/endpoints";
import { ServerConfigurationsResourceEndpointsInterface } from "@wso2is/admin.server-configurations.v1";
import { SMSProvidersResourceEndpointsInterface } from "@wso2is/admin.sms-providers.v1/models/endpoints";
import { ExtensionTemplatesEndpointsInterface } from "@wso2is/admin.template-core.v1/models/endpoints";
import { TenantResourceEndpointsInterface } from "@wso2is/admin.tenants.v1/models/endpoints";
import { UsersResourceEndpointsInterface } from "@wso2is/admin.users.v1/models/endpoints";
Expand Down Expand Up @@ -541,7 +542,8 @@ export interface ServiceResourceEndpointsInterface extends ClaimResourceEndpoint
ConsoleSettingsResourceEndpointsInterface,
ExtensionTemplatesEndpointsInterface,
ApplicationsTemplatesEndpointsInterface,
ActionsResourceEndpointsInterface {
ActionsResourceEndpointsInterface,
SMSProvidersResourceEndpointsInterface {

CORSOrigins: string;
// TODO: Remove this endpoint and use ID token to get the details
Expand Down
2 changes: 2 additions & 0 deletions features/admin.core.v1/store/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface<
selfSignUp: "",
serverConfigurations: "",
serverSupportedSchemas: "",
smsPublisher: "",
smsSender: "",
tenantAssociationApi: "",
tenantManagementApi: "",
tenantSubscriptionApi: "",
Expand Down
2 changes: 0 additions & 2 deletions features/admin.extensions.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ export const getExtendedFeatureResourceEndpoints = (serverHost: string,
eventsEndpoint: `${ serverHost }/api/event-configurations/v1/events`,
inviteEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users/invite`,
inviteLinkEndpoint: "/api/users/v1/offline-invite-link",
notificationSendersEndPoint: `${ serverHost }/api/server/v1/notification-senders`,
organizationEndpoint: `${ serverHost }/api/asgardeo-enterprise-login/v1/business-user-login/{organization}`,
organizationPatchEndpoint: `${ serverHost }/api/asgardeo-enterprise-login/v1/business-user-login`,
resendEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users/invite/{}/resend`,
smsProviderEndpoint: `${ serverHost }/api/server/v1/notification-senders/sms`,
userEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users`,
userStoreAgentConnection: `${ serverHost }/api/onprem-userstore/v1/connection`,
userStoreAgentToken: `${ serverHost }/api/onprem-userstore/v1/token`
Expand Down
10 changes: 0 additions & 10 deletions features/admin.extensions.v1/configs/models/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ export interface ExtendedFeatureResourceEndpointsInterface {
*/
emailProviderEndpoint : string;

/**
* SMS Publishing API endpoint.
*/
smsProviderEndpoint : string;

/**
* Event Publishing API endpoint.
*/
Expand All @@ -69,11 +64,6 @@ export interface ExtendedFeatureResourceEndpointsInterface {
*/
choreoEventingEndpoint : string;

/**
* Notification senders API endpoint.
*/
notificationSendersEndPoint: string;

/**
* Authorization Service API endpoint.
*/
Expand Down
2 changes: 1 addition & 1 deletion features/admin.sms-providers.v1/api/add-sms-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const addSMSPublisher = (): Promise<NotificationSenderSMSInterface> => {
"Content-Type": "application/json"
},
method: HttpMethods.POST,
url: store.getState().config.endpoints.notificationSendersEndPoint + "/sms"
url: store.getState().config.endpoints.smsSender
};

return httpClient(requestConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const deleteSMSPublisher = (): Promise<void> => {
"Content-Type": "application/json"
},
method: HttpMethods.DELETE,
url: store.getState().config.endpoints.notificationSendersEndPoint + "/sms/SMSPublisher"
url: store.getState().config.endpoints.smsPublisher
};

return httpClient(requestConfig)
Expand Down
8 changes: 4 additions & 4 deletions features/admin.sms-providers.v1/api/sms-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useSMSProviders = <Data = SMSProviderAPIResponseInterface[], Error
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: store.getState().config.endpoints.smsProviderEndpoint
url: store.getState().config.endpoints.smsSender
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(requestConfig);
Expand All @@ -74,7 +74,7 @@ export const createSMSProvider = (
"Content-Type": "application/json"
},
method: HttpMethods.POST,
url: store.getState().config.endpoints.smsProviderEndpoint
url: store.getState().config.endpoints.smsSender
};

return httpClient(requestConfig)
Expand Down Expand Up @@ -113,7 +113,7 @@ export const updateSMSProvider = (
"Content-Type": "application/json"
},
method: HttpMethods.PUT,
url: store.getState().config.endpoints.smsProviderEndpoint + "/SMSPublisher"
url: store.getState().config.endpoints.smsPublisher
};

return httpClient(requestConfig)
Expand Down Expand Up @@ -148,7 +148,7 @@ export const deleteSMSProviders = (): Promise<null | IdentityAppsApiException> =
"Content-Type": "application/json"
},
method: HttpMethods.DELETE,
url: store.getState().config.endpoints.smsProviderEndpoint + "/SMSPublisher"
url: store.getState().config.endpoints.smsPublisher
};

return httpClient(requestConfig)
Expand Down
32 changes: 32 additions & 0 deletions features/admin.sms-providers.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { SMSProvidersResourceEndpointsInterface } from "../models/endpoints";

/**
* Get the resource endpoints for the SMS Providers feature.
*
* @param serverHost - Server Host.
* @returns Endpoint URLs.
*/
export const getSMSProvidersResourceEndpoints = (serverHost: string): SMSProvidersResourceEndpointsInterface => {
return {
smsPublisher: `${ serverHost }/api/server/v1/notification-senders/sms/SMSPublisher`,
smsSender: `${ serverHost }/api/server/v1/notification-senders/sms`
};
};
31 changes: 31 additions & 0 deletions features/admin.sms-providers.v1/models/endpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Interface for the SMS Providers feature resource endpoints.
*/
export interface SMSProvidersResourceEndpointsInterface {
/**
* Endpoint for the SMS Publisher.
*/
smsPublisher: string;
/**
* Endpoint for the SMS Sender.
*/
smsSender: string;
}

0 comments on commit 7fe5d52

Please sign in to comment.