Skip to content

Commit

Permalink
technology routes cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullai-t committed Dec 6, 2023
1 parent a6f8db2 commit 8193cc2
Show file tree
Hide file tree
Showing 6 changed files with 722 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/api/handlers/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def registerRoutes(self):

self.add("/campaigns.technologies.testimonials.create", self.create_campaign_technology_testimonial)
self.add("/campaigns.technologies.testimonials.update", self.update_campaign_technology_testimonial)
self.add("/campaigns.technologies.testimonials.delete", self.delete_campaign_technology_testimonial)

self.add("/campaigns.technologies.comments.create", self.create_campaign_technology_comment)
self.add("/campaigns.technologies.comments.update", self.update_campaign_technology_comment)
Expand Down Expand Up @@ -620,6 +621,22 @@ def add_campaign_technology_view(self, request):
if err:
return err
return MassenergizeResponse(data=res)



def delete_campaign_technology_testimonial(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)
args, err = self.validator.verify(args)
if err:
return err

res, err = self.service.delete_campaign_technology_testimonial(context, args)
if err:
return err
return MassenergizeResponse(data=res)



292 changes: 292 additions & 0 deletions src/api/handlers/technology.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@



from _main_.utils.context import Context
from _main_.utils.massenergize_response import MassenergizeResponse
from _main_.utils.route_handler import RouteHandler
from api.services.technology import TechnologyService


class TechnologyHandler(RouteHandler):
def __init__(self):
super().__init__()
self.service = TechnologyService()
self.registerRoutes()

def registerRoutes(self):
self.add("/technologies.info", self.info)
self.add("/technologies.create", self.create)
self.add("/technologies.list", self.list)
self.add("/technologies.update", self.update)
self.add("/technologies.delete", self.delete)
self.add("/technologies.coaches.add", self.add_coach)
self.add("/technologies.coaches.remove", self.remove_coach)
self.add("/technologies.listForAdmin", self.list_for_admin)
self.add("/technologies.vendors.add", self.add_vendor)
self.add("/technologies.vendors.remove", self.remove_vendor)
self.add("/technologies.vendors.list", self.list_vendors)
self.add("/technologies.overview.create", self.create_overview)
self.add("/technologies.overview.update", self.update_overview)
self.add("/technologies.overview.delete", self.delete_overview)
self.add("/technologies.overview.list", self.list_overviews)



def info(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)
if err:
return err

res, err = self.service.get_technology_info(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def list(self, request):
context: Context = request.context
args: dict = context.args

res, err = self.service.list_technologies(context, args)
if err:
return err
return MassenergizeResponse(data=res)



def create(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("name", str, is_required=True)
self.validator.expect("description", str, is_required=True)
self.validator.expect("image", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.create_technology(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def update(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)
self.validator.expect("name", str, is_required=False)
self.validator.expect("description", str, is_required=False)
self.validator.expect("image", str, is_required=False)


args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.update_technology(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def delete(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.delete_technology(context, args)
if err:
return err
return MassenergizeResponse(data=res)



def list_for_admin(self, request):
context: Context = request.context
args: dict = context.args

res, err = self.service.list_technologies_for_admin(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def add_coach(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)
self.validator.expect("user_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.add_technology_coach(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def remove_coach(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)
self.validator.expect("user_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.remove_technology_coach(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def add_vendor(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)
self.validator.expect("vendor_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.add_technology_vendor(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def remove_vendor(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)
self.validator.expect("vendor_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.remove_technology_vendor(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def create_overview(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)
self.validator.expect("title", str, is_required=True)
self.validator.expect("description", str, is_required=True)
self.validator.expect("image", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.create_technology_overview(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def update_overview(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)
self.validator.expect("title", str, is_required=False)
self.validator.expect("description", str, is_required=False)
self.validator.expect("image", str, is_required=False)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.update_technology_overview(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def delete_overview(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.delete_technology_overview(context, args)
if err:
return err
return MassenergizeResponse(data=res)



def list_overviews(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.list_technology_overviews(context, args)
if err:
return err
return MassenergizeResponse(data=res)


def list_vendors(self, request):
context: Context = request.context
args: dict = context.args

self.validator.expect("technology_id", str, is_required=True)

args, err = self.validator.verify(args, strict=True)

if err:
return err

res, err = self.service.list_technology_vendors(context, args)
if err:
return err
return MassenergizeResponse(data=res)

10 changes: 9 additions & 1 deletion src/api/services/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
self.store = CampaignStore()

def get_campaign_info(self, context: Context, args) -> Tuple[dict, MassEnergizeAPIError]:
campaign, err = self.store.get_Campaign_info(context, args)
campaign, err = self.store.get_campaign_info(context, args)
if err:
return None, err
return serialize(campaign, full=True), None
Expand Down Expand Up @@ -231,3 +231,11 @@ def add_campaign_technology_like(self, context, args)-> Tuple[dict, MassEnergize
if err:
return None, err
return serialize(res, full=True), None


def delete_campaign_technology_testimonial(self, context, args)-> Tuple[dict, MassEnergizeAPIError]:
res, err = self.store.delete_campaign_technology_testimonial(context, args)
if err:
return None, err

return serialize(res, full=True), None
Loading

0 comments on commit 8193cc2

Please sign in to comment.