-
Notifications
You must be signed in to change notification settings - Fork 1
/
organization.go
86 lines (74 loc) · 3.33 KB
/
organization.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
82
83
84
85
86
package linkedin
import "strings"
// Organization struct for LinkedIn organizations
type Organization struct {
Paging Paging `json:"paging"`
Elements []ElementOrganization `json:"elements"`
}
// ElementOrganization struct for LinkedIn organization elements
type ElementOrganization struct {
RoleAssignee string `json:"roleAssignee"` // e.g. urn:li:person:a1b2c3
State string `json:"state"` // e.g. APPROVED
LastModified LastModified `json:"lastModified"`
Role string `json:"role"` // e.g. ADMINISTRATOR
Created Created `json:"created"`
Organization string `json:"organization"` // e.g. urn:li:organization:123456789
}
// LastModified struct for last modified timestamp
type LastModified struct {
Actor string `json:"actor"` // e.g. urn:li:person:a1b2c3
Impersonator string `json:"impersonator"` // e.g. urn:li:servicePrincipal:organization
Time int64 `json:"time"` // e.g. 1612345678901
}
// Created struct for created timestamp
type Created struct {
Actor string `json:"actor"` // e.g. urn:li:person:a1b2c3
Impersonator string `json:"impersonator"` // e.g. urn:li:servicePrincipal:organization
Time int64 `json:"time"` // e.g. 1612345678901
}
// GetOrganizationID returns the organization ID from the organization URN
func (e *ElementOrganization) GetOrganizationID() string {
// extract the organization ID from e.g. urn:li:organization:123456789
return e.Organization[strings.LastIndex(e.Organization, ":")+1:]
}
// OrganizationInfo struct for LinkedIn organization information
type OrganizationInfo struct {
VanityName string `json:"vanityName"`
LocalizedName string `json:"localizedName"`
Created Created `json:"created"`
VersionTag string `json:"versionTag"`
CoverPhotoV2 CoverPhotoV2 `json:"coverPhotoV2"`
OrganizationType string `json:"organizationType"` // e.g. SELF_OWNED
DefaultLocale DefaultLocale `json:"defaultLocale"`
LocalizedSpecialties []string `json:"localizedSpecialties"`
Name NameLocalized `json:"name"`
PrimaryOrganizationType string `json:"primaryOrganizationType"` // e.g. NONE
LastModified LastModified `json:"lastModified"`
ID int64 `json:"id"` // ID of the organization
LocalizedDescription string `json:"localizedDescription"`
AutoCreated bool `json:"autoCreated"`
LocalizedWebsite string `json:"localizedWebsite"`
LogoV2 LogoV2 `json:"logoV2"`
}
// CoverPhotoV2 struct for cover photo
type CoverPhotoV2 struct {
Original string `json:"original"`
}
// LogoV2 struct for logo
type LogoV2 struct {
Original string `json:"original"`
}
// DefaultLocale struct for default locale
type DefaultLocale struct {
Country string `json:"country"` // e.g. US
Language string `json:"language"` // e.g. en
}
// NameLocalized struct for localized name
type NameLocalized struct {
Localized map[string]string `json:"localized"`
PreferredLocale DefaultLocale `json:"preferredLocale"`
}
// GetOrganizationID returns the organization ID from the details of the organization
func (oi *OrganizationInfo) GetOrganizationID() int64 {
return oi.ID
}