zendesk

package module
v0.0.0-...-421aa67 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

Zendesk API

This API is ready to send request for Users and Tickets

How to use?

Configuration

Update the configuration.yml file inside config folder:

domain: DOMAIN
email: EMAIL
password: PASSWORD
token: TOKEN

The service uses API token to communicate with Zendesk.

Connecting with Zendesk API

import "github.com/hellofresh/zendesk-go"

func main() {
    client, _ := zendesk.FromEnv(
        zendesk.LoadConfiguration("./config/configuration.yml"),
    )
}

Basic

user := zendesk.User {
    Id: [id],
    Name: [name],
    Email: [email],
}

client, _ := zendesk.FromEnv(
    zendesk.LoadConfiguration("./config/configuration.yml"),
)

u, err := client.ZendeskApi().CreateOrUpdateUser(user)

if err != nil {
    log.Println(err)
} else {
    log.Println(u)
}

User functions available

GetUser

Return the user

client.ZendeskApi().GetUser(1)
GetUsers

Return the list of all users

client.ZendeskApi().GetZendeskApi()
GetUsersByGroup

Return the list of all users in a group

client.ZendeskApi().GetUsersByGroup(4)
CreateOrUpdateUser

Create or update a user

client.ZendeskApi().CreateOrUpdateUser(user)
CreateUser

Create a new user

client.ZendeskApi().CreateUser(user)
UpdateUser

Update an existing user

client.ZendeskApi().UpdateUser(user)
DeleteUser

Delete an existing user

client.ZendeskApi().DeleteUser(1)

Ticket function available

GetTicket

Return the ticket

client.ZendeskApi().GetTicket(1)
GetTickets

Return the list of all tickets

client.ZendeskApi().GetTickets()
GetRecentTickets

Return the recent tickets

client.ZendeskApi().GetRecentTickets()
GetTicketsFromOrganization

Return the tickets from an organization

client.ZendeskApi().GetTicketsFromOrganization(10)
GetManyTickets

Return a list of tickets

client.ZendeskApi().GetManyTickets(int[]{1, 2, 3, 5})
GetRequestedTicketsFromUser

Return the tickets requests by an user

client.ZendeskApi().GetRequestedTicketsFromUser(2)
GetCcdTicketsFromUser
client.ZendeskApi().GetCcdTicketsFromUser(2)
GetAssignedTicketsFromUser

Return the tickets assigned from user

client.ZendeskApi().GetAssignedTicketsFromUser(2)
CreateTicket

Create a new ticket

client.ZendeskApi().CreateTicket(ticket)
UpdateTicket

Update a ticket

client.ZendeskApi().UpdateTicket(ticket)
UpdateTicketMarkAsSpam

Update a ticket to mark as spam

client.ZendeskApi().UpdateTicketMarkAsSpam(1)
DeleteTicket

Delete an existing ticket

client.ZendeskApi().DeleteTicket(1)

License

Copyright (C) 2016 HelloFresh SE

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct{}

type Client

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

func FromToken

func FromToken(config ZendeskConfiguration) Client

func (Client) Ticket

func (c Client) Ticket() TicketApiHandler

func (Client) User

func (c Client) User() UserApiHandler

type Job

type Job struct {
	JobStatus `json:"job_status,omitempty"`
}

type JobStatus

type JobStatus struct {
	Id       string `json:"id,omitempty"`
	Url      string `json:"url,omitempty"`
	Total    string `json:"total,omitempty"`
	Progress string `json:"progress,omitempty"`
	Status   string `json:"status,omitempty"`
	Message  string `json:"mesage,omitempty"`
	Results  string `json:"results,omitempty"`
}

type ManyUsers

type ManyUsers struct {
	Users []User
}

func (*ManyUsers) AppendUsers

func (users *ManyUsers) AppendUsers(user User) []User

type MultipleTicket

type MultipleTicket struct {
	Response []Ticket `json:"tickets"`
}

type MultipleUser

type MultipleUser struct {
	Response []User `json:"users"`
}

type SingleTicket

type SingleTicket struct {
	Response Ticket `json:"ticket"`
}

type SingleUser

type SingleUser struct {
	Response User `json:"user"`
}

type Ticket

type Ticket struct {
	Id                  int      `json:"id,omitempty"`
	Url                 string   `json:"url,omitempty"`
	ExternalId          string   `json:"external_id,omitempty"`
	Type                string   `json:"type,omitempty"`
	Subject             string   `json:"subject,omitempty"`
	RawSubject          string   `json:"raw_subject,omitempty"`
	Description         string   `json:"description,omitempty"`
	Priority            string   `json:"priority,omitempty"`
	Status              string   `json:"status,omitempty"`
	Recipient           string   `json:"recipient,omitempty"`
	RequesterId         int      `json:"requester_id,omitempty"`
	SubmitterId         int      `json:"submitter_id,omitempty"`
	AssigneeId          int      `json:"assignee_id,omitempty"`
	OrganizationId      int      `json:"organization_id,omitempty"`
	GroupId             int      `json:"group_id,omitempty"`
	CollaboratorsId     []int    `json:"collaborators_id,omitempty"`
	ForumTopicId        int      `json:"forum_topic_id,omitempty"`
	ProblemId           int      `json:"problem_id,omitempty"`
	HasIncidents        bool     `json:"has_incidents,omitempty"`
	DueAt               string   `json:"due_at,omitempty"`
	Tags                []string `json:"tags,omitempty"`
	Via                 *Via     `json:"via,omitempty"`
	CustomFields        []string `json:"custom_fields,omitempty"`
	SatisfactionRating  []string `json:"satisfaction_rating,omitempty"`
	SharingAgreementIds []int    `json:"sharing_agreement_ids,omitempty"`
	FollowupIds         []int    `json:"followup_ids,omitempty"`
	TicketFormId        int      `json:"ticket_form_id,omitempty"`
	BrandId             int      `json:"brand_id,omitempty"`
	CreatedAt           string   `json:"created_at,omitempty"`
	UpdatedAt           string   `json:"updated_at,omitempty"`
}

