teamtailorgo

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 14 Imported by: 0

README

teamtailorgo

Connection to the TeamTailor API (partial)

Updates in V2
  • Switched to go modules
  • Improved error handling
  • Added tests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthorization

func CheckAuthorization(token string) error

CheckAuthorization checks token validity and if it has the correct permissions TODO: Also check if permissions are correct, right now it only checks Reads and not Write

func SetUpTeamTailorTest

func SetUpTeamTailorTest()

func UnauthorizedError

func UnauthorizedError(status int) error

Types

type Authorization

type Authorization interface {
	CheckAuthorization(h http.Handler) http.Handler
}

type Candidate

type Candidate struct {
	ID           string   `json:"-" jsonapi:"primary,candidates"`
	Email        string   `json:"email" jsonapi:"attr,email"`
	Connected    bool     `json:"connected" jsonapi:"attr,connected"`
	Created      string   `json:"created-at" jsonapi:"attr,created-at"`
	Firstname    string   `json:"first-name" jsonapi:"attr,first-name"`
	Lastname     string   `json:"last-name" jsonapi:"attr,last-name"`
	LinkedinUID  string   `json:"linkedin-uid" jsonapi:"attr,linkedin-uid"`
	LinkedinURL  string   `json:"linkedin-url" jsonapi:"attr,linkedin-url"`
	FacebookUID  string   `json:"facebook-id" jsonapi:"attr,facebook-id"`
	Phone        string   `json:"phone" jsonapi:"attr,phone"`
	Picture      string   `json:"picture" jsonapi:"attr,picture"`
	Pitch        string   `json:"pitch" jsonapi:"attr,pitch"`
	Sourced      bool     `json:"sourced" jsonapi:"attr,sourced"`
	Tags         []string `json:"tags" jsonapi:"attr,tags"`
	UpdatedAt    string   `json:"updated-at" jsonapi:"attr,updated-at"`
	ReferringURL string   `json:"referring-url" jsonapi:"attr,referring-url"`
	Resume       string   `json:"resume" jsonapi:"attr,resume"`
	Unsubscribed bool     `json:"unsubscribed" jsonapi:"attr,unsubscribed"`
}

func (Candidate) GetID

func (c Candidate) GetID() string

func (*Candidate) SetID

func (c *Candidate) SetID(ID string) error

func (*Candidate) SetToOneReferenceID

func (c *Candidate) SetToOneReferenceID(name, ID string) error

JSON API INTERFACE FUNCTIONS

type CandidateConverted

type CandidateConverted struct {
	Type      string            `json:"type"`
	Candidate *CandidateRequest `json:"attributes"`
}

type CandidateJSONApi

type CandidateJSONApi struct {
	Data *CandidateConverted `json:"data"`
}

type CandidateRequest

type CandidateRequest struct {
	Email       string    `json:"email" jsonapi:"attr, email"`
	Connected   bool      `json:"connected" jsonapi:"attr,connected"`
	Created     time.Time `json:"created-at" jsonapi:"attr, created-at"`
	Firstname   string    `json:"first-name" jsonapi:"attr, first-name"`
	Lastname    string    `json:"last-name" jsonapi:"attr, last-name"`
	LinkedinUID string    `json:"linkedin-uid" jsonapi:"attr, linkedin-uid"`
	LinkedinURL string    `json:"linkedin-url" jsonapi:"attr, linkedin-url"`
	FacebookUID string    `json:"facebook-id" jsonapi:"attr, facebook-id"`
	Phone       string    `json:"phone" jsonapi:"attr, phone"`
	Picture     string    `json:"picture" jsonapi:"attr, picture"`
	Pitch       string    `json:"pitch" jsonapi:"attr, pitch"`
	Sourced     bool      `json:"sourced" jsonapi:"attr, sourced"`
	Tags        []string  `json:"tags" jsonapi:"attr, tags"`
	UpdatedAt   time.Time `json:"updated-at" jsonapi:"attr, updated-at"`
}

func (CandidateRequest) GetID

func (c CandidateRequest) GetID() string

