Advertisement
alisonamerico

barcode_upload

Mar 8th, 2021
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # services.py
  2.  
  3.     def barcode_upload_iupay(self, user, token, barcode):
  4.         url = 'https://api.iupay.com.br/api/v5alpha/documents/barcode'
  5.         payload = {"barcode": barcode}
  6.         headers = {'content-type': 'application/json', 'Authorization': token}
  7.         response = requests.post(url, data=json.dumps(payload), headers=headers)
  8.         return response
  9.  
  10. -----------------------------------------------------------------------------------------------
  11.  
  12. # views.py
  13.  
  14. class BarcodeUploadPIView(ListAPIView):
  15.     serializer_class = BankSlipSerializer
  16.     permission_classes = [permissions.IsAuthenticated]
  17.  
  18.     def post(self, request, *args, **kwargs):
  19.         barcode_iupay = barcode_upload_iupay(request.data.get('barcode'))
  20.         barcode = BankSlip.objects.get(barcode=barcode)
  21.         return Response(barcode)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement