<commit_before>package main

import (
	yoBackClient "github.com/yoed/yoed-client-yo-back"
	clientInterface "github.com/yoed/yoed-client-interface"
	"net/http"
	"log"
	"fmt"
	"io/ioutil"
	"encoding/json"
	"strings"
	"time"
	"bytes"
	"math"
)

type TransilienYoedClient struct {
	yoBackClient.YoBackYoedClient
	config *TransilienYoedClientConfig
}

const Fmt = "15:04"
type configTime time.Time
func (ct *configTime) UnmarshalJSON(data []byte) error {
        b := bytes.NewBuffer(data)
        dec := json.NewDecoder(b)
        var s string
        if err := dec.Decode(&s); err != nil {
                return err
        }
        t, err := time.Parse(Fmt, s)
        if err != nil {
                return err
        }
        *ct = (configTime)(t)
        return nil
}

type configDelta time.Duration
func (cd *configDelta) UnmarshalJSON(data []byte) error {
        b := bytes.NewBuffer(data)
        dec := json.NewDecoder(b)
        var s string
        if err := dec.Decode(&s); err != nil {
                return err
        }
        t, err := time.ParseDuration(s)
        if err != nil {
                return err
        }
        *cd = (configDelta)(t)
        return nil
}

type TransilienYoedClientConfig struct {
	FromStation string
	ToStation string
	Hour configTime
	Delta configDelta
}

type TransilienApiResponse struct {
    Data []*struct{
        TrainHour string
    }
}

func (c *TransilienYoedClient) loadConfig(configPath string) (*TransilienYoedClientConfig, error) {
	configJson, err := clientInterface.ReadConfig(configPath)

	if err != nil {
		return nil, err
	}

	config := &TransilienYoedClientConfig{}

	if err := json.Unmarshal(configJson, config); err != nil {
		return nil, err
	}

	return config, nil
}

func (c *TransilienYoedClient) Handle(username string) {
	url := "http://transilien.ods.ocito.com/ods/transilien/iphone"
   	jsonDataIn := `[{"target":"/transilien/getNextTrains","map":{"codeArrivee":"PMP","codeDepart":"VMK"},"serial":"4"}]`
   	b := strings.NewReader(jsonDataIn)
	resp, err := http.Post(url, "application/json", b)

	log.Print("Requesting Transilien API from station %s to station %s", c.config.FromStation, c.config.ToStation)

	if err != nil {
		log.Printf("Transilien API error: %s", err)
		return
	}

	defer resp.Body.Close()

	log.Printf("Transilien API response status: %s", resp.Status)

	if body, err := ioutil.ReadAll(resp.Body); err != nil {
		log.Printf("Transilien API response body error: %s", err)
	} else {
		log.Printf("Transilien API response body: %s", string(body))<commit_msg>From/To station read from config<commit_after>package main

import (
	yoBackClient "github.com/yoed/yoed-client-yo-back"
	clientInterface "github.com/yoed/yoed-client-interface"
	"net/http"
	"log"
	"fmt"
	"io/ioutil"
	"encoding/json"
	"strings"
	"time"
	"bytes"
	"math"
)

type TransilienYoedClient struct {
	yoBackClient.YoBackYoedClient
	config *TransilienYoedClientConfig
}

const Fmt = "15:04"
type configTime time.Time
func (ct *configTime) UnmarshalJSON(data []byte) error {
        b := bytes.NewBuffer(data)
        dec := json.NewDecoder(b)
        var s string
        if err := dec.Decode(&s); err != nil {
                return err
        }
        t, err := time.Parse(Fmt, s)
        if err != nil {
                return err
        }
        *ct = (configTime)(t)
        return nil
}

type configDelta time.Duration
func (cd *configDelta) UnmarshalJSON(data []byte) error {
        b := bytes.NewBuffer(data)
        dec := json.NewDecoder(b)
        var s string
        if err := dec.Decode(&s); err != nil {
                return err
        }
        t, err := time.ParseDuration(s)
        if err != nil {
                return err
        }
        *cd = (configDelta)(t)
        return nil
}

type TransilienYoedClientConfig struct {
	FromStation string
	ToStation string
	Hour configTime
	Delta configDelta
}

type TransilienApiResponse struct {
    Data []*struct{
        TrainHour string
    }
}

func (c *TransilienYoedClient) loadConfig(configPath string) (*TransilienYoedClientConfig, error) {
	configJson, err := clientInterface.ReadConfig(configPath)

	if err != nil {
		return nil, err
	}

	config := &TransilienYoedClientConfig{}

	if err := json.Unmarshal(configJson, config); err != nil {
		return nil, err
	}

	return config, nil
}

func (c *TransilienYoedClient) Handle(username string) {
	url := "http://transilien.ods.ocito.com/ods/transilien/iphone"
   	jsonDataIn := `[{"target":"/transilien/getNextTrains","map":{"codeArrivee":"`+c.config.ToStation+`","codeDepart":"`+c.config.FromStation+`"},"serial":"4"}]`
   	log.Printf(jsonDataIn)
   	b := strings.NewReader(jsonDataIn)
	resp, err := http.Post(url, "application/json", b)

	log.Print("Requesting Transilien API from station %s to station %s", c.config.FromStation, c.config.ToStation)

	if err != nil {
		log.Printf("Transilien API error: %s", err)
		return
	}

	defer resp.Body.Close()

	log.Printf("Transilien API response status: %s", resp.Status)

	if body, err := ioutil.ReadAll(resp.Body); err != nil {
		log.Printf("Transilien API response body error: %s", err)
	} else {
		log.Printf("Transilien API response body: %s", string(body))
{'fraction_non_alphanumeric': 0.13182167563412758, 'fraction_numerical': 0.001921598770176787, 'mean_word_length': 3.072769953051643, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7157540', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1752, 'n_words': 420}