type CandidateRequestResume

type CandidateRequestResume struct {
	Email       string    `json:"email" jsonapi:"email"`
	Connected   bool      `json:"connected" jsonapi:"connected"`
	Created     time.Time `json:"created-at" jsonapi:"created-at"`
	Firstname   string    `json:"first-name" jsonapi:"first-name"`
	Lastname    string    `json:"last-name" jsonapi:"last-name"`
	LinkedinUID string    `json:"linkedin-uid" jsonapi:"linkedin-uid"`
	LinkedinURL string    `json:"linkedin-url" jsonapi:"linkedin-url"`
	FacebookUID string    `json:"facebook-id" jsonapi:"facebook-id"`
	Phone       string    `json:"phone" jsonapi:"phone"`
	Picture     string    `json:"picture" jsonapi:"picture"`
	Pitch       string    `json:"pitch" jsonapi:"pitch"`
	Resume      string    `json:"resume" jsonapi:"resume"`
	Sourced     bool      `json:"sourced" jsonapi:"sourced"`
	Tags        []string  `json:"tags" jsonapi:"tags"`
	UpdatedAt   time.Time `json:"updated-at" jsonapi:"updated-at"`
}

func (CandidateRequestResume) GetID

func (c CandidateRequestResume) GetID() string

type CandidateResumeConverted

type CandidateResumeConverted struct {
	Type      string                  `json:"type"`
	Candidate *CandidateRequestResume `json:"attributes"`
}

type CandidateResumeJSONApi

type CandidateResumeJSONApi struct {
	Data *CandidateResumeConverted `json:"data"`
}

type ErrorStruct

type ErrorStruct struct {
	StatusCode int
	Message    string
}

func (ErrorStruct) Error

func (e ErrorStruct) Error() string

type JA

type JA struct {
	Data JAData `json:"data"`
}

type JAAttributes

type JAAttributes struct {
	Sourced bool `json:"sourced"`
}

type JACandidate

type JACandidate struct {
	Data JACandidateData `json:"data"`
}

type JACandidateData

type JACandidateData struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

type JAData

type JAData struct {
	Type          string          `json:"type"`
	Attributes    JAAttributes    `json:"attributes"`
	Relationships JARelationships `json:"relationships"`
}

type JAJob

type JAJob struct {
	Data JAJobData `json:"data"`
}

type JAJobData

type JAJobData struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

type JARelationships

type JARelationships struct {
	Candidate JACandidate `json:"candidate"`
	Job       JAJob       `json:"job"`
}

type Job

type Job struct {
	ID          string
	Type        string   `json:"type"`
	Body        string   `json:"body"`
	EndDate     string   `json:"end-date"`
	HumanStatus string   `json:"human-status"`
	Internal    bool     `json:"internal"`
	Pinned      bool     `json:"pinned"`
	StartDate   string   `json:"start-date"`
	Status      string   `json:"status"`
	Title       string   `json:"title"`
	Tags        []string `json:"tags"`
	Created     string   `json:"created-at"`
}

TODO: Add picture which consists of substrings "standard" and "thumb" or "" if no picture for job

func (Job) GetID

func (j Job) GetID() string

func (*Job) SetID

func (j *Job) SetID(ID string) error

func (Job) SetToOneReferenceID

func (j Job) SetToOneReferenceID(name, ID string) error

type JobApplication

type JobApplication struct {
	ID             string
	Type           string `json: "type"`
	Created        string `json:"created-at"`
	CoverLetter    string `json:"cover-letter"`
	UpdatedAt      string `json:"updated-at"`
	RejectedAt     string `json:"rejected-at"`
	ReferringSite  string `json:"referring-site"`
	ReferringURL   string `json:"referring-url"`
	Sourced        bool   `json:"sourced"`
	ChangedStateAt string `json:"changed-stage-at"`
}

func (JobApplication) GetID

func (ja JobApplication) GetID() string

func (JobApplication) GetName

func (ja JobApplication) GetName() string

func (*JobApplication) SetID

func (ja *JobApplication) SetID(ID string) error

func (JobApplication) SetToOneReferenceID

func (ja JobApplication) SetToOneReferenceID(name, ID string) error

type Meta

type Meta struct {
	MetaTags *MetaTags `json:"meta"`
}

Meta is a wrapper for meta tags. Needed in order to Marshal()

type MetaTags

type MetaTags struct {
	RecordCount int `json:"record-count"`
	PageCount   int `json:"page-count"`
}

MetaTags checks how many job objects and how many pages exist in the Teamtailor instance. Used if more than 30 jobs exist for a company.

type Stage

type Stage struct {
	ID               string `json:"-" jsonapi:"primary,stages"`
	Created          string `json:"created-at" jsonapi:"attr,created-at"`
	UpdatedAt        string `json:"updated-at" jsonapi:"attr,updated-at"`
	Name             string `json:"name" jsonapi:"attr,name"`
	StageType        string `json:"stage-type" jsonapi:"attr,stage-type"`
	JobApplicationID string `json:"job-application-id"`
}

type TeamTailor

type TeamTailor struct {
	APIHost    string `json:"api-host" bson:"api-host"`
	Token      string `json:"token" bson:"token"`
	APIversion string `json:"X-Api-Version" bson:"X-Api-Version"`
	HTTPClient *http.Client
}

func NewTeamTailor

func NewTeamTailor(authToken string) (TeamTailor, error)

Create TeamTailor instance

func (TeamTailor) CreateJobApplication

func (t TeamTailor) CreateJobApplication(idjob string, idcand string) (JobApplication, error)

CreateJobApplication

func (TeamTailor) GetAllJobs

func (t TeamTailor) GetAllJobs() ([]Job, error)

GetAllJobs returns all jobs for a company. Used if page count in Teamtailor is greater than one and multiple GET-requests are needed to get all jobs.

func (*TeamTailor) GetCandidate

func (t *TeamTailor) GetCandidate(id string) (Candidate, error)

func GetCandidate

func (*TeamTailor) GetCandidateByEmail

func (t *TeamTailor) GetCandidateByEmail(email string) (*Candidate, error)

func GetCandidateByEmail

func (*TeamTailor) GetCandidates

func (t *TeamTailor) GetCandidates() ([]*Candidate, error)

func GetCandidates

func (TeamTailor) GetFirstJobPage

func (t TeamTailor) GetFirstJobPage() ([]Job, error)

GetFirstJobPage fetches the 30 jobs that are on the first page of Teamtailor response. If there are more than 30 jobs to fetch from Teamtailor, use GetAllJobs().

func (TeamTailor) GetJob

func (t TeamTailor) GetJob(id string) (Job, error)

GetJob

func (TeamTailor) GetJobApplicationStage

func (t TeamTailor) GetJobApplicationStage(id string) (*Stage, error)

GetJobApplicationStage returns the stage of a specific job application containing status in recruitment process

func (*TeamTailor) PostCandidate

func (t *TeamTailor) PostCandidate(c CandidateRequest) (*Candidate, error)

PostCandidate creates and executes a POST-request to the TeamTailor API and returns the resposne body as a []byte

func (*TeamTailor) PostCandidateResume

func (t *TeamTailor) PostCandidateResume(c CandidateRequestResume) (*Candidate, error)

PostCandidateResume executes POST-request with a signedURL to access a candidate's resume

func (*TeamTailor) SetHeaders

func (t *TeamTailor) SetHeaders(r *http.Request)

func SetHeaders

func (*TeamTailor) UpdateCandidate

func (t *TeamTailor) UpdateCandidate(c Candidate) error

type TeamTailorErrorResponse

type TeamTailorErrorResponse struct {
	Errors []struct {
		Title  string `json:"title"`
		Detail string `json:"detail"`
		Code   string `json:"code"`
		Status string `json:"status"`
	} `json:"errors"`
	Meta struct {
		Texts struct {
			Prev string `json:"prev"`
			Next string `json:"next"`
		} `json:"texts"`
	} `json:"meta"`
}

Jump to

Keyboard shortcuts

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