Skip to content

Commit

Permalink
feat: add test data
Browse files Browse the repository at this point in the history
  • Loading branch information
oscaromeu committed May 12, 2023
1 parent 0c67667 commit 85205ef
Show file tree
Hide file tree
Showing 9 changed files with 19,714 additions and 1,467 deletions.
37 changes: 37 additions & 0 deletions _examples/basic/weather.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"fmt"
"log"
"os"

"github.com/oscaromeu/meteocat"
)

func main() {

// execute export METEOCAT_API_KEY=<API_KEY_VALUE> on a shell first
d, err := meteocat.NewMesurades(os.Getenv("METEOCAT_API_KEY"))
if err != nil {
log.Fatalln(err)
}

if meteocat.CheckAPIKeyExists(d.Key) == false {
fmt.Println("ApiKey is not set. ")
}

data := meteocat.Data{
Any: "2023",
Mes: "01",
Dia: "06",
}
params, _ := meteocat.NewParameters(
meteocat.OptionCodiEstacio("D5"),
meteocat.OptionCodiVariable("32"),
meteocat.OptionData(data),
)

// Call MeasurementByDay Method
d.MeasurementByDay(params)
fmt.Println(d.Measurements)
}
9 changes: 0 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ go 1.13

require (
github.com/fatih/color v1.15.0
github.com/ilyakaznacheev/cleanenv v1.2.5
github.com/influxdata/influxdb-client-go/v2 v2.6.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/sys v0.8.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
1,462 changes: 4 additions & 1,458 deletions go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mesurades.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (m *Mesurades) MeasurementByDay(p *Parameters) error {
return err
}

//req.Header.Set("Content-Type", "application/json")
req.Header.Add("X-Api-Key", m.Key)

resp, err := m.client.Do(req)
Expand Down
19 changes: 19 additions & 0 deletions testdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/referencia/v1/municipis
```

```
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/estacions/metadades?estat=ope&data=2023-03-11Z
```

```
cat testdata/metadades_totes_estacions.json| jq -r '.|sort_by(.nom)|.[]|([.nom, .codi])|@tsv'
```

```
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/estacions/D5/metadades
```

```
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/variables/mesurades/32/2023/03/12?codiEstacio=D5
```
293 changes: 293 additions & 0 deletions testdata/dades_variable_32_estacio_D5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
{
"codi": 32,
"lectures": [
{
"data": "2023-03-12T00:00Z",
"valor": 15.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T00:30Z",
"valor": 15.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T01:00Z",
"valor": 15.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T01:30Z",
"valor": 15.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T02:00Z",
"valor": 15.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T02:30Z",
"valor": 15.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T03:00Z",
"valor": 15.1,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T03:30Z",
"valor": 15.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T04:00Z",
"valor": 14.9,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T04:30Z",
"valor": 14.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T05:00Z",
"valor": 13.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T05:30Z",
"valor": 13.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T06:00Z",
"valor": 13.1,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T06:30Z",
"valor": 13.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T07:00Z",
"valor": 14.5,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T07:30Z",
"valor": 15.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T08:00Z",
"valor": 16.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T08:30Z",
"valor": 16.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T09:00Z",
"valor": 15.9,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T09:30Z",
"valor": 16.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T10:00Z",
"valor": 17.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T10:30Z",
"valor": 17.9,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T11:00Z",
"valor": 19,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T11:30Z",
"valor": 19.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T12:00Z",
"valor": 19.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T12:30Z",
"valor": 19.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T13:00Z",
"valor": 18.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T13:30Z",
"valor": 18.8,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T14:00Z",
"valor": 18.1,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T14:30Z",
"valor": 18.6,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T15:00Z",
"valor": 19.5,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T15:30Z",
"valor": 19.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T16:00Z",
"valor": 17.5,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T16:30Z",
"valor": 16.6,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T17:00Z",
"valor": 15.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T17:30Z",
"valor": 13.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T18:00Z",
"valor": 12.8,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T18:30Z",
"valor": 13,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T19:00Z",
"valor": 12.6,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T19:30Z",
"valor": 12.8,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T20:00Z",
"valor": 14.1,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T20:30Z",
"valor": 14.4,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T21:00Z",
"valor": 14.6,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T21:30Z",
"valor": 14.3,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T22:00Z",
"valor": 14.7,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T22:30Z",
"valor": 15.2,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T23:00Z",
"valor": 15.1,
"estat": "V",
"baseHoraria": "SH"
},
{
"data": "2023-03-12T23:30Z",
"valor": 15.1,
"estat": "V",
"baseHoraria": "SH"
}
]
}
Loading

0 comments on commit 85205ef

Please sign in to comment.