type TicketApiHandler

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

func (TicketApiHandler) Create

func (t TicketApiHandler) Create(v Ticket) (Ticket, error)

func (TicketApiHandler) CreateOrUpdate

func (t TicketApiHandler) CreateOrUpdate(v Ticket) (Ticket, error)

func (TicketApiHandler) CreateOrUpdateMany

func (t TicketApiHandler) CreateOrUpdateMany(v []Ticket) (Ticket, error)

func (TicketApiHandler) Delete

func (t TicketApiHandler) Delete(id int) (int, error)

func (TicketApiHandler) GetAll

func (t TicketApiHandler) GetAll() ([]Ticket, error)

func (TicketApiHandler) GetById

func (t TicketApiHandler) GetById(id int) (Ticket, error)

func (TicketApiHandler) Update

func (t TicketApiHandler) Update(v Ticket) (Ticket, error)

type User

type User struct {
	Id                  int                    `json:"id,omitempty"`
	Url                 string                 `json:"url,omitempty"`
	Name                string                 `json:"name,omitempty"`
	ExternalId          string                 `json:"external_id,omitempty"`
	Alias               string                 `json:"alias,omitempty"`
	CreatedAt           string                 `json:"created_at,omitempty"`
	UpdatedAt           string                 `json:"updated_at,omitempty"`
	Active              bool                   `json:"active,omitempty"`
	Verified            bool                   `json:"verified,omitempty"`
	Shared              bool                   `json:"shared,omitempty"`
	SharedAgent         bool                   `json:"shared_agent,omitempty"`
	Locale              string                 `json:"locale,omitempty"`
	LocaleId            int                    `json:"locale_id,omitempty"`
	TimeZone            string                 `json:"time_zone,omitempty"`
	LastLoginAt         string                 `json:"last_login_at,omitempty"`
	Email               string                 `json:"email,omitempty"`
	Phone               string                 `json:"phone,omitempty"`
	Signature           string                 `json:"signature,omitempty"`
	Details             string                 `json:"details,omitempty"`
	Notes               string                 `json:"notes,omitempty"`
	OrganizationId      int                    `json:"organization_id,omitempty"`
	Role                string                 `json:"role,omitempty"`
	CustomRoleId        string                 `json:"custom_role_id,omitempty"`
	Moderator           bool                   `json:"moderator,omitempty"`
	TicketRestriction   string                 `json:"ticket_restriction,omitempty"`
	OnlyPrivateComments bool                   `json:"only_private_comments,omitempty"`
	Tags                []string               `json:"tags,omitempty"`
	Suspended           bool                   `json:"suspended,omitempty"`
	RestrictedAgent     bool                   `json:"restricted_agent,omitempty"`
	Photo               *Attachment            `json:"photo,omitempty"`
	UserFields          map[string]interface{} `json:"user_fields,omitempty"`
}

func (*User) FormatPhone

func (u *User) FormatPhone(country string)

type UserApiHandler

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

func (UserApiHandler) Create

func (u UserApiHandler) Create(v User) (User, error)

func (UserApiHandler) CreateOrUpdate

func (u UserApiHandler) CreateOrUpdate(v User) (User, error)

func (UserApiHandler) CreateOrUpdateMany

func (u UserApiHandler) CreateOrUpdateMany(v []User) (Job, error)

func (UserApiHandler) Delete

func (u UserApiHandler) Delete(id int) (int, error)

func (UserApiHandler) GetAll

func (u UserApiHandler) GetAll() ([]User, error)

func (UserApiHandler) GetById

func (u UserApiHandler) GetById(id int) (User, error)

func (UserApiHandler) Update

func (u UserApiHandler) Update(v User) (User, error)

type Via

type Via struct{}

type ZendeskApi

type ZendeskApi interface {
	GetById(id int) (interface{}, error)
	GetAll() ([]interface{}, error)
	Create(v interface{}) (interface{}, error)
	CreateOrUpdate(v interface{}) (interface{}, error)
	CreateOrUpdateMany(v []interface{}) (interface{}, error)
	Update(v interface{}) (interface{}, error)
	Delete(id int) (int, error)
	// contains filtered or unexported methods
}

type ZendeskConfiguration

type ZendeskConfiguration struct {
	ApiVersion string `yaml:"api_version"`
	Domain     string `yaml:"domain"`
	Email      string `yaml:"email"`
	Token      string `yaml:"token"`
	Password   string `yaml:"password"`
}

func LoadConfiguration

func LoadConfiguration(path string) ZendeskConfiguration

Jump to

Keyboard shortcuts

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