Skip to content

Commit

Permalink
Merge pull request #111 from Ilhasoft/feature/grpc-whatsapp-integrations
Browse files Browse the repository at this point in the history
Feature/grpc whatsapp integrations
  • Loading branch information
BarbosaJackson committed Dec 21, 2021
2 parents 77c7cea + 1e98d97 commit 8e4540f
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ grpcio-tools = "~=1.39.0"
djangogrpcframework = "~=0.2.1"
stripe = "~=2.60.0"
psutil = "~=5.8.0"
weni-protobuffers = "~=1.2.0"
weni-protobuffers = "==1.2.7"

[requires]
python_version = "3.6"
113 changes: 63 additions & 50 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions connect/api/grpc/organization/handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from connect.api.grpc.organization.services import OrganizationService
from weni.protobuf.connect import organization_pb2_grpc


def grpc_handlers(server):
organization_pb2_grpc.add_OrganizationControllerServicer_to_server(
OrganizationService.as_servicer(), server
)
10 changes: 10 additions & 0 deletions connect/api/grpc/organization/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django_grpc_framework.proto_serializers import ProtoSerializer
from rest_framework import serializers
from weni.protobuf.connect import organization_pb2


class OrganizationSerializer(ProtoSerializer):
uuid = serializers.CharField(required=True)

class Meta:
proto_class = organization_pb2.OrganizationResponse
19 changes: 19 additions & 0 deletions connect/api/grpc/organization/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from connect.common.models import Organization
from weni.protobuf.connect.organization_pb2 import OrganizationResponse
from django_grpc_framework import generics


class OrganizationService(generics.GenericService):
def Retrieve(self, request, context):

flow_organization_uuid = request.uuid
organization = Organization.objects.get(project__flow_organization=flow_organization_uuid)

return OrganizationResponse(
uuid=str(organization.uuid),
name=organization.name,
description=organization.description,
inteligence_organization=organization.inteligence_organization,
extra_integration=organization.extra_integration,
is_suspended=organization.is_suspended,
)
2 changes: 2 additions & 0 deletions connect/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from connect.api.v1 import urls as rookly_api_v1_urls
from connect.api.grpc.project.handlers import grpc_handlers as grpc_project_handlers
from connect.api.grpc.organization.handlers import grpc_handlers as grpc_organization_handlers
from connect.billing.views import StripeHandler


Expand All @@ -49,6 +50,7 @@

def grpc_handlers(server):
grpc_project_handlers(server)
grpc_organization_handlers(server)


if settings.DEBUG:
Expand Down

0 comments on commit 8e4540f

Please sign in to comment.