-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresults.go
More file actions
53 lines (41 loc) · 1.13 KB
/
results.go
File metadata and controls
53 lines (41 loc) · 1.13 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
package irdata
import (
"context"
"fmt"
"net/url"
)
func (d *irdata) Results() DataResults {
return &irdataResults{parent: d}
}
type irdataResults struct {
parent *irdata
}
type DataResults interface {
Get(ctx context.Context, subsessionId int, opts ...ResultsGetOption) (ResultSession, error)
}
type ResultsGetOption interface {
ApplyResultsGet(*url.Values)
}
type ResultsFromOption struct {
IncludeLicenses bool
}
func (o *ResultsFromOption) ApplyResultsGet(v *url.Values) {
v.Set("include_licenses", fmt.Sprintf("%t", o.IncludeLicenses))
}
func (c *irdataResults) Get(ctx context.Context, subsessionId int, opts ...ResultsGetOption) (ResultSession, error) {
d := c.parent
u, err := url.Parse(fmt.Sprintf("%s/data/results/get", d.membersUrl))
if err != nil {
return ResultSession{}, &ConfigurationError{Msg: "unable to parse URL", Trigger: err}
}
q := u.Query()
q.Set("subsession_id", fmt.Sprintf("%d", subsessionId))
u.RawQuery = q.Encode()
resp, err := d.get(ctx, u.String())
var output ResultSession
err = handleLink(ctx, d, resp, err, &output)
if err != nil {
return ResultSession{}, err
}
return output, nil
}