client

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiPathCoursesList            = "/content-discovery/v2/organizations/%s/catalog-content"
	ApiPathLearningActivityReport = "/reporting/v1/organizations/%s/report-requests/learning-activity"
	ApiPathReport                 = "/reporting/v1/organizations/%s/report-requests/%s"
	ApiPathUsersList              = "/user-management/v1/organizations/%s/users"
	BaseApiUrl                    = "https://api.percipio.com"
	HeaderNamePagingRequestId     = "x-paging-request-id"
	HeaderNameTotalCount          = "x-total-count"
	PageSizeDefault               = 1000
	ReportLookBackDefault         = 10 * time.Hour * 24 * 365 // 10 years
)

Variables

This section is empty.

Functions

func GetNextToken

func GetNextToken(
	offset int,
	limit int,
	total int,
	pagingRequestId string,
) string

GetNextToken given a limit, offset, and `pagingRequestId` that were used to fetch _this_ page of data, and total number of resources, return the next pagination token as a string.

func ParsePaginationToken

func ParsePaginationToken(pToken *pagination.Token) (
	int,
	int,
	string,
	error,
)

ParsePaginationToken - takes as pagination token and returns offset, limit, and `pagingRequestId` in that order.

func WithBearerToken

func WithBearerToken(token string) uhttp.RequestOption

WithBearerToken - TODO(marcos): move this function to `baton-sdk`.

Types

type AICCLaunch

type AICCLaunch struct {
	Params string `json:"params"`
	Url    string `json:"url"`
}

type ApprovalManager

type ApprovalManager struct {
	Id             string `json:"id"`
	Email          string `json:"email"`
	ExternalUserId string `json:"externalUserId"`
}

type Associations

type Associations struct {
	Areas              []string           `json:"areas"`
	Subjects           []string           `json:"subjects"`
	Channels           []Channel          `json:"channels"`
	LocalizedChannels  []LocalizedChannel `json:"localizedChannels"`
	LicensedLocales    string             `json:"licensedLocales"`
	Skills             []Skill            `json:"skills"`
	Journeys           []Journey          `json:"journeys"`
	Parent             Parent             `json:"parent"`
	TranslationGroupId string             `json:"translationGroupId"`
}

type Channel

type Channel struct {
	Id    string `json:"id"`
	Link  string `json:"link"`
	Title string `json:"title"`
}

type Characteristics

type Characteristics struct {
	EarnsBadge    bool `json:"earnsBadge"`
	HasAssessment bool `json:"hasAssessment"`
	IsCompliance  bool `json:"isCompliance"`
}

type Client

type Client struct {
	StatusesStore StatusesStore

	ReportStatus ReportStatus
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	baseUrl string,
	organizationId string,
	token string,
) (*Client, error)

func (*Client) GenerateLearningActivityReport

func (c *Client) GenerateLearningActivityReport(
	ctx context.Context,
) (
	*v2.RateLimitDescription,
	error,
)

GenerateLearningActivityReport makes a post request to the API asking it to start generating a report. We'll need to then poll a _different_ endpoint to get the actual report data.

func (*Client) GetCourses

func (c *Client) GetCourses(
	ctx context.Context,
	offset int,
	limit int,
	pagingRequestId string,
) (
	[]Course,
	string,
	int,
	*v2.RateLimitDescription,
	error,
)

GetCourses Given a limit/offset and a pagination token (see below), fetch a page's worth of course data. Returns _five_ values:

  1. the list of courses
  2. the "pagination token", required to get any page but the first.
  3. the total number of courses, so that we don't have to fetch an extra page to confirm there are no more courses.
  4. rate limit data read from headers.
  5. any error

func (*Client) GetLearningActivityReport

func (c *Client) GetLearningActivityReport(
	ctx context.Context,
) (
	*v2.RateLimitDescription,
	error,
)

func (*Client) GetUsers

func (c *Client) GetUsers(
	ctx context.Context,
	offset int,
	limit int,
) (
	[]User,
	int,
	*v2.RateLimitDescription,
	error,
)

GetUsers returns - a page of users - the reported total number of users that match the filter criteria - any ratelimit data - an error.

type ContentType

type ContentType struct {
	Category     string `json:"category"`
	DisplayLabel string `json:"displayLabel"`
	PercipioType string `json:"percipioType"`
	Source       string `json:"source"`
}

type Course

