desk_api_v2 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
 - data/.gitignore +1 -0
 - data/CHANGELOG.md +0 -0
 - data/Gemfile +3 -0
 - data/LICENSE +24 -0
 - data/README.md +27 -0
 - data/Rakefile +39 -0
 - data/desk_api_v2.gemspec +27 -0
 - data/lib/desk.rb +11 -0
 - data/lib/desk/api/articles.rb +34 -0
 - data/lib/desk/api/cases.rb +47 -0
 - data/lib/desk/api/customers.rb +36 -0
 - data/lib/desk/api/groups.rb +30 -0
 - data/lib/desk/api/modules/creatable.rb +15 -0
 - data/lib/desk/api/modules/deletable.rb +11 -0
 - data/lib/desk/api/modules/listable.rb +16 -0
 - data/lib/desk/api/modules/searchable.rb +13 -0
 - data/lib/desk/api/topics.rb +25 -0
 - data/lib/desk/api/translations.rb +24 -0
 - data/lib/desk/article.rb +7 -0
 - data/lib/desk/case.rb +7 -0
 - data/lib/desk/client.rb +39 -0
 - data/lib/desk/collection.rb +17 -0
 - data/lib/desk/connection.rb +71 -0
 - data/lib/desk/customer.rb +7 -0
 - data/lib/desk/entity.rb +7 -0
 - data/lib/desk/error.rb +17 -0
 - data/lib/desk/filter.rb +7 -0
 - data/lib/desk/group.rb +7 -0
 - data/lib/desk/message.rb +7 -0
 - data/lib/desk/response/error_handling.rb +30 -0
 - data/lib/desk/topic.rb +7 -0
 - data/lib/desk/translation.rb +7 -0
 - data/lib/desk/user.rb +7 -0
 - data/spec/desk/api/articles_spec.rb +135 -0
 - data/spec/desk/api/cases_spec.rb +181 -0
 - data/spec/desk/api/customers_spec.rb +135 -0
 - data/spec/desk/api/groups_spec.rb +98 -0
 - data/spec/desk/api/topics_spec.rb +98 -0
 - data/spec/desk/api/translations_spec.rb +92 -0
 - data/spec/desk/collection_spec.rb +22 -0
 - data/spec/desk/connection_spec.rb +95 -0
 - data/spec/fixtures/article.json +39 -0
 - data/spec/fixtures/articles.json +101 -0
 - data/spec/fixtures/case.json +40 -0
 - data/spec/fixtures/cases.json +105 -0
 - data/spec/fixtures/customer.json +60 -0
 - data/spec/fixtures/customers.json +143 -0
 - data/spec/fixtures/group.json +9 -0
 - data/spec/fixtures/group_filters.json +53 -0
 - data/spec/fixtures/group_users.json +71 -0
 - data/spec/fixtures/groups.json +42 -0
 - data/spec/fixtures/message.json +26 -0
 - data/spec/fixtures/topic.json +23 -0
 - data/spec/fixtures/topics.json +69 -0
 - data/spec/fixtures/translation.json +28 -0
 - data/spec/fixtures/translations.json +79 -0
 - data/spec/spec_helper.rb +17 -0
 - metadata +200 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                Y2JlYzYyMDg5NzcwZWRhMjc3M2JmZDY5OTkyNDBkNGZhN2UyMzk5ZQ==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                YWU0Yzk0YzhiZWQ0MDUyN2Q3MTk5NzczMDJjNjgzNDJjMzJmNjA2Ng==
         
     | 
| 
      
 7 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                NjhjYjg1MDA0YTE2Y2NjMTZlNmQ5NTk0M2ZkMTJmYjE1ZjYxYjMxYjVjNWNm
         
     | 
| 
      
 10 
     | 
    
         
            +
                MzhjNGRkOGVjZWFhMGRmNzY4NzY3MDM0N2JkMjFkNTc3NDBkYTc1ODBiNDUx
         
     | 
| 
      
 11 
     | 
    
         
            +
                NTkzOTIyMzJiMGQzZTc5N2YxMTA5YzIxMTAwOGMzNDMxOTVmYjY=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                YTI1OGQzZTQ1OWYzZjFiZDgwNWY5MjlhNGZjYTEyNjllYzUyNzM0MDE0NDA1
         
     | 
| 
      
 14 
     | 
    
         
            +
                MmNlMTQyODcwNTkyZDEyNGU5YWM2ODMzODYxZjEwMjA5OGY3MzQzYjE5ODU0
         
     | 
| 
      
 15 
     | 
    
         
            +
                MWUxMzNmZThmNzU3ZTc4NGVjZWVkMTNkN2ZkNjcwOTZhOGQ2NTU=
         
     | 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gemfile.lock
         
     | 
    
        data/CHANGELOG.md
    ADDED
    
    | 
         
            File without changes
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Copyright (c) 2013 Justin Powers
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 7 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 8 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 9 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 10 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 11 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 14 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 17 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 18 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 19 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 21 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         
     | 
