got get_contacts working
This commit is contained in:
@@ -53,45 +53,6 @@ else:
|
||||
)
|
||||
)
|
||||
|
||||
def idoklad_token():
|
||||
try:
|
||||
token = iDokladToken.objects.get(id=1)
|
||||
except iDokladToken.DoesNotExist:
|
||||
return None
|
||||
|
||||
if token.updated_at + datetime.timedelta(seconds=token.expires_in) < timezone.now():
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
data = {
|
||||
'grant_type': 'refresh_token',
|
||||
'client_id': IDOKLAD_CLIENT_ID,
|
||||
'client_secret': IDOKLAD_CLIENT_SECRET,
|
||||
'scope': 'eet offline_access',
|
||||
'refresh_token': token.refresh_token,
|
||||
}
|
||||
|
||||
response = requests.post('https://app.idoklad.cz/identity/server/connect/token', headers=headers, data=data)
|
||||
|
||||
if response.status_code == 200:
|
||||
token = response.json()
|
||||
token['updated_at'] = timezone.now()
|
||||
iDokladToken.objects.filter(id=1).update(**token)
|
||||
else:
|
||||
return None
|
||||
|
||||
return token
|
||||
|
||||
def prepare_invoice():
|
||||
token = idoklad_token()
|
||||
if token is None:
|
||||
return None
|
||||
|
||||
data = {
|
||||
'templateId': 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
def process_webhook(notification):
|
||||
|
||||
Reference in New Issue
Block a user