-
Notifications
You must be signed in to change notification settings - Fork 15
/
certification.go
81 lines (67 loc) · 2.21 KB
/
certification.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package golinkedin
import (
"encoding/json"
"net/url"
"strconv"
)
// CertificationNode contains user educations info
type CertificationNode struct {
ProfileID string `json:"profileId,omitempty"`
Paging Paging `json:"paging,omitempty"`
RecipeType string `json:"$recipeType,omitempty"`
Elements []Certification `json:"elements,omitempty"`
err error
ln *Linkedin
stopCursor bool
}
type Certification struct {
DateRange DateRange `json:"dateRange,omitempty"`
MultiLocaleLicenseNumber MultiLocale `json:"multiLocaleLicenseNumber,omitempty"`
CompanyUrn string `json:"companyUrn,omitempty"`
URL string `json:"url,omitempty"`
MultiLocaleAuthority MultiLocale `json:"multiLocaleAuthority,omitempty"`
EntityUrn string `json:"entityUrn,omitempty"`
Authority string `json:"authority,omitempty"`
Name string `json:"name,omitempty"`
MultiLocaleName MultiLocale `json:"multiLocaleName,omitempty"`
LicenseNumber string `json:"licenseNumber,omitempty"`
Company Company `json:"company,omitempty"`
RecipeType string `json:"$recipeType,omitempty"`
DisplaySource string `json:"displaySource,omitempty"`
TimePeriod TimePeriod `json:"timePeriod,omitempty"`
}
func (c *CertificationNode) SetLinkedin(ln *Linkedin) {
c.ln = ln
}
func (c *CertificationNode) Next() bool {
if c.stopCursor {
return false
}
start := strconv.Itoa(c.Paging.Start)
count := strconv.Itoa(c.Paging.Count)
raw, err := c.ln.get("/identity/profiles/"+c.ProfileID+"/certifications", url.Values{
"start": {start},
"count": {count},
})
if err != nil {
c.err = err
return false
}
certNode := new(CertificationNode)
if err := json.Unmarshal(raw, certNode); err != nil {
c.err = err
return false
}
c.Elements = certNode.Elements
c.Paging.Start = certNode.Paging.Start + certNode.Paging.Count
if len(c.Elements) == 0 {
return false
}
if len(c.Elements) < c.Paging.Count {
c.stopCursor = true
}
return true
}
func (c *CertificationNode) Error() error {
return c.err
}