| 
      
 22 
     | 
    
         
            +
            SOFTWARE.
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            A simple ruby interface to Desk.com
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 4 
     | 
    
         
            +
                gem install desk_api_v2
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Oauth (recommended):
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                client = Desk::Client.new(site: "my-site-name", consumer_key: "consumer-key", consumer_secret: "consumer-secret", token: "token", token_secret: "token_secret")
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Basic Auth:
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                client = Desk::Client.new(site: "my-site-name", email: "email@example.com", password: "mypassword")
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Example usage:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                client.cases.all
         
     | 
| 
      
 19 
     | 
    
         
            +
                client.cases.show(1234)
         
     | 
| 
      
 20 
     | 
    
         
            +
                client.cases.create(data)
         
     | 
| 
      
 21 
     | 
    
         
            +
                client.cases.update(1234, data)
         
     | 
| 
      
 22 
     | 
    
         
            +
                client.article.all
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            ## To do
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Add more endpoints  
         
     | 
| 
      
 27 
     | 
    
         
            +
            Pagination
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            begin
         
     | 
| 
      
 4 
     | 
    
         
            +
              require "bundler"
         
     | 
| 
      
 5 
     | 
    
         
            +
              Bundler.setup
         
     | 
| 
      
 6 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 7 
     | 
    
         
            +
              $stderr.puts "You need to have Bundler installed to be able build this gem."
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            gemspec = eval(File.read(Dir["*.gemspec"].first))
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            desc "Validate the gemspec"
         
     | 
| 
      
 13 
     | 
    
         
            +
            task :gemspec do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gemspec.validate
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            desc "Build gem locally"
         
     | 
| 
      
 18 
     | 
    
         
            +
            task :build => :gemspec do
         
     | 
| 
      
 19 
     | 
    
         
            +
              system "gem build #{gemspec.name}.gemspec"
         
     | 
| 
      
 20 
     | 
    
         
            +
              FileUtils.mkdir_p "pkg"
         
     | 
| 
      
 21 
     | 
    
         
            +
              FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            desc "Install gem locally"
         
     | 
| 
      
 25 
     | 
    
         
            +
            task :install => :build do
         
     | 
| 
      
 26 
     | 
    
         
            +
              system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            desc "Clean automatically generated files"
         
     | 
| 
      
 30 
     | 
    
         
            +
            task :clean do
         
     | 
| 
      
 31 
     | 
    
         
            +
              FileUtils.rm_rf "pkg"
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            Rake::TestTask.new do |t|
         
     | 
| 
      
 35 
     | 
    
         
            +
              t.pattern = "spec/**/*_spec.rb"
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            desc "Run Tests"
         
     | 
| 
      
 39 
     | 
    
         
            +
            task :default => :test
         
     | 
    
        data/desk_api_v2.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
              s.name                     = "desk_api_v2"
         
     | 
| 
      
 3 
     | 
    
         
            +
              s.version                  = "0.0.1"
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.platform                 = Gem::Platform::RUBY
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.authors                  = ["Justin Powers"]
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.email                    = ["justinspowers@gmail.com"]
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.homepage                 = "http://github.com/dangerp/desk"
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.summary                  = "A ruby interface to the Desk.com API V2"
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.description              = s.summary
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.licenses              = ['MIT']
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.required_ruby_version = '>= 1.9.2'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              s.required_rubygems_version = ">= 1.3.6"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              s.require_path = 'lib'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_dependency "faraday_middleware", "~> 0.9.0"
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_dependency "activesupport", "~> 3.2.13"
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_development_dependency "pry", "~> 0.9.12"
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_development_dependency "rake", "~> 10.0.4"
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.add_development_dependency "webmock", "~> 1.11.0"
         
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency "minitest", "~> 3.5.0"
         
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_development_dependency "minitest-reporters", "~> 0.14.20"
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/desk.rb
    ADDED
    
    | 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $: << File.expand_path('../lib', File.dirname(__FILE__))
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/client'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/collection'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'desk/entity'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'desk/case'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'desk/article'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'desk/customer'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'desk/topic'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'desk/group'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'desk/filter'
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/core_ext/hash'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/api/modules/creatable'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/api/modules/searchable'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'desk/api/modules/deletable'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'desk/article'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 10 
     | 
    
         
            +
                class Articles
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 13 
     | 
    
         
            +
                  include Desk::Api::Creatable
         
     | 
| 
      
 14 
     | 
    
         
            +
                  include Desk::Api::Searchable
         
     | 
| 
      
 15 
     | 
    
         
            +
                  include Desk::Api::Deletable
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  VALID_SEARCH_PARAMS = [:text, :topic_ids]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def initialize(connection)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @endpoint = "articles"
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @return_class = Desk::Article
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  private
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  def valid_search_params
         
     | 
| 
      
 30 
     | 
    
         
            +
                    VALID_SEARCH_PARAMS
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/core_ext/hash'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/api/modules/creatable'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/api/modules/searchable'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'desk/case'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'desk/message'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 10 
     | 
    
         
            +
                class Cases
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 13 
     | 
    
         
            +
                  include Desk::Api::Creatable
         
     | 
| 
      
 14 
     | 
    
         
            +
                  include Desk::Api::Searchable
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  VALID_SEARCH_PARAMS= [:name, :first_name, :last_name, :email, :phone,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                        :company, :twitter, :labels, :case_id, :subject,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                        :description, :status, :priority, :assigned_group,
         
     | 
| 
      
 19 
     | 
    
         
            +
                                        :assigned_user, :channels, :notes, :attachments,
         
     | 
| 
      
 20 
     | 
    
         
            +
                                        :case_custom_key, :created, :updated, :since_created_at,
         
     | 
| 
      
 21 
     | 
    
         
            +
                                        :max_created_at, :since_updated_at, :max_updated_at,
         
     | 
| 
      
 22 
     | 
    
         
            +
                                        :since_id, :max_id]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def initialize(connection)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 28 
     | 
    
         
            +
                    @endpoint = "cases"
         
     | 
| 
      
 29 
     | 
    
         
            +
                    @return_class = Desk::Case
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def message(id)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Desk::Message.new(connection.get("cases/#{id}/message"))
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def replies(id)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    Desk::Message.new(connection.get("cases/#{id}/replies"))
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  private
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  def valid_search_params
         
     | 
| 
      
 43 
     | 
    
         
            +
                    VALID_SEARCH_PARAMS
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/core_ext/hash'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/api/modules/creatable'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/api/modules/searchable'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'desk/api/modules/deletable'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'desk/customer'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 10 
     | 
    
         
            +
                class Customers
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 13 
     | 
    
         
            +
                  include Desk::Api::Creatable
         
     | 
| 
      
 14 
     | 
    
         
            +
                  include Desk::Api::Searchable
         
     | 
| 
      
 15 
     | 
    
         
            +
                  include Desk::Api::Deletable
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  VALID_SEARCH_PARAMS = [:first_name, :last_name, :full_name, :email, :since_created_at,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                         :max_created_at, :external_id, :since_updated_at, :max_updated_at,
         
     | 
| 
      
 19 
     | 
    
         
            +
                                         :since_id, :max_id, :twitter, :phone, :custom_N]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def initialize(connection)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @endpoint = "customers"
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @return_class = Desk::Customer
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  private
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def valid_search_params
         
     | 
| 
      
 32 
     | 
    
         
            +
                    VALID_SEARCH_PARAMS
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/customer'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/filter'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/user'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 8 
     | 
    
         
            +
                class Groups
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize(connection)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @endpoint = "groups"
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @return_class = Desk::Group
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def filters(id)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    Desk::Collection.new(connection.get("groups/#{id}/filters"), Desk::Filter)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def users(id)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Desk::Collection.new(connection.get("groups/#{id}/users"), Desk::User)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Listable
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def all
         
     | 
| 
      
 6 
     | 
    
         
            +
                    Desk::Collection.new(connection.get(endpoint), return_class)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def show(id)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    raise ArgumentError "Must provide an ID" unless id
         
     | 
| 
      
 11 
     | 
    
         
            +
                    return_class.new(connection.get("#{endpoint}/#{id}"))
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/core_ext/hash'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/api/modules/creatable'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'desk/api/modules/deletable'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'desk/topic'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 9 
     | 
    
         
            +
                class Topics
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 12 
     | 
    
         
            +
                  include Desk::Api::Creatable
         
     | 
| 
      
 13 
     | 
    
         
            +
                  include Desk::Api::Deletable
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  def initialize(connection)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @endpoint = "topics"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @return_class = Desk::Topic
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'desk/api/modules/listable'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'desk/api/modules/creatable'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'desk/translation'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Desk
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 7 
     | 
    
         
            +
                class Translations
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  include Desk::Api::Listable
         
     | 
| 
      
 10 
     | 
    
         
            +
                  include Desk::Api::Creatable
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_reader :connection, :endpoint, :return_class
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize(connection, parent)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @connection = connection
         
     | 
| 
      
 16 
     | 
    
         
            +
                    raise ArgumentError unless parent
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @parent = parent
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @endpoint = "#{parent.endpoint}/translations"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @return_class = Desk::Translation
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/desk/article.rb
    ADDED