Skip to content

Commit

Permalink
HA-104 - added get provider profile by user token
Browse files Browse the repository at this point in the history
- updated bruno definitions
  • Loading branch information
jbc25 committed Jun 12, 2024
1 parent 16ffaeb commit bfea8ca
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/client/Auth/Login User.bru
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body:form-urlencoded {
script:post-response {

let data = res.getBody();
let token = bru.setEnvVar("token", data.token);
let token = bru.setEnvVar("token", data.data.api_key);
}

tests {
Expand Down
11 changes: 11 additions & 0 deletions api/client/Market/Detail Provider.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Detail Provider
type: http
seq: 3
}

get {
url: {{URL}}/api/v2/nodes/{{node_id}}/providers/{{provider_uuid}}
body: none
auth: none
}
2 changes: 1 addition & 1 deletion api/client/Market/List Categories.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: List Categories
type: http
seq: 3
seq: 4
}

get {
Expand Down
2 changes: 1 addition & 1 deletion api/client/Market/List News.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: List News
type: http
seq: 4
seq: 5
}

get {
Expand Down
2 changes: 1 addition & 1 deletion api/client/Profile/Consumer.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Consumer
type: http
seq: 1
seq: 2
}

get {
Expand Down
8 changes: 6 additions & 2 deletions api/client/Profile/Provider.bru
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
meta {
name: Provider
type: http
seq: 3
seq: 1
}

get {
url: {{URL}}/api/v2/nodes/{{node_id}}/providers/{{provider_uuid}}
url: {{URL}}/api/v2/provider/
body: none
auth: none
}

headers {
Authorization: Token {{token}}
}
2 changes: 1 addition & 1 deletion api/client/Profile/Update Consumer.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Update Consumer
type: http
seq: 2
seq: 3
}

put {
Expand Down
4 changes: 2 additions & 2 deletions api/client/environments/PROD.bru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vars {
URL: https://app.mercadosocial.net
username: [email protected]
URL: https://mercadosocial.app
}
vars:secret [
username,
password,
token,
node_id,
Expand Down
4 changes: 2 additions & 2 deletions api/client/environments/STAGING.bru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vars {
URL: https://staging.app.mercadosocial.net
username: [email protected]
URL: https://staging.mercadosocial.app
}
vars:secret [
username,
password,
token,
node_id,
Expand Down
3 changes: 2 additions & 1 deletion api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from api.views.member_status import MemberStatusViewSet
from api.views.news import NewsViewSet
from api.views.offers import OffersViewSet
from api.views.provider import EntitiesView
from api.views.provider import EntitiesView, ProviderAuthViewSet
from api.views.user import FetchUserView, PreRegisterUserView

router = DefaultRouter()
Expand All @@ -29,6 +29,7 @@
path("v2/reset_password/", ResetPasswordView.as_view()),
path("v2/member_status/", MemberStatusViewSet.as_view()),
path("v2/consumer/", ConsumerViewSet.as_view()),
path("v2/provider/", ProviderAuthViewSet.as_view()),
path("v2/profile_image/", ProfileImageViewSet.as_view()),

path("v1/entities/", EntitiesView.as_view()),
Expand Down
14 changes: 14 additions & 0 deletions api/views/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import viewsets
from rest_framework.filters import SearchFilter
from rest_framework.generics import RetrieveUpdateAPIView
from rest_framework.views import APIView

from api.filters.provider import ProviderFilter
from api.mixins.FilterByNodeMixin import FilterByNodeMixin
from api.serializers.provider import ProviderSerializer
from market.models import Provider
from rest_framework import authentication, status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response


class ProviderViewSet(FilterByNodeMixin, viewsets.ReadOnlyModelViewSet):
Expand All @@ -18,6 +22,16 @@ class ProviderViewSet(FilterByNodeMixin, viewsets.ReadOnlyModelViewSet):
filterset_class = ProviderFilter


class ProviderAuthViewSet(FilterByNodeMixin, RetrieveUpdateAPIView):
authentication_classes = [authentication.TokenAuthentication]
permission_classes = (IsAuthenticated,)

def get(self, request, *args, **kwargs):
provider = Provider.objects.get(owner=request.user)
serializer = ProviderSerializer(provider, many=False)
return Response(data=serializer.data, status=status.HTTP_200_OK)


class EntitiesView(APIView):
permission_classes = []

Expand Down

0 comments on commit bfea8ca

Please sign in to comment.