github.com/schmorrison/Zoho@v1.1.4/recruit/user.go (about) 1 package recruit 2 3 import ( 4 "fmt" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 // GetUsers returns a list of users. Users are those who are allowed to access and manage records. 10 // https://www.zoho.com/recruit/developer-guide/apiv2/get-users.html 11 // https://recruit.zoho.eu/recruit/v2/users?type={AllUsers,ActiveUsers,DeactiveUsers,ConfirmedUsers,NotConfirmedUsers,DeletedUsers,ActiveConfirmedUsers,AdminUsers,ActiveConfirmedAdmins,CurrentUser} 12 func (c *API) GetUsers(params map[string]zoho.Parameter) (data UsersResponse, err error) { 13 endpoint := zoho.Endpoint{ 14 Name: "GetUsers", 15 URL: fmt.Sprintf("https://recruit.zoho.%s/recruit/v2/users", c.ZohoTLD), 16 Method: zoho.HTTPGet, 17 ResponseData: &UsersResponse{}, 18 URLParameters: map[string]zoho.Parameter{ 19 "type": "", 20 }, 21 } 22 23 if len(params) > 0 { 24 for k, v := range params { 25 endpoint.URLParameters[k] = v 26 } 27 } 28 29 err = c.Zoho.HTTPRequest(&endpoint) 30 if err != nil { 31 return UsersResponse{}, fmt.Errorf("failed to retrieve users: %s", err) 32 } 33 34 if v, ok := endpoint.ResponseData.(*UsersResponse); ok { 35 return *v, nil 36 } 37 38 return UsersResponse{}, fmt.Errorf("data returned was not 'UsersResponse'") 39 } 40 41 // UsersResponse is the data returned by GetUsers 42 type UsersResponse struct { 43 Users []struct { 44 DecimalSeparator string `json:"decimal_separator,omitempty"` 45 Role struct { 46 Name string `json:"name,omitempty"` 47 ID string `json:"id,omitempty"` 48 } `json:"role,omitempty"` 49 CustomizeInfo struct { 50 NotesDesc interface{} `json:"notes_desc,omitempty"` 51 ShowRightPanel interface{} `json:"show_right_panel,omitempty"` 52 BcView interface{} `json:"bc_view,omitempty"` 53 ShowHome bool `json:"show_home,omitempty"` 54 ShowDetailView interface{} `json:"show_detail_view,omitempty"` 55 UnpinRecentItem interface{} `json:"unpin_recent_item,omitempty"` 56 } `json:"customize_info,omitempty"` 57 Signature interface{} `json:"signature,omitempty"` 58 Profile struct { 59 Name string `json:"name,omitempty"` 60 ID string `json:"id,omitempty"` 61 } `json:"profile,omitempty"` 62 LastName string `json:"last_name,omitempty"` 63 NameFormat string `json:"name_format,omitempty"` 64 Language string `json:"language,omitempty"` 65 Locale string `json:"locale,omitempty"` 66 TimeZone string `json:"time_zone,omitempty"` 67 PersonalAccount bool `json:"personal_account,omitempty"` 68 Zuid string `json:"zuid,omitempty"` 69 Confirm bool `json:"confirm,omitempty"` 70 DefaultTabGroup string `json:"default_tab_group,omitempty"` 71 FullName string `json:"full_name,omitempty"` 72 Territories []interface{} `json:"territories,omitempty"` 73 Dob string `json:"dob,omitempty"` 74 DateFormat string `json:"date_format,omitempty"` 75 Theme struct { 76 NormalTab struct { 77 FontColor string `json:"font_color,omitempty"` 78 Background string `json:"background,omitempty"` 79 } `json:"normal_tab,omitempty"` 80 SelectedTab struct { 81 FontColor string `json:"font_color,omitempty"` 82 Background string `json:"background,omitempty"` 83 } `json:"selected_tab,omitempty"` 84 NewBackground interface{} `json:"new_background,omitempty"` 85 Background string `json:"background,omitempty"` 86 Screen string `json:"screen,omitempty"` 87 Type string `json:"type,omitempty"` 88 } `json:"theme,omitempty"` 89 ID string `json:"id,omitempty"` 90 CountryLocale string `json:"country_locale,omitempty"` 91 FirstName interface{} `json:"first_name,omitempty"` 92 Email string `json:"email,omitempty"` 93 Status string `json:"status,omitempty"` 94 } `json:"users,omitempty"` 95 Info PageInfo `json:"info,omitempty"` 96 }