Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OO Freshdesk API Class for Google Apps Script #21

Open
huan opened this issue Dec 17, 2015 · 5 comments
Open

OO Freshdesk API Class for Google Apps Script #21

huan opened this issue Dec 17, 2015 · 5 comments

Comments

@huan
Copy link
Contributor

huan commented Dec 17, 2015

I had just wrote a easy to use OO wrapper: gas-freshdesk.

looks like this:

var API_TOKEN = PropertiesService.getScriptProperties().getProperty('FreshDeskApiToken')
var MyFreshdesk = new Freshdesk('https://mikebo.freshdesk.com', API_TOKEN)

var ticket = new MyFreshdesk.Ticket({
  helpdesk_ticket: {
    description:'A description'
    , subject: 'A subject'
    , email: '[email protected]'
  }
})

ticket.assign(9000658396)
ticket.addNote({
  body: 'Hi tom, Still Angry'
  , private: true
})
ticket.setPriority(2)
ticket.setStatus(2)

ticket.del()
ticket.restore()

Logger.log('ticket #' + ticket.getId() + ' was set!')

hope it could useful and help others for easy start to api freshdesk.

@meteormanaged
Copy link

Hey, looks like you posted your API key.

Mike Kozak
[email protected]:[email protected]

On Dec 17, 2015, at 7:25 AM, Zhuohuan LI <[email protected]mailto:[email protected]> wrote:

I had just wrote a easy to use OO wrapper: gas-freshdeskhttps://githubcom/zixia/gas-freshdesk/

looks like this:

var MyFreshdesk = new Freshdesk('https://mikebofreshdeskcom', 'Jrg0FQNzX3tzuHbiFjYQ')

var ticket = new MyFreshdeskTicket({
helpdesk_ticket: {
description:'A description'
, subject: 'A subject'
, email: 'you@examplecom'
}
})

ticketassign(9000658396)
ticketaddNote({
body: 'Hi tom, Still Angry'
, private: true
})
ticketsetPriority(2)
ticketsetStatus(2)

ticketdel()
ticketrestore()

Loggerlog('ticket #' + ticketgetId() + ' was set!')

hope it could useful and help others for easy start to api freshdesk

Reply to this email directly or view it on GitHubhttps://github.com//issues/21.

@huan
Copy link
Contributor Author

huan commented Dec 17, 2015

@meteormanaged thanks for noticing me that. it's ok, because that key is from my testing account.

I created that account only for unit testing , and also make others to run the sample code easy.

@meteormanaged
Copy link

var API_TOKEN = process.env.API_TOKEN;
var MyFreshdesk = new Freshdesk('https://mikebo.freshdesk.com', API_TOKEN);

i would suggest that it's poor practice to include your token in a script in practice, and better to present it as an environment variable (or though some other mechanism).

@huan
Copy link
Contributor Author

huan commented Dec 17, 2015

@meteormanaged

i agree with you. it's a poor practice. this is only for demo and example. (also used by my test cases).

if use a environment variable, it should looks like this (because it's in gas, not nodejs)

var API_TOKEY = PropertiesService.getScriptProperties().getProperty('FreshDeskApiToken')

@huan
Copy link
Contributor Author

huan commented Dec 17, 2015

@meteormanaged fixed as you suggest. :]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants