client

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPageSize = 50

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessRole

type AccessRole struct {
	AccessRoleUID   string `json:"access_role_uid"`
	AccessRoleName  string `json:"role_name"`
	RoleDescription string `json:"role_description"`
}

type AssignUserToTeamRequest

type AssignUserToTeamRequest struct {
	TeamUID string `json:"team_uid"`
	UserUID string `json:"user_uid"`
}

AssignUserToTeam models.

type AssignUserToTeamResponse

type AssignUserToTeamResponse struct {
	Type    string `json:"type"`
	Title   string `json:"title"`
	Message string `json:"message"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Zuper API client for Baton.

func New

func New(ctx context.Context, client *Client) (*Client, error)

func NewClient

func NewClient(ctx context.Context, apiUrl string, apiKey string, httpClient *uhttp.BaseHttpClient) *Client

NewClient creates a new Client instance with the provided HTTP client.

func (*Client) AssignUserToTeam

func (c *Client) AssignUserToTeam(ctx context.Context, teamUID string, userUID string) (*AssignUserToTeamResponse, annotations.Annotations, error)

AssignUserToTeam assigns a user to a team in Zuper using the teamUID and userUID.

func (*Client) CreateUser

CreateUser sends a request to create a new user with the provided user payload and default work hours.

func (*Client) GetTeamUsers

func (c *Client) GetTeamUsers(ctx context.Context, teamID string) ([]*ZuperUser, string, annotations.Annotations, error)

GetTeamUsers fetches the users of a team from the Zuper API.

func (*Client) GetTeams

func (c *Client) GetTeams(ctx context.Context, opts PageOptions) ([]*Team, string, annotations.Annotations, error)

GetTeams fetches a paginated list of teams from the Zuper API.

func (*Client) GetUserByID

func (c *Client) GetUserByID(ctx context.Context, userUID string) (*ZuperUser, annotations.Annotations, error)

GetUserByID fetches the details of a user by their user_uid from the Zuper API.

func (*Client) GetUsers

GetUsers fetches a paginated list of users from the Zuper API.

func (*Client) IsUserInTeam

func (c *Client) IsUserInTeam(ctx context.Context, teamUID string, userUID string) (bool, error)

IsUserInTeam checks if a user is already a member of a team.

func (*Client) UnassignUserFromTeam

func (c *Client) UnassignUserFromTeam(ctx context.Context, teamUID string, userUID string) (*AssignUserToTeamResponse, annotations.Annotations, error)

UnassignUserFromTeam removes a user from a team in Zuper using the teamUID and userUID.

func (*Client) UpdateUserAccessRole

func (c *Client) UpdateUserAccessRole(ctx context.Context, userUID string, accessRoleUID string) (*UpdateUserRoleResponse, annotations.Annotations, error)

UpdateUserAccessRole updates the access role of a user using UpdateUserField.

func (*Client) UpdateUserField

func (c *Client) UpdateUserField(ctx context.Context, userUID string, field string, value interface{}) (*UpdateUserRoleResponse, annotations.Annotations, error)

UpdateUserField updates a specific field of a user in Zuper.

func (*Client) UpdateUserRole

func (c *Client) UpdateUserRole(ctx context.Context, userUID string, roleID int) (*UpdateUserRoleResponse, annotations.Annotations, error)

UpdateUserRole updates the role of a user using UpdateUserField.

type CreateUserRequest

type CreateUserRequest struct {
	WorkHours []WorkHour  `json:"work_hours"`
	User      UserPayload `json:"user"`
}

type CreateUserResponse

type CreateUserResponse struct {
	Type    string `json:"type"`
	Title   string `json:"title"`
	Message string `json:"message"`
	Data    struct {
		UserUID string `json:"user_uid"`
	} `json:"data"`
}

type CreatedBy

type CreatedBy struct {
	UserUID           string `json:"user_uid"`
	FirstName         string `json:"first_name"`
	LastName          string `json:"last_name"`
	Email             string `json:"email"`
	ExternalLoginID   string `json:"external_login_id"`
	HomePhoneNumber   string `json:"home_phone_number"`
	Designation       string `json:"designation"`
	EmpCode           string `json:"emp_code"`
	Prefix            string `json:"prefix"`
	WorkPhoneNumber   string `json:"work_phone_number"`
	MobilePhoneNumber string `json:"mobile_phone_number"`
	ProfilePicture    string `json:"profile_picture"`
	HourlyLaborCharge string `json:"hourly_labor_charge"`
	IsActive          bool   `json:"is_active"`
	IsDeleted         bool   `json:"is_deleted"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
}

