def post_chunk(chunk):
    if is_valid_chunk(chunk) == True:
        timestamp = chunk['timestamp'].strftime("%Y-%m-%dT%H:%M:%S.%fZ")
        gas = {'value': chunk['gas'], 'read_on': timestamp, 'token': token}
        requests.post(endpoint + '/api/gas', json=gas)

        elec = {'value': chunk['day_elec_usage'] + chunk['night_elec_usage'], 'read_on': timestamp, 'token': token}
        requests.post(endpoint + '/api/electricity', json=elec)

        solar = {'value': chunk['day_elec_inject'] + chunk['night_elec_inject'], 'read_on': timestamp, 'token': token}
        requests.post(endpoint + '/api/solar', json=solar)
    else:
        print('invalid chunk')
        print(chunk)
        # print('timestamp' in chunk)
        # print('day_elec_usage' in chunk)
        # print('night_elec_usage' in chunk)
        # print('day_elec_inject' in chunk)
        # print('night_elec_inject' in chunk)
        # print('gas' in chunk)
        print('timestamp' in chunk and 'day_elec_usage' in chunk  and 'night_elec_usage' in chunk  and 'day_elec_inject' in chunk and 'night_elec_inject' in chunk and 'gas' in chunk)
        sys.exit(1)