desk 0.3.0

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.
Files changed (74) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.yardopts +9 -0
  5. data/Gemfile +12 -0
  6. data/HISTORY.mkd +44 -0
  7. data/LICENSE.mkd +20 -0
  8. data/README.mkd +267 -0
  9. data/Rakefile +23 -0
  10. data/desk.gemspec +44 -0
  11. data/lib/desk.rb +26 -0
  12. data/lib/desk/api.rb +28 -0
  13. data/lib/desk/authentication.rb +25 -0
  14. data/lib/desk/client.rb +28 -0
  15. data/lib/desk/client/article.rb +92 -0
  16. data/lib/desk/client/case.rb +55 -0
  17. data/lib/desk/client/customer.rb +146 -0
  18. data/lib/desk/client/interaction.rb +75 -0
  19. data/lib/desk/client/macro.rb +142 -0
  20. data/lib/desk/client/topic.rb +90 -0
  21. data/lib/desk/client/user.rb +38 -0
  22. data/lib/desk/configuration.rb +98 -0
  23. data/lib/desk/connection.rb +39 -0
  24. data/lib/desk/error.rb +67 -0
  25. data/lib/desk/request.rb +44 -0
  26. data/lib/desk/version.rb +4 -0
  27. data/lib/faraday/request/multipart_with_file.rb +30 -0
  28. data/lib/faraday/request/oauth.rb +23 -0
  29. data/lib/faraday/response/raise_http_4xx.rb +45 -0
  30. data/lib/faraday/response/raise_http_5xx.rb +24 -0
  31. data/spec/desk/api_spec.rb +70 -0
  32. data/spec/desk/client/article_spec.rb +134 -0
  33. data/spec/desk/client/case_spec.rb +99 -0
  34. data/spec/desk/client/customer_spec.rb +158 -0
  35. data/spec/desk/client/interaction_spec.rb +191 -0
  36. data/spec/desk/client/macro_spec.rb +204 -0
  37. data/spec/desk/client/topic_spec.rb +135 -0
  38. data/spec/desk/client/user_spec.rb +58 -0
  39. data/spec/desk/client_spec.rb +10 -0
  40. data/spec/desk_spec.rb +127 -0
  41. data/spec/faraday/response_spec.rb +34 -0
  42. data/spec/fixtures/article.json +50 -0
  43. data/spec/fixtures/article_create.json +54 -0
  44. data/spec/fixtures/article_destroy.json +3 -0
  45. data/spec/fixtures/article_update.json +54 -0
  46. data/spec/fixtures/articles.json +58 -0
  47. data/spec/fixtures/case.json +59 -0
  48. data/spec/fixtures/case_update.json +59 -0
  49. data/spec/fixtures/cases.json +182 -0
  50. data/spec/fixtures/customer.json +58 -0
  51. data/spec/fixtures/customer_create.json +56 -0
  52. data/spec/fixtures/customer_create_email.json +15 -0
  53. data/spec/fixtures/customer_update.json +47 -0
  54. data/spec/fixtures/customer_update_email.json +15 -0
  55. data/spec/fixtures/customers.json +98 -0
  56. data/spec/fixtures/interaction_create.json +126 -0
  57. data/spec/fixtures/interactions.json +139 -0
  58. data/spec/fixtures/macro.json +8 -0
  59. data/spec/fixtures/macro_action.json +9 -0
  60. data/spec/fixtures/macro_action_update.json +12 -0
  61. data/spec/fixtures/macro_actions.json +69 -0
  62. data/spec/fixtures/macro_create.json +13 -0
  63. data/spec/fixtures/macro_destroy.json +3 -0
  64. data/spec/fixtures/macro_update.json +13 -0
  65. data/spec/fixtures/macros.json +24 -0
  66. data/spec/fixtures/topic.json +9 -0
  67. data/spec/fixtures/topic_create.json +14 -0
  68. data/spec/fixtures/topic_destroy.json +3 -0
  69. data/spec/fixtures/topic_update.json +14 -0
  70. data/spec/fixtures/topics.json +35 -0
  71. data/spec/fixtures/user.json +15 -0
  72. data/spec/fixtures/users.json +24 -0
  73. data/spec/helper.rb +55 -0
  74. metadata +464 -0
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ *.rbc
3
+ .DS_Store
4
+ .bundle
5
+ .rvmrc
6
+ .yardoc
7
+ Gemfile.lock
8
+ coverage/*
9
+ doc/*
10
+ log/*
11
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --protected
3
+ --tag format:"Supported formats"
4
+ --tag authenticated:"Requires Authentication"
5
+ --tag rate_limited:"Rate Limited"
6
+ --markup markdown
7
+ -
8
+ HISTORY.mkd
9
+ LICENSE.mkd
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+
6
+ group :development do
7
+ gem "ruby-debug"
8
+ end
9
+
10
+ group :test do
11
+ gem "ruby-debug"
12
+ end
data/HISTORY.mkd ADDED
@@ -0,0 +1,44 @@
1
+ 0.3.0 July 15, 2012
2
+ ------------------
3
+ Renamed from Assistly to Desk
4
+ Updated Faraday and Hashie versions
5
+
6
+ 0.2.6 October 3, 2011
7
+ ------------------
8
+ Newer Faraday and multixml versions
9
+
10
+ 0.2.5 August 17, 2011
11
+ ------------------
12
+ Newer multijson version for Rails 3.1 compatibility
13
+
14
+ 0.2.3 April 18, 2011
15
+ ------------------
16
+ Removed deep_merge because it conflicts with rails. Handling the merge inside the create_outbound_interaction method only on headers for now, until we need it elsewhere.
17
+
18
+ 0.2.2 - April 18, 2011
19
+ ------------------
20
+ Added deep_merge! support so that we keep any custom email headers when creating outbound interactions.
21
+ Required pony in the gem so you don't have to include it in your app.
22
+
23
+ 0.2.1 - April 18, 2011
24
+ ------------------
25
+ Stopped returning only the 'results' array when listing things, because this would cause us to not have access to page numbers, total counts, etc.
26
+
27
+ 0.2.0 - April 16, 2011
28
+ -------------------------
29
+ * Support for Topics, Articles, and Macros added
30
+ * Update Readme
31
+
32
+ 0.1.5 - April 15, 2011
33
+ -------------------------
34
+ * Support for creating outbound interactions via email
35
+
36
+ 0.1.1 - 0.1.4 - April 14, 2011
37
+ -------------------------
38
+ * Miscellaneous bug fixes found when actually using this in production.
39
+ * Moved to Zencoder Github account
40
+
41
+ 0.1 - April 12, 2011
42
+ -------------------------
43
+ * Initial release
44
+ * Support for Case, Customer, Interaction, and User APIs.
data/LICENSE.mkd ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Chris Warren
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/README.mkd ADDED
@@ -0,0 +1,267 @@
1
+ The Desk Ruby Gem
2
+ ====================
3
+ A Ruby wrapper for the [Desk.com API](http://dev.desk.com/)
4
+
5
+ Installation
6
+ ------------
7
+ gem install desk
8
+
9
+ What's new in 0.3.0?
10
+ ------------------
11
+ Renamed to Desk
12
+ Newer faraday, faraday_middleware and hashie
13
+
14
+ What's new in 0.2.6?
15
+ ------------------
16
+ Newer faraday, faraday_middleware and multixml versions
17
+
18
+ What's new in 0.2.5?
19
+ ------------------
20
+ Newer multijson version for Rails 3.1 compatibility
21
+
22
+ What's new in 0.2.4?
23
+ ------------------
24
+ Resolved an issue that was breaking PUT requests.
25
+
26
+ What's new in 0.2.3?
27
+ ------------------
28
+ Removed deep_merge because it conflicts with rails. Handling the merge inside the create_outbound_interaction method only on headers for now, until we need it elsewhere.
29
+
30
+ What's new in 0.2.2?
31
+ ------------------
32
+ Added deep_merge support so that we keep any custom email headers when creating outbound interactions.
33
+ Required pony in the gem so you don't have to include it in your app.
34
+
35
+ What's new in 0.2.1?
36
+ ------------------
37
+ Stopped returning only the 'results' array when listing things, because this would cause us to not have access to page numbers, total counts, etc.
38
+
39
+ What's new in 0.2.0?
40
+ ------------------
41
+ Added support for Topics, Articles, and Macros, which is currently all that is available in the Assistly API.
42
+
43
+ What's new in 0.1.5?
44
+ ------------------
45
+ Added the ability to create outbound communications over email
46
+
47
+
48
+ What's new in 0.1?
49
+ ------------------
50
+ This is the first release of the Assistly gem, based on the [Twitter gem](http://github.com/jnunemaker/twitter). Support for most of the [Assistly API](http://dev.desk.com/docs/api) are handled.
51
+ There is not yet support for Content or Macros.
52
+
53
+ Help! I'm getting: "Did not recognize your engine specification. Please specify either a symbol or a class. (RuntimeError)"
54
+ ---------------------------------------------------------------------------------------------------------------------------
55
+
56
+ You'll need to explicitly require a JSON library. We recommend [yajl-ruby](http://github.com/brianmario/yajl-ruby).
57
+
58
+ Usage Examples
59
+ --------------
60
+ require "rubygems"
61
+ require "desk"
62
+
63
+ # All methods require authentication. To get your Desk OAuth credentials,
64
+ # register an app in the Desk.com admin for your account at http://your-domain.desk.com/admin
65
+ Desk.configure do |config|
66
+ config.support_email = "help@example.com"
67
+ config.subdomain = YOUR_DESK_SUBDOMAIN
68
+ config.consumer_key = YOUR_CONSUMER_KEY
69
+ config.consumer_secret = YOUR_CONSUMER_SECRET
70
+ config.oauth_token = YOUR_OAUTH_TOKEN
71
+ config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
72
+ end
73
+
74
+ ######
75
+ # Cases
76
+ ######
77
+
78
+ # List cases
79
+ Desk.cases
80
+ Desk.cases(:since_id => 12345)
81
+
82
+ # Get a specific case
83
+ Desk.case(12345)
84
+
85
+ # Update a specific case
86
+ Desk.update_case(12345, :subject => "Something Else")
87
+
88
+ # Get a case url
89
+ Desk.case_url(12345)
90
+
91
+ ######
92
+ # Customers
93
+ ######
94
+
95
+ # List customers
96
+ Desk.customers
97
+ Desk.customers(:since_id => 12345, :count => 5)
98
+
99
+ # Get a specific customer
100
+ Desk.customer(12345)
101
+
102
+ # Create a customer
103
+ Desk.create_customer(:name => "Chris Warren", :twitter => "cdwarren")
104
+
105
+ # Update a customer
106
+ Desk.update_customer(12345, :name => "Christopher Warren")
107
+
108
+ # Add a customer email
109
+ Desk.create_customer_email(12345, "foo@example.com")
110
+ Desk.create_customer_email(12345, "foo@example.com", :customer_contact_type => "work")
111
+
112
+ # Update a customer email
113
+ Desk.update_customer_email(12345, 54321, :email => "foo@example.com")
114
+ Desk.update_customer_email(12345, 54321, :customer_contact_type => "work")
115
+
116
+ # Add a customer phone number
117
+ Desk.create_customer_phone(12345, "555-368-7147")
118
+ Desk.create_customer_phone(12345, "555-368-7147", :customer_contact_type => "work")
119
+
120
+ # Update a customer phone number
121
+ Desk.update_customer_phone(12345, 54321, :phone => "555-368-7147")
122
+ Desk.update_customer_phone(12345, 54321, :customer_contact_type => "work")
123
+
124
+ ######
125
+ # Interactions
126
+ ######
127
+
128
+ # List interactions
129
+ Desk.interactions
130
+ Desk.interactions(:since_id => 12345)
131
+ Desk.interactions(:since_id => 12345, :count => 5)
132
+
133
+ # Create an inbound interaction
134
+ Desk.create_interaction(:interaction_subject => "help me", :customer_email => "foo@example.com", :interaction_body => "You're my only hope.")
135
+ Desk.create_inbound_interaction(:interaction_subject => "help me", :customer_email => "foo@example.com", :interaction_body => "You're my only hope.")
136
+
137
+ # Create an outbound interaction
138
+ # Desk.com's API doesn't support creating outbound communications, so we do this over email with a BCC back to Desk and customer headers.
139
+ # Desk.support_email must be set to your Desk.com email address so that the email can be sent to the account and give the customer someone to respond to.
140
+ #
141
+ # Read more at http://support.desk.com/customer/portal/articles/4180
142
+ # Additional headers can be passed as well http://support.desk.com/customer/portal/articles/6728
143
+ #
144
+ # Email is sent using Pony https://github.com/benprew/pony
145
+ Desk.create_interaction(:interaction_subject => "Missed Your Call", :customer_email => "foo@example.com", :interaction_body => "Sorry we missed yoru call. What's up?", :direction => "outbound")
146
+ Desk.create_outbound_interaction("foo@example.com", "Missed Your Call", "Sorry we missed yoru call. What's up?")
147
+
148
+ ######
149
+ # Users
150
+ ######
151
+
152
+ # List users
153
+ Desk.users
154
+
155
+ # Get a specific user
156
+ Desk.user(12345)
157
+
158
+ ######
159
+ # Topics
160
+ ######
161
+
162
+ # List Topics
163
+ Desk.topics
164
+
165
+ # Get a specific topic
166
+ Desk.topic(12345)
167
+
168
+ # Create a new topic
169
+ Desk.create_topic("name", :description => "description")
170
+
171
+ # Update a topic
172
+ Desk.update_topic(12345, :subject => "Updated")
173
+
174
+ # Delete a topic
175
+ Desk.delete_topic(12345)
176
+
177
+ ######
178
+ # Articles
179
+ ######
180
+
181
+ # List articles for a topic
182
+ Desk.articles(1)
183
+
184
+ # Get a specific article
185
+ Desk.article(12345)
186
+
187
+ # Create a new article within a topic
188
+ Desk.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
189
+
190
+ # Update an article
191
+ Desk.update_article(12345, :subject => "Updated API Tips")
192
+
193
+ # Delete an article
194
+ Desk.delete_article(12345)
195
+
196
+ ######
197
+ # Macros
198
+ ######
199
+
200
+ # List Macros
201
+ Desk.macros
202
+
203
+ # Get a specific macro
204
+ Desk.macro(12345)
205
+
206
+ # Create a new macro
207
+ Desk.create_macro("name", :labels => "escalated")
208
+
209
+ # Update a macro
210
+ Desk.update_macro(12345, :name => "Updated Name")
211
+
212
+ # Delete a macro
213
+ Desk.delete_macro(12345)
214
+
215
+ # Macro Actions
216
+ Desk.macro_actions(12345)
217
+
218
+ # Macro Action
219
+ Desk.macro_action(12345, "set-case-description")
220
+
221
+ # Update Macro Action
222
+ Desk.update_macro_action(12345, "set-case-description", :value => "New Subject")
223
+
224
+ Contributing
225
+ ------------
226
+ In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
227
+
228
+ Here are some ways *you* can contribute:
229
+
230
+ * by using alpha, beta, and prerelease versions
231
+ * by reporting bugs
232
+ * by suggesting new features
233
+ * by writing or editing documentation
234
+ * by writing specifications
235
+ * by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
236
+ * by refactoring code
237
+ * by closing [issues](http://github.com/zencoder/desk/issues)
238
+ * by reviewing patches
239
+
240
+ All contributors will be added to the [HISTORY](https://github.com/zencoder/desk/blob/master/HISTORY.mkd)
241
+ file and will receive the respect and gratitude of the community.
242
+
243
+ Submitting an Issue
244
+ -------------------
245
+ We use the [GitHub issue tracker](http://github.com/zencoder/desk/issues) to track bugs and
246
+ features. Before submitting a bug report or feature request, check to make sure it hasn't already
247
+ been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
248
+ bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
249
+ details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
250
+ operating system. Ideally, a bug report should include a pull request with failing specs.
251
+
252
+ Submitting a Pull Request
253
+ -------------------------
254
+ 1. Fork the project.
255
+ 2. Create a topic branch.
256
+ 3. Implement your feature or bug fix.
257
+ 4. Add documentation for your feature or bug fix.
258
+ 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
259
+ 6. Add specs for your feature or bug fix.
260
+ 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
261
+ 8. Commit and push your changes.
262
+ 9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
263
+
264
+ Copyright
265
+ ---------
266
+ Copyright (c) 2012 Chris Warren/[Zencoder](http://zencoder.com)
267
+ See [LICENSE](https://github.com/zencoder/desk/blob/master/LICENSE.mkd) for details.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
9
+
10
+ namespace :doc do
11
+ require 'yard'
12
+ YARD::Rake::YardocTask.new do |task|
13
+ task.files = ['HISTORY.mkd', 'LICENSE.mkd', 'lib/**/*.rb']
14
+ task.options = [
15
+ '--protected',
16
+ '--output-dir', 'doc/yard',
17
+ '--tag', 'format:Supported formats',
18
+ '--tag', 'authenticated:Requires Authentication',
19
+ '--tag', 'rate_limited:Rate Limited',
20
+ '--markup', 'markdown',
21
+ ]
22
+ end
23
+ end
data/desk.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/desk/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ # s.add_development_dependency('json', '~> 1.5')
6
+ s.add_development_dependency('nokogiri', '~> 1.4')
7
+ s.add_development_dependency('maruku', '~> 0.6')
8
+ s.add_development_dependency('rake', '~> 0.8')
9
+ s.add_development_dependency('rspec', '~> 2.5')
10
+ s.add_development_dependency('email_spec', '~> 1.1.1')
11
+ s.add_development_dependency('simplecov', '~> 0.4')
12
+ s.add_development_dependency('webmock', '~> 1.6')
13
+ s.add_development_dependency('yard', '~> 0.6')
14
+ s.add_development_dependency('ZenTest', '~> 4.5')
15
+ s.add_runtime_dependency('json', '~> 1.7') if RUBY_VERSION < '1.9'
16
+ s.add_runtime_dependency('hashie', '~> 1.2.0')
17
+ s.add_runtime_dependency('faraday', '~> 0.8.0')
18
+ s.add_runtime_dependency('faraday_middleware', '~> 0.8.0')
19
+ s.add_runtime_dependency('jruby-openssl', '~> 0.7.2') if RUBY_PLATFORM == 'java'
20
+ s.add_runtime_dependency('multi_json', '~> 1.0.3')
21
+ s.add_runtime_dependency('multi_xml', '~> 0.4.0')
22
+ s.add_runtime_dependency('rash', '~> 0.3.1')
23
+ s.add_runtime_dependency('simple_oauth', '~> 0.1.4')
24
+ s.add_runtime_dependency('pony', '~> 1.1')
25
+ s.authors = ["Chris Warren"]
26
+ s.description = %q{A Ruby wrapper for the Desk.com REST API}
27
+ s.post_install_message =<<eos
28
+ ********************************************************************************
29
+ Ruby wrapper for the Desk.com API.
30
+ ********************************************************************************
31
+ eos
32
+ s.email = ['chris@zencoder.com']
33
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
34
+ s.files = `git ls-files`.split("\n")
35
+ s.homepage = 'https://github.com/zencoder/desk'
36
+ s.name = 'desk'
37
+ s.platform = Gem::Platform::RUBY
38
+ s.require_paths = ['lib']
39
+ s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
40
+ s.rubyforge_project = s.name
41
+ s.summary = %q{Ruby wrapper for the Desk.com API}
42
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
43
+ s.version = Desk::VERSION.dup
44
+ end