CreateUser models.

type ErrorResponse

type ErrorResponse interface {
	Message() string
}

type PageOptions

type PageOptions struct {
	PageToken string
	PageSize  int
}

type Role

type Role struct {
	RoleUID  string `json:"role_uid"`
	RoleName string `json:"role_name"`
	RoleKey  string `json:"role_key"`
}

Role & Access Models.

type Team

type Team struct {
	TeamUID         string    `json:"team_uid"`
	TeamName        string    `json:"team_name"`
	TeamColor       string    `json:"team_color"`
	TeamDescription string    `json:"team_description"`
	TeamTimezone    string    `json:"team_timezone"`
	UserCount       int       `json:"user_count"`
	IsActive        bool      `json:"is_active"`
	CreatedAt       string    `json:"created_at"`
	UpdatedAt       string    `json:"updated_at"`
	CreatedBy       CreatedBy `json:"created_by"`
}

Teams Models.

type TeamDetailsResponse

type TeamDetailsResponse struct {
	Type string `json:"type"`
	Data Team   `json:"data"`
}

type TeamDetailsWithUsersResponse

type TeamDetailsWithUsersResponse struct {
	Type string `json:"type"`
	Data struct {
		Team  Team        `json:"team"`
		Users []ZuperUser `json:"users"`
	} `json:"data"`
}

type TeamsResponse

type TeamsResponse struct {
	Type         string `json:"type"`
	Data         []Team `json:"data"`
	TotalRecords int    `json:"total_records"`
	CurrentPage  int    `json:"current_page"`
	TotalPages   int    `json:"total_pages"`
}

type UnassignUserFromTeamRequest

type UnassignUserFromTeamRequest struct {
	TeamUID string `json:"team_uid"`
	UserUID string `json:"user_uid"`
}

UnassignUserFromTeam models.

type UpdateUserAccessRoleRequest

type UpdateUserAccessRoleRequest struct {
	User struct {
		AccessRole string `json:"access_role"`
	} `json:"user"`
}

UpdateUserAccessRoleRequest models.

type UpdateUserRoleRequest

type UpdateUserRoleRequest struct {
	User struct {
		RoleID int `json:"role_id"`
	} `json:"user"`
}

type UpdateUserRoleResponse

type UpdateUserRoleResponse struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	Title   string `json:"title,omitempty"`
}

UpdateUserRole models.

type UserDetailsResponse

type UserDetailsResponse struct {
	Type string    `json:"type"`
	Data ZuperUser `json:"data"`
}

type UserPayload

type UserPayload struct {
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	Email       string `json:"email"`
	Password    string `json:"password"`
	Designation string `json:"designation"`
	EmpCode     string `json:"emp_code"`
	RoleID      string `json:"role_id"`
}

type UsersResponse

type UsersResponse struct {
	Type         string      `json:"type"`
	Data         []ZuperUser `json:"data"`
	TotalRecords int         `json:"total_records"`
	TotalPages   int         `json:"total_pages"`
	CurrentPage  int         `json:"current_page"`
}

type WorkHour

type WorkHour struct {
	Day           string `json:"day"`
	StartTime     string `json:"start_time"`
	EndTime       string `json:"end_time"`
	WorkMins      int    `json:"work_mins"`
	TrackLocation bool   `json:"track_location"`
	IsEnabled     string `json:"is_enabled"`
}

Create Users.

type ZuperError

type ZuperError struct {
	MessageError string `json:"message"`
	Title        string `json:"title"`
	Type         string `json:"type"`
}

Error Models.

func (*ZuperError) Message

func (e *ZuperError) Message() string

Error implements the uhttp.ErrorResponse interface.

type ZuperUser

type ZuperUser struct {
	UserUID     string      `json:"user_uid"`
	FirstName   string      `json:"first_name"`
	LastName    string      `json:"last_name"`
	Email       string      `json:"email"`
	Designation string      `json:"designation"`
	EmpCode     string      `json:"emp_code"`
	IsActive    bool        `json:"is_active"`
	IsDeleted   bool        `json:"is_deleted"`
	CreatedAt   string      `json:"created_at"`
	UpdatedAt   string      `json:"updated_at"`
	Role        *Role       `json:"role"`
	AccessRole  *AccessRole `json:"access_role"`
}

Users Models.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL