def get(self): location = u'{}/categories'.format(urls.INCOME_SERVICE) res = requests.get(location) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def delete(self, name): location = u'{}/categories/{}'.format(urls.INCOME_SERVICE, name) res = requests.delete(location) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def post(self): location = u'{}/categories'.format(urls.INCOME_SERVICE) body = parsers.catParser.parse_args() res = requests.post(location, json=body) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def delete(self, id): location = u'{}/barcodes/{}'.format(urls.INCOME_SERVICE, id) res = requests.delete(location) if res.status_code == 201 or res.status_code == 200: # print(res.json()) return res.json() else: return codeChecker(res.status_code)
def put(self, id): location = u'{}/barcodes/{}'.format(urls.INCOME_SERVICE, id) body = parsers.barUpdateParser.parse_args() res = requests.put(location, json=body) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def get(self): uid = get_jwt_identity() location = u'{}/incomes/{}'.format(urls.INCOME_SERVICE, uid) res = requests.get(location) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def put(self, id): body = parsers.incomeUpdateParser.parse_args() uid = get_jwt_identity() location = u'{}/incomes/{}/{}'.format(urls.INCOME_SERVICE, uid, id) res = requests.put(location, json=body) if res.status_code == 201 or res.status_code == 200: return res.json() else: return codeChecker(res.status_code)
def post(self): body = parsers.loginParser.parse_args() print(body) res = requests.post(urls.USER_SERVICE + '/login', json=body) if res.status_code == 201 or res.status_code == 200: id = res.json()['id'] fullname = res.json()['fullName'] access_token = create_access_token(identity=id) return { 'message': '{} logged in success'.format(fullname), 'access_token': access_token }, 200 return codeChecker(res.status_code)
def post(self): body = parsers.registerParser.parse_args() res = requests.post(urls.USER_SERVICE + u'/register', json=body) # print(res.json()) if res.status_code == 201 or res.status_code == 200: id = res.json()['id'] fullname = res.json()['fullname'] access_token = create_access_token(identity=id) return { 'message': 'User {} was created'.format(fullname), 'access_token': access_token }, 201 return codeChecker(res.status_code)