<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
using System.Net.Http;
using System.Diagnostics;
using System.Threading.Tasks;
using WivaldyBot.Models.WivaldyObjects;

namespace WivaldyBot.Models
{
    [Serializable]
    public class Wivaldy
    {
        public string Connection { get; set; }

        public Wivaldy() { }

        public Wivaldy(string connection)
        {
            Connection = connection;
        }

        #region Consumption

        public async Task<Electricity> GetMeasures(DateTimeOffset start, DateTimeOffset stop)
        {
            //API is http://app.wivaldy.com/api/v1/json/privatekey/2016-11-01-08:00/2016-11-01-08:10
            //API is http://app.wivaldy.com/api/v1/json/{PRIVATE_KEY}/last
            try
            {
                HttpClient cli = new HttpClient();
                string urlrequest = $"https://app.wivaldy.com/api/v1/json/{Connection}/";
                //if both are null, then only last measure
                if ((start == DateTimeOffset.MinValue) && (stop == DateTimeOffset.MinValue))
                    urlrequest += "last";
                //if only stop is nullm than a full day
                else if (stop == DateTimeOffset.MinValue)<commit_msg>Use staging (recette) API for all requests<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
using System.Net.Http;
using System.Diagnostics;
using System.Threading.Tasks;
using WivaldyBot.Models.WivaldyObjects;

namespace WivaldyBot.Models
{
    [Serializable]
    public class Wivaldy
    {
        public string Connection { get; set; }

        public Wivaldy() { }

        public Wivaldy(string connection)
        {
            Connection = connection;
        }

        #region Consumption

        public async Task<Electricity> GetMeasures(DateTimeOffset start, DateTimeOffset stop)
        {
            //API is http://app.wivaldy.com/api/v1/json/privatekey/2016-11-01-08:00/2016-11-01-08:10
            //API is http://app.wivaldy.com/api/v1/json/{PRIVATE_KEY}/last
            try
            {
                HttpClient cli = new HttpClient();
                string urlrequest = $"https://app-recette.wivaldy.com/api/v1/json/{Connection}/";
                //if both are null, then only last measure
                if ((start == DateTimeOffset.MinValue) && (stop == DateTimeOffset.MinValue))
                    urlrequest += "last";
                //if only stop is nullm than a full day
                else if (stop == DateTimeOffset.MinValue)
{'fraction_non_alphanumeric': 0.10496400151572566, 'fraction_numerical': 0.02046229632436529, 'mean_word_length': 2.120567375886525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823778', 'n_tokens_mistral': 788, 'n_tokens_neox': 737, 'n_words': 179}