type Course struct {
	AICCLaunch                 AICCLaunch                 `json:"aiccLaunch"`
	AlternateImageUrl          string                     `json:"alternateImageUrl"`
	Associations               Associations               `json:"associations"`
	By                         []string                   `json:"by"`
	Characteristics            Characteristics            `json:"characteristics"`
	Code                       string                     `json:"code"`
	ContentType                ContentType                `json:"contentType"`
	Credentials                Credentials                `json:"credentials"`
	Duration                   string                     `json:"duration"`
	ExpertiseLevels            []string                   `json:"expertiseLevels"`
	Id                         string                     `json:"id"`
	ImageUrl                   string                     `json:"imageUrl"`
	Keywords                   []string                   `json:"keywords"`
	LearningObjectives         []string                   `json:"learningObjectives"`
	Lifecycle                  Lifecycle                  `json:"lifecycle"`
	Link                       string                     `json:"link"`
	LocaleCodes                []string                   `json:"localeCodes"`
	LocalizedMetadata          []LocalizedMetadata        `json:"localizedMetadata"`
	Modalities                 []string                   `json:"modalities"`
	ProviderSpecificAttributes ProviderSpecificAttributes `json:"providerSpecificAttributes"`
	Publication                Publication                `json:"publication"`
	Technologies               []Technology               `json:"technologies"`
	XApiActivityId             string                     `json:"xapiActivityId"`
	XApiActivityTypeId         string                     `json:"xapiActivityTypeId"`
}

type Credentials

type Credentials struct {
	// Continuing Professional Education credits. Possible values include 1.5.
	CpeCredits float64 `json:"cpeCredits"`
	// National Association of State Boards of Accountancy. Seems like a CPA thing.
	NasbaReady bool `json:"nasbaReady"`
	// Professional Development Unit credits. Possible values include 0.75.
	PduCredits float64 `json:"pduCredits"`
}

type CustomAttribute

