-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiles.go
49 lines (38 loc) · 1.05 KB
/
profiles.go
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
package main
import (
"fmt"
"bitbucket.org/long174/go-odoo"
"github.com/spejder/aarsstjerner/internal/ms"
)
func profiles(client *ms.Client) (*ms.MemberProfiles, error) {
criteria := odoo.NewCriteria().Add("can_access_contact_info", "=", true)
criteria.
Add("state", "=", "active").
Add("is_active_leader", "=", false)
options := odoo.NewOptions().FetchFields(
"id",
"display_name",
"scout_name",
"membership_ids",
"other_info",
)
profiles, err := client.FindMemberProfiles(criteria, options)
if err != nil {
return &ms.MemberProfiles{}, fmt.Errorf("finding member profiles: %w", err)
}
return profiles, nil
}
func memberships(client *ms.Client, ids []int64) (*ms.MemberMemberships, error) {
criteria := odoo.NewCriteria().Add("id", "=", ids)
options := odoo.NewOptions().FetchFields(
"id",
"active_flag",
"start_date",
"end_date",
)
memberships, err := client.FindMemberMemberships(criteria, options)
if err != nil {
return &ms.MemberMemberships{}, fmt.Errorf("finding member profiles: %w", err)
}
return memberships, nil
}