zendesk_engine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8482e71fdb6b38af51042d4be1159f3d57de522e
4
+ data.tar.gz: df1917f4538b74b5aa20edf4d1b49fdc1521dedc
5
+ SHA512:
6
+ metadata.gz: 6affdbddfdac75b9469ebd3a4edd79270c87c396ab1c0f7ce1147e99f1c7415e507d21271e51c35700334255a0a87545d4153af6a98c5fe5e35452cd6e50266e
7
+ data.tar.gz: de85dc001b76d2d73c8ff6c4ebd002441863c6e4bda361fe4f3ae7a26780d4f48f068189994c1da354b50b6f0dd5622ec945ee5541d31378891a6e6bc8a5d061
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ZendeskEngine'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
@@ -0,0 +1,27 @@
1
+ require "zendesk_api"
2
+
3
+ class ZendeskEngine::BaseController < ZendeskEngine.parent_controller.constantize
4
+ private
5
+ def client
6
+ @client ||= ZendeskAPI::Client.new do |config|
7
+ config.url = ZendeskEngine.url
8
+
9
+ # Basic / Token Authentication
10
+ config.username = ZendeskEngine.user
11
+
12
+ # Choose one of the following depending on your authentication choice
13
+ config.token = ZendeskEngine.token
14
+
15
+ # OAuth Authentication
16
+ #config.access_token = "your OAuth access token"
17
+
18
+ # Optional:
19
+
20
+ # Retry uses middleware to notify the user
21
+ # when hitting the rate limit, sleep automatically,
22
+ # then retry the request.
23
+ config.retry = true
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,18 @@
1
+ class ZendeskEngine::TicketsController < ZendeskEngine::BaseController
2
+ respond_to :json
3
+
4
+ delegate :users, :tickets, to: :client
5
+
6
+ def create
7
+ render json: tickets.create(permitted_params[:ticket].merge(submitter_id: user.id))
8
+ end
9
+
10
+ private
11
+ def user
12
+ users.search(query: "email:#{params[:user][:email]}").first || users.create(permitted_params[:user])
13
+ end
14
+
15
+ def permitted_params
16
+ params.permit user: [:name, :email], ticket: [:subject, :priority, comment: [:value]]
17
+ end
18
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ ZendeskEngine::Engine.routes.draw do
2
+ resources :tickets, only: [:create]
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :zendesk_engine do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,36 @@
1
+ module ZendeskEngine
2
+ module Configuration
3
+ VALID_CONFIG_KEYS = [:url, :user, :token, :parent_controller]
4
+
5
+ DEFAULT_URL = nil
6
+ DEFAULT_USER = nil
7
+ DEFAULT_TOKEN = nil
8
+ DEFAULT_PARENT_CONTROLLER = "ApplicationController"
9
+
10
+ # Build accessor methods for every config options so we can do this, for example:
11
+ # Awesome.format = <img src="http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif?m=1129645325g" alt=":x" class="wp-smiley"> ml
12
+ attr_accessor *VALID_CONFIG_KEYS
13
+
14
+ # Make sure we have the default values set when we get 'extended'
15
+ def self.extended(base)
16
+ base.reset
17
+ end
18
+
19
+ def configure
20
+ yield self if block_given?
21
+ end
22
+
23
+ def options
24
+ Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
25
+ end
26
+
27
+ def reset
28
+ self.url = DEFAULT_URL
29
+ self.user = DEFAULT_USER
30
+ self.token = DEFAULT_TOKEN
31
+ self.parent_controller = DEFAULT_PARENT_CONTROLLER
32
+ end
33
+
34
+ end # Configuration
35
+ end
36
+
@@ -0,0 +1,4 @@
1
+ module ZendeskEngine
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ZendeskEngine
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "zendesk_engine/engine"
2
+ require "zendesk_engine/configuration"
3
+
4
+ module ZendeskEngine
5
+ extend Configuration
6
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zendesk_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Diogo Biazus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: zendesk_api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: This engine provides a controller to create tickets through zendesk API
70
+ email:
71
+ - diogo@biazus.me
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - MIT-LICENSE
77
+ - Rakefile
78
+ - app/controllers/zendesk_engine/base_controller.rb
79
+ - app/controllers/zendesk_engine/tickets_controller.rb
80
+ - config/routes.rb
81
+ - lib/tasks/zendesk_engine_tasks.rake
82
+ - lib/zendesk_engine.rb
83
+ - lib/zendesk_engine/configuration.rb
84
+ - lib/zendesk_engine/engine.rb
85
+ - lib/zendesk_engine/version.rb
86
+ homepage: https://github.com/catarse/zendesk_engine
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: This engine provides a controller to create tickets through zendesk API
110
+ test_files: []