type CustomAttribute struct {
	Id    string `json:"id"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Journey

type Journey struct {
	Id    string `json:"id"`
	Title string `json:"title"`
	Link  string `json:"link"`
}

type Lifecycle

type Lifecycle struct {
	IncludedFromActivity  bool      `json:"includedFromActivity"`
	LastUpdatedDate       time.Time `json:"lastUpdatedDate"`
	PlannedRetirementDate time.Time `json:"plannedRetirementDate"`
	PublishDate           time.Time `json:"publishDate"`
	RetiredDate           time.Time `json:"retiredDate"`
	Status                string    `json:"status"`
}

type LocalizedChannel

type LocalizedChannel struct {
	Description    string `json:"description"`
	Id             string `json:"id"`
	Link           string `json:"link"`
	LocaleCode     string `json:"localeCode"`
	Title          string `json:"title"`
	XapiActivityId string `json:"xapiActivityId"`
}

type LocalizedMetadata

type LocalizedMetadata struct {
	Description string `json:"description"`
	LocaleCode  string `json:"localeCode"`
	Title       string `json:"title"`
}

type Pagination

type Pagination struct {
	PagingRequestId string `json:"pagingRequestId"`
	Offset          int    `json:"offset"`
}

type Parent

type Parent struct {
	Id    string `json:"id"`
	Link  string `json:"link"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type ProviderSpecificAttributes

type ProviderSpecificAttributes struct {
	ProviderAssetId   string `json:"providerAssetId"`
	SkillCourseNumber string `json:"skillCourseNumber"`
}

type Publication

type Publication struct {
	CopyrightYear int    `json:"copyrightYear"`
	Isbn          string `json:"isbn"`
	Publisher     string `json:"publisher"`
}

type Report

type Report []ReportEntry

type ReportConfigurations

type ReportConfigurations struct {
	Audience                string               `json:"audience,omitempty"`
	ContentType             string               `json:"contentType,omitempty"`
	CsvPreferences          ReportCsvPreferences `json:"csvPreferences,omitempty"`
	Encrypt                 bool                 `json:"encrypt,omitempty"`
	End                     time.Time            `json:"end,omitempty"`
	FileMask                string               `json:"fileMask,omitempty"`
	FolderName              string               `json:"folderName,omitempty"`
	FormatType              string               `json:"formatType,omitempty"`
	IncludeMillisInFilename bool                 `json:"includeMillisInFilename,omitempty"`
	IsFileRequiredInSftp    bool                 `json:"isFileRequiredInSftp,omitempty"`
	IsPgpFileExtnNotReqrd   bool                 `json:"isPgpFileExtnNotReqrd,omitempty"`
	Locale                  string               `json:"locale,omitempty"`
	Mapping                 string               `json:"mapping,omitempty"`
	Plugin                  string               `json:"plugin,omitempty"`
	SftpId                  string               `json:"sftpId,omitempty"`
	Sort                    ReportSort           `json:"sort,omitempty"`
	Start                   time.Time            `json:"start,omitempty"`
	Status                  string               `json:"status,omitempty"`
	Template                string               `json:"template,omitempty"`
	TimeFrame               string               `json:"timeFrame,omitempty"`
	TransformName           string               `json:"transformName,omitempty"`
	Zip                     bool                 `json:"zip,omitempty"`
}

type ReportCsvPreferences

type ReportCsvPreferences struct {
	ColumnDelimiter    string `json:"columnDelimiter,omitempty"`
	Header             bool   `json:"header,omitempty"`
	HeaderForNoRecords bool   `json:"headerForNoRecords,omitempty"`
	RowDelimiter       string `json:"rowDelimiter,omitempty"`
}

type ReportEntry

type ReportEntry struct {
	Audience             string    `json:"audience"`
	BusinessUnit         string    `json:"businessUnit"`
	CompletedDate        time.Time `json:"completedDate"`
	ContentTitle         string    `json:"contentTitle"`
	ContentType          string    `json:"contentType"`
	ContentUUID          string    `json:"contentUuid"`
	CostCenterCode       string    `json:"costCenterCode"`
	CountryName          string    `json:"countryName"`
	DepartmentCode       string    `json:"departmentCode"`
	DepartmentOwner      string    `json:"departmentOwner"`
	DeptName             string    `json:"deptName"`
	DirectManagerName    string    `json:"directManagerName"`
	Division             string    `json:"division"`
	DivisionCode         string    `json:"divisionCode"`
	DivisionOwner        string    `json:"divisonOwner"` // [SIC]
	DurationHms          string    `json:"durationHms"`
	EmailAddress         string    `json:"emailAddress"`
	EmployeeClass        string    `json:"employeeClass"`
	EmployeeId           string    `json:"employeeId"`
	EstimatedDurationHms string    `json:"estimatedDurationHms"`
	FirstAccess          time.Time `json:"firstAccess"`
	FirstName            string    `json:"firstName"`
	Geo                  string    `json:"geo"`
	HireDate             string    `json:"hireDate"`
	HrbpOwner            string    `json:"hrbpOwner"`
	IsAManager           string    `json:"isAManager"`
	LanguageCode         string    `json:"languageCode"`
	LastName             string    `json:"lastName"`
	ManagerEmail         string    `json:"managerEmail"`
	ManagerId            string    `json:"managerId"`
	Status               string    `json:"status"`
	UserId               string    `json:"userId"`
	UserStatus           string    `json:"userStatus"`
	UserUUID             string    `json:"userUuid"`
}

type ReportSort

type ReportSort struct {
	Field string `json:"field,omitempty"`
	Order string `json:"order,omitempty"`
}

type ReportStatus

type ReportStatus struct {
	Id     string `json:"id"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

type Skill

type Skill struct {
	LocaleCode string   `json:"localeCode"`
	Skills     []string `json:"skills"`
}

type StatusesStore

type StatusesStore map[string]map[string]string

func (StatusesStore) Get

func (r StatusesStore) Get(courseId string) map[string]string

Get - return a mapping of user IDs to course completion status. TODO(marcos) Should we use enums instead?

func (StatusesStore) Load

func (r StatusesStore) Load(report *Report) error

Load given a Report (which again, can be on the order of 1 GB), and just create a mapping of course IDs to a mapping of user IDs to statuses. e.g.:

{
  "00000000-0000-0000-0000-000000000000": {
    "00000000-0000-0000-0000-000000000001": "in_progress",
    "00000000-0000-0000-0000-000000000002": "completed",
  },
}

type Technology

type Technology struct {
	Title   string `json:"title"`
	Version string `json:"version"`
}

type User

type User struct {
	Id                             string            `json:"id"`
	ApprovalManager                ApprovalManager   `json:"approvalManager"`
	CustomAttributes               []CustomAttribute `json:"customAttributes"`
	Email                          string            `json:"email"`
	ExternalUserId                 string            `json:"externalUserId"`
	FirstName                      string            `json:"firstName"`
	HasCoaching                    bool              `json:"hasCoaching"`
	HasEnterpriseCoaching          bool              `json:"hasEnterpriseCoaching"`
	HasEnterpriseCoachingDashboard bool              `json:"hasEnterpriseCoachingDashboard"`
	IsActive                       bool              `json:"isActive"`
	IsInstructor                   bool              `json:"isInstructor"`
	JobTitle                       string            `json:"jobTitle"`
	LastName                       string            `json:"lastName"`
	LoginName                      string            `json:"loginName"`
	Role                           string            `json:"role"`
	UpdatedAt                      string            `json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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