Client app for using the Desk.com API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib
public
spec
test
vendor/assets
.gitignore
Bowerfile
Gemfile
Gemfile.lock
README.rdoc
Rakefile
config.ru

README.rdoc

Desk.com API Client

serene-brushlands-8690.herokuapp.com

Leverages the Desk.com API to help you aggregate your customer support cases, allows custom views and labelling to help you get organized with your team.

Built with Ruby 2.2.0, Ruby on Rails 4.2.0, and Angular.js 1.3.14.

Installation

1. Install needed Ruby dependencies and libraries: 

$ bundle install 

2. Configure database settings and environment variables for Ruby on Rails. This client uses the {{Desk.com Ruby Gem}}[https://github.com/chriswarren/desk] to make authenticated requests with their API. Sign up for Desk.com to get your API keys, as mentioned in their {{documentation here.}}[http://dev.desk.com/API/using-the-api]. API configs are set in the following file:

{{/config/initializers/desk_api.rb}}[https://github.com/sayem/desk/blob/master/config/initializers/desk_api.rb]

Set your OAuth API credentials as secrets in config/secrets.yml for development and as environment variables for production, as mentioned here for Heroku: https://devcenter.heroku.com/articles/config-vars

3. Install Memcache for use with Dalli and Ruby on Rails caching, as mentioned here: https://devcenter.heroku.com/articles/memcachier#ruby. Cache settings are stored in the environment files ("config.cache_store = :dalli_store"). 

4. Install npm (Node Package Manager) and {{Bower}}[https://github.com/bower/bower] for front-end libraries used in this application

5. Similar to how the Gemfile is used to specify Rails dependencies, the Bowerfile, also located in the root of the application, lists front-end libraries that are installed via bower. Just update Bowerfile and then do:

rake -T bower:install

That will install our assets in {{/vendor/assets/bower_components}}[https://github.com/sayem/desk/tree/master/vendor/assets/bower_components], so that they can be compiled by the Rails asset pipeline and Sprockets.

6. To use them hower, you'll then need to specifiy the library within the application, which we do in:

{{app/assets/javascripts/application.js}}[https://github.com/sayem/desk/blob/master/app/assets/javascripts/application.js]

Note that the full-path until the file in the bower-components folder needs to be specified (e.g. angular.js is within the angular folder in bower_components, so we "require angular/angular" in application.js.

7. And for Ruby unit-testing and code coverage, install RSpec:

rails generate rspec:install

Then "rspec spec" will run all of the tests located in the /spec folder of the application.

Application Structure

This client routes a REST API via Ruby on Rails and the Desk.com API gem, which is then rendered on an Angular.js front-end using templates.

- config/routes.rb specifies the API routing and resources we use (Cases, Filters, and Labels). 
- The API end-points are set via the controllers in app/controllers/api/v1/ and render .json to the client
- {{Jbuilder}}[https://github.com/rails/jbuilder] is used for fragment caching and defining attributes in the end-points, which can be seen in the {{views directory}}[https://github.com/sayem/desk/tree/master/app/views/api/v1]
- The controller routes requests to those Jbuilder JSON templates, from data passed from the models which are in: app/models
- We're not persisting API requests from the Desk Ruby gem, so these tableless models are being used as a wrapper for the gem and for caching

All the major view components and front-end logic are handled via Angular.js, app/views/layouts/application.html.erb and views/home/index.html.erb simply initiliaze our Angular views. All this is happening in app/assets/javascripts.

There, application.js requires the front-end dependencies, as mentioned, and loads the angular app in the adjacent folder, which has logic for handling routes, controllers, and rendered templates. app.js for Angular is similar to config/routes.rb for Ruby, this passes controller actions and templates to different url requests. All the templates used by Angular are located in app/assets/javascripts/templates. 

And finally, for styling, SASS/CSS files are in app/assets/stylesheets - application.css.scss has all the custom styles for the current app.

This Angular app uses {{Restangular}}[https://github.com/mgonto/restangular] as a service to seamlessly handle the REST resources from our back-end.

LICENSE

(The MIT License)

Copyright © 2015:

Sayem Khan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.