Skip to content

Instantly share code, notes, and snippets.

@napster11
Last active February 15, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napster11/c45800f96a6db2ab8c46cd4d28a0e2db to your computer and use it in GitHub Desktop.
Save napster11/c45800f96a6db2ab8c46cd4d28a0e2db to your computer and use it in GitHub Desktop.

Shivam Singh Zendesk Excercise Time Taken: 4-5 Hrs

Project Setup

  1. Golang

(i) Install Golang. (If using docker than can jump directly to Method 2/3 to run the Golang project).
(ii) Download the archive and extract it into /usr/local.
(iii) tar –C /usr/local –xzf go$VERSION.$OS-$ARCH.tar.gz.
(iv) Add /usr/local/go/bin to the PATH environment variable by adding it into $HOME/.profile export PATH=$PATH:/usr/local/go/bin..

(v) Setup workspace by creating a directory $HOME/go and add it as path variable.
(vi) Export GOPATH=$HOME/go in ~/.bash_profile file .     (vii) Create directory structure like $GOPATH/src/github.com , $GOPATH/bin and $GOPATH/pkg and $GOPATH/src/golang.org at $GOPATH.
(viii) Create or clone a subdirectory in src folder with the username of github account (for ex: my username is napster11) like $GOPATH/src/github.com/napster11 . Ex: cd $GOPATH/src && git clone https://github.com/napster11/zendesk.git

  1. React JS.
    (a) Install Node (using homebrew install node) . (b) Clone the project git clone https://github.com/napster11/zenUI.git . (c) Go to the project path and Do “npm install” to install the dependencies.

  2. Run the program.
    Method 1
    (a) Go to project folder like src/github.com/napster11/zendesk and type go get all && go install && go run main.go .   (b) Launch rest client like postman and use the API documentation given below to test the service.
    (c) go to zenUI project path and type “npm run” to run the project.
    (d) Go to browser and type localhost:3000 .

    Method 2 .   (a) Launch Docker Hub in Mac (b) Type docker pull shivam30/shivamzendeskservice (c) Now docker run –t –p 8080:8080 {ImageID} (d) Test the service on Rest client using API documentation or try it using curl request provided below.

    Method 3 . (a)     Go to the path of Dockerfile in project folder.
    (b) Type docker build –t zendesk .
    (c) Type docker run –t –p 8080:8080 zendesk.
    (d) Test the service on Rest client.

UI Flow: .

  1. Go to localhost:3000 and type username (email ID in my case) and password.  

  2. Instead of password can use auth_token but for this need to append/token in username.

  3. I’m using first half of the email address to get the account name and appending it in the base URL like singh782@umn.edu is email address and API endpoint base for zendesk API is https://singh782.zendesk.com/ .

  4. Returns List of tickets with Ticket ID, Ticket Status, Description, Created_At and Last Updated_At attributes.

Code Flow: .

  1. BootRouter function in zendeskService/zendeskRouter.go starts the service on port 8080 using mux library.
  2. getTicketList in zendeskService/zendeskHandler.go is the handler function which will return the response.
  3. Test cases are written in zendeskHandler_test.go . a. First test case to check the happy path.
    b. Second test to check if ticket list is empty or not.
    c. Third test case to check if authentication is mandatory to access the API or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment