grocy-cli/grocy/models/schema.py

16 lines
564 B
Python
Raw Normal View History

2019-04-28 16:12:05 -05:00
from grocy import RestService
import logging
2019-06-16 23:54:10 -05:00
class Schema(object):
2019-04-28 16:12:05 -05:00
def _init_rest_service(self):
if hasattr(self, 'api'):
if self.api.startswith == '/':
self.api = self.api[1:]
if self.api.endswith == '/':
self.api = self.api[1:-1]
self.rest_service = RestService(self.api, json=True)
self.rest_service.addHeader('Content-Type', 'application/json')
self.rest_service.addHeader('Accept', 'application/json')
self.rest_service.addToken(self.token)