-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdonki.go
More file actions
71 lines (60 loc) · 1.77 KB
/
donki.go
File metadata and controls
71 lines (60 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package nasaapi
import (
donki "nasaapi/types/donki"
"net/url"
"strconv"
"time"
)
// Catalog is the type for the CMEAnalyses' `catalog` parameter
type catalog string
// Enum values for CMEAnalyses' `catalog` parameters
const (
All = catalog("ALL")
SWRCCatalog = catalog("SWRC_CATALOG")
JangEtAlCatalog = catalog("JANG_ET_AL_CATALOG")
)
func (f *fetcher) CoronalMassEjections(startDate, endDate time.Time) (*donki.CoronalMassEjections, error) {
u := f.buildURL(
"DONKI/CME",
map[string]string{
"startDate": startDate.Format(dateFormat),
"endDate": endDate.Format(dateFormat),
},
)
return getCME(u)
}
func getCME(u *url.URL) (*donki.CoronalMassEjections, error) {
a := &donki.CoronalMassEjections{}
if err := getAndParse(u.String(), a); err != nil {
return nil, err
}
return a, nil
}
func (f *fetcher) CoronalMassEjectionsAnalyses(
startDate, endDate time.Time,
mostAccurateOnly, completeEntryOnly bool,
lowerSpeed, lowerHalfAngle int64,
catalog catalog,
keyword string) (*donki.CoronalMassEjectionsAnalyses, error) {
u := f.buildURL(
"DONKI/CMEAnalysis",
map[string]string{
"startDate": startDate.Format(dateFormat),
"endDate": endDate.Format(dateFormat),
"mostAccurateOnly": strconv.FormatBool(mostAccurateOnly),
"completeEntryOnly": strconv.FormatBool(completeEntryOnly),
"speed": strconv.FormatInt(lowerSpeed, 10),
"halfAngle": strconv.FormatInt(lowerHalfAngle, 10),
"catalog": string(catalog),
"keyword": keyword,
},
)
return getCMEAnalyses(u)
}
func getCMEAnalyses(u *url.URL) (*donki.CoronalMassEjectionsAnalyses, error) {
a := &donki.CoronalMassEjectionsAnalyses{}
if err := getAndParse(u.String(), a); err != nil {
return nil, err
}
return a, nil
}