Skip to content

Commit

Permalink
Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
andresWeitzel committed Nov 11, 2023
1 parent 8801dbe commit d126628
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 121 deletions.
27 changes: 27 additions & 0 deletions src/rate-plans/graphql/examples/createRatePlan.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Create a rate plan
mutation {
createRatePlan(
ratePlanObj:{
name: "IOPA-278",
description: "plan for groupal annual subscriptions, until ten peoples",
versionId: 7822111,
versionPlan: "2.4",
status: "Published",
typePlan: "Annually - Groupal Subscribers",
subscriptionCharge: 1.1,
numberOfTiers: 3,
}
) {
id
name
description
versionId
versionPlan
status
typePlan
subscriptionCharge
numberOfTiers
creationDate
updateDate
}
}
16 changes: 16 additions & 0 deletions src/rate-plans/graphql/examples/getAllRatePlans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Get All Rate Plans
query {
getAllRatePlans(pageNro: 0, pageSize: 100, orderBy: "name", orderAt: "asc") {
id
name
description
versionId
versionPlan
status
typePlan
subscriptionCharge
numberOfTiers
creationDate
updateDate
}
}
16 changes: 16 additions & 0 deletions src/rate-plans/graphql/examples/getByIdRatePlans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# get by id Rate Plan
query {
getByIdRatePlans(inputId: 2) {
id
name
description
versionId
versionPlan
status
typePlan
subscriptionCharge
numberOfTiers
creationDate
updateDate
}
}
25 changes: 25 additions & 0 deletions src/rate-plans/graphql/examples/updateRatePlan.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Update a Rate Plan
mutation {
updateRatePlan(
id : 2,
ratePlanObj:{
name: "IOPA-27822",
description: "plan for groupal annual subscriptions, until ten peoples",
versionId: 7822111,
versionPlan: "2.4",
status: "Published",
typePlan: "Annually - Groupal Subscribers",
subscriptionCharge: 1.1,
numberOfTiers: 3,
}
) {
name
description
versionId
versionPlan
status
typePlan
subscriptionCharge
numberOfTiers
}
}
56 changes: 0 additions & 56 deletions src/rate-plans/graphql/mutations.txt

This file was deleted.

44 changes: 0 additions & 44 deletions src/rate-plans/graphql/queries.txt

This file was deleted.

5 changes: 3 additions & 2 deletions src/rate-plans/resolvers/create.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CreateRatePlansResolver {
constructor(private createPlansService: CreateRatePlansService) {}

/**
* @description function for add a rate plan to database
* @description function for add a rate plan to database
* @param {RatePlansDTO} ratePlanObj RatePlansDTO type
* @returns a response with the rate plan object and status code
*/
Expand All @@ -37,7 +37,8 @@ export class CreateRatePlansResolver {
return await this.createPlansService.create(ratePlanObj);
// --- end with database operations ---
} catch (error) {
msgResponse = 'ERROR in createRatePlan function for CreateRatePlansResolver class';
msgResponse =
'ERROR in createRatePlan function for CreateRatePlansResolver class';
msgLog = msgResponse + `Caused by ${error}`;
console.log(msgLog);
return msgResponse;
Expand Down
6 changes: 3 additions & 3 deletions src/rate-plans/resolvers/get-all.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export class GetAllRatePlansResolver {
);
//--- end with database operations ----
} catch (error) {
msgResponse = 'ERROR in getAllRatePlans function for GetAllRatePlansResolver class';
msgResponse =
'ERROR in getAllRatePlans function for GetAllRatePlansResolver class';
msgLog = msgResponse + `Caused by ${error}`;
console.log(msgLog);
return msgResponse;
}
}

}
}
2 changes: 1 addition & 1 deletion src/rate-plans/resolvers/update.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export class UpdateRatePlansResolver {
return msgResponse;
}
}
}
}
18 changes: 9 additions & 9 deletions src/rate-plans/services/create.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable prettier/prettier */
//External
import { Injectable, Inject } from "@nestjs/common";
import { Repository } from "typeorm";
import { Injectable, Inject } from '@nestjs/common';
import { Repository } from 'typeorm';
//Models
import { RatePlans } from "../models/rate-plans.entity";
import { RatePlansDTO } from "../models/rate-plans.dto";
import { RatePlans } from '../models/rate-plans.entity';
import { RatePlansDTO } from '../models/rate-plans.dto';
//Enums
//Helpers
import { validateObject } from "../helpers/models/validateObject";
import { validateObject } from '../helpers/models/validateObject';
//Const-vars
let checkObj: any;
let newRatePlan: any;
Expand All @@ -21,8 +21,8 @@ let msgLog: string;
@Injectable()
export class CreateRatePlansService {
constructor(
@Inject("RATE_PLANS_REPOSITORY")
private ratePlansRepository: Repository<RatePlans>
@Inject('RATE_PLANS_REPOSITORY')
private ratePlansRepository: Repository<RatePlans>,
) {}

/**
Expand All @@ -45,10 +45,10 @@ export class CreateRatePlansService {

return await this.ratePlansRepository.save(newRatePlan);
} catch (error) {
msgResponse = "ERROR in create function for CreateRatePlansService class";
msgResponse = 'ERROR in create function for CreateRatePlansService class';
msgLog = msgResponse + `Caused by ${error}`;
console.log(msgLog);
return msgResponse;
}
}
}
}
6 changes: 3 additions & 3 deletions src/rate-plans/services/get-all.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class GetAllRatePlansService {
private ratePlansRepository: Repository<RatePlans>,
) {}


/**
* @description Service to get a paginated listing of all rate plans
* @param {number} pageNroParam number type
Expand Down Expand Up @@ -91,10 +90,11 @@ export class GetAllRatePlansService {

return ratePlansList;
} catch (error) {
msgResponse = 'ERROR in get-all function for GetAllRatePlansService class';
msgResponse =
'ERROR in get-all function for GetAllRatePlansService class';
msgLog = msgResponse + `Caused by ${error}`;
console.log(msgLog);
return msgResponse;
}
}
}
}
9 changes: 6 additions & 3 deletions src/rate-plans/services/update.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ export class UpdateRatePlansService {
//-- end with validation object ---

//-- start with database operation ---
updatedRatePlan = await this.ratePlansRepository.update(inputId, ratePlan);
updatedRatePlan = await this.ratePlansRepository.update(
inputId,
ratePlan,
);

if (updatedRatePlan != (null || undefined)) {
if (updatedRatePlan != (null || undefined)) {
return ratePlan;
}

Expand All @@ -59,4 +62,4 @@ export class UpdateRatePlansService {
return msgResponse;
}
}
}
}

0 comments on commit d126628

Please sign in to comment.