zendesk_api 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zendesk_api/client.rb +1 -1
  3. data/lib/zendesk_api/middleware/response/parse_json.rb +0 -1
  4. data/lib/zendesk_api/version.rb +1 -1
  5. metadata +10 -205
  6. data/.gitignore +0 -15
  7. data/.rspec +0 -2
  8. data/.travis.yml +0 -10
  9. data/.yardopts +0 -10
  10. data/Gemfile +0 -14
  11. data/LICENSE +0 -176
  12. data/README.md +0 -425
  13. data/Rakefile +0 -52
  14. data/spec/core/association_spec.rb +0 -256
  15. data/spec/core/bulk_actions_spec.rb +0 -69
  16. data/spec/core/client_spec.rb +0 -280
  17. data/spec/core/collection_spec.rb +0 -901
  18. data/spec/core/configuration_spec.rb +0 -28
  19. data/spec/core/create_resource_spec.rb +0 -39
  20. data/spec/core/data_namespace_spec.rb +0 -15
  21. data/spec/core/data_resource_spec.rb +0 -239
  22. data/spec/core/inflection_spec.rb +0 -7
  23. data/spec/core/lru_cache_spec.rb +0 -26
  24. data/spec/core/middleware/request/encode_json_spec.rb +0 -73
  25. data/spec/core/middleware/request/etag_cache_spec.rb +0 -21
  26. data/spec/core/middleware/request/retry_spec.rb +0 -49
  27. data/spec/core/middleware/request/test.jpg +0 -0
  28. data/spec/core/middleware/request/upload_spec.rb +0 -164
  29. data/spec/core/middleware/response/callback_spec.rb +0 -17
  30. data/spec/core/middleware/response/deflate_spec.rb +0 -21
  31. data/spec/core/middleware/response/gzip_spec.rb +0 -25
  32. data/spec/core/middleware/response/parse_iso_dates_spec.rb +0 -44
  33. data/spec/core/middleware/response/parse_json_spec.rb +0 -53
  34. data/spec/core/middleware/response/raise_error_spec.rb +0 -128
  35. data/spec/core/middleware/response/sanitize_response_spec.rb +0 -19
  36. data/spec/core/read_resource_spec.rb +0 -97
  37. data/spec/core/resource_spec.rb +0 -541
  38. data/spec/core/resources/automation_spec.rb +0 -81
  39. data/spec/core/resources/macro_spec.rb +0 -27
  40. data/spec/core/resources/trigger_spec.rb +0 -67
  41. data/spec/core/resources/view_spec.rb +0 -97
  42. data/spec/core/search_spec.rb +0 -23
  43. data/spec/core/spec_helper.rb +0 -162
  44. data/spec/core/trackie_spec.rb +0 -129
  45. data/spec/fixtures/Argentina.gif +0 -0
  46. data/spec/fixtures/Argentina2.gif +0 -0
  47. data/spec/fixtures/credentials.yml.example +0 -3
  48. data/spec/fixtures/sample_app.zip +0 -0
  49. data/spec/fixtures/test_resources.rb +0 -22
  50. data/spec/fixtures/zendesk.rb +0 -109
  51. data/spec/live/Readme.md +0 -4
  52. data/spec/live/activity_spec.rb +0 -12
  53. data/spec/live/app_installation_spec.rb +0 -58
  54. data/spec/live/app_spec.rb +0 -58
  55. data/spec/live/audit_spec.rb +0 -15
  56. data/spec/live/automation_spec.rb +0 -23
  57. data/spec/live/bookmark_spec.rb +0 -11
  58. data/spec/live/brand_spec.rb +0 -14
  59. data/spec/live/category_spec.rb +0 -12
  60. data/spec/live/collection_spec.rb +0 -64
  61. data/spec/live/custom_role_spec.rb +0 -5
  62. data/spec/live/dynamic_content/item_spec.rb +0 -16
  63. data/spec/live/dynamic_content/variant_spec.rb +0 -19
  64. data/spec/live/forum_spec.rb +0 -14
  65. data/spec/live/forum_subscription_spec.rb +0 -12
  66. data/spec/live/group_membership_spec.rb +0 -18
  67. data/spec/live/group_spec.rb +0 -32
  68. data/spec/live/identity_spec.rb +0 -14
  69. data/spec/live/locale_spec.rb +0 -9
  70. data/spec/live/macro_spec.rb +0 -44
  71. data/spec/live/organization_field_spec.rb +0 -12
  72. data/spec/live/organization_membership_spec.rb +0 -11
  73. data/spec/live/organization_spec.rb +0 -12
  74. data/spec/live/push_notification_device_spec.rb +0 -21
  75. data/spec/live/request_spec.rb +0 -38
  76. data/spec/live/satisfaction_rating_spec.rb +0 -6
  77. data/spec/live/setting_spec.rb +0 -25
  78. data/spec/live/suspended_ticket_spec.rb +0 -8
  79. data/spec/live/tag_spec.rb +0 -58
  80. data/spec/live/target_spec.rb +0 -17
  81. data/spec/live/ticket_field_spec.rb +0 -12
  82. data/spec/live/ticket_form_spec.rb +0 -14
  83. data/spec/live/ticket_metrics_spec.rb +0 -6
  84. data/spec/live/ticket_spec.rb +0 -136
  85. data/spec/live/topic_comment_spec.rb +0 -52
  86. data/spec/live/topic_spec.rb +0 -46
  87. data/spec/live/topic_subscription_spec.rb +0 -12
  88. data/spec/live/topic_vote_spec.rb +0 -13
  89. data/spec/live/trigger_spec.rb +0 -23
  90. data/spec/live/upload_spec.rb +0 -10
  91. data/spec/live/user_field_spec.rb +0 -12
  92. data/spec/live/user_spec.rb +0 -71
  93. data/spec/live/user_view_spec.rb +0 -16
  94. data/spec/live/view_spec.rb +0 -22
  95. data/spec/live/voice/phone_number_spec.rb +0 -13
  96. data/spec/macros/resource_macros.rb +0 -169
  97. data/zendesk_api.gemspec +0 -38
data/README.md DELETED
@@ -1,425 +0,0 @@
1
- # Zendesk API Client
2
-
3
- ## API version support
4
-
5
- This client **only** supports Zendesk's v2 API. Please see our [API documentation](http://developer.zendesk.com) for more information.
6
-
7
- ## Documentation
8
-
9
- Please check out the [wiki](https://github.com/zendesk/zendesk_api_client_rb/wiki), [class documentation](http://zendesk.github.io/zendesk_api_client_rb), and [issues](https://github.com/zendesk/zendesk_api_client_rb/issues) before reporting a bug or asking for help.
10
-
11
- ## Important Notices
12
-
13
- * Version 0.0.5 brings with it a change to the top-level namespace. All references to Zendesk should now use ZendeskAPI.
14
- * Version 0.3.0 changed the license from MIT to Apache Version 2.
15
- * Version 0.3.2 introduced a regression when side-loading roles on users. This was fixed in 0.3.4.
16
- * Version 1.0.0 changes the way errors are handled. Please see the [wiki page](https://github.com/zendesk/zendesk_api_client_rb/wiki/Errors) for more info.
17
- * Version 1.3.0 updates the Faraday dependency to 0.9. Since Faraday did not bump a major version we have not either, but there is no guarantee >= 1.3.0 works with Faraday < 0.9
18
- * Version 1.3.8 had a bug where attachments were created, but the response was not handled properly
19
- * Version >= 1.0 and < 1.4.2 had a bug where non application/json response bodies were discarded
20
- * Version 1.5.0 removed support for Ruby 1.8
21
- * Version 1.6.0 ZendeskAPI::Voice::CertificationAddress is now ZendeskAPI::Voice::Address
22
- * Version 1.8.0 no longer considers 1XX and 3XX (except 304) response status codes valid and will raise a NetworkError
23
-
24
- ## Installation
25
-
26
- The Zendesk API client can be installed using Rubygems or Bundler.
27
-
28
- ### Rubygems
29
-
30
- ```sh
31
- gem install zendesk_api
32
- ```
33
-
34
- ### Bundler
35
-
36
- Add it to your Gemfile
37
-
38
- gem "zendesk_api"
39
-
40
- and follow normal [Bundler](http://gembundler.com/) installation and execution procedures.
41
-
42
- ## Configuration
43
-
44
- Configuration is done through a block returning an instance of ZendeskAPI::Client.
45
- The block is mandatory and if not passed, an ArgumentError will be thrown.
46
-
47
- ```ruby
48
- require 'zendesk_api'
49
-
50
- client = ZendeskAPI::Client.new do |config|
51
- # Mandatory:
52
-
53
- config.url = "<- your-zendesk-url ->" # e.g. https://mydesk.zendesk.com/api/v2
54
-
55
- # Basic / Token Authentication
56
- config.username = "login.email@zendesk.com"
57
-
58
- # Choose one of the following depending on your authentication choice
59
- config.token = "your zendesk token"
60
- config.password = "your zendesk password"
61
-
62
- # OAuth Authentication
63
- config.access_token = "your OAuth access token"
64
-
65
- # Optional:
66
-
67
- # Retry uses middleware to notify the user
68
- # when hitting the rate limit, sleep automatically,
69
- # then retry the request.
70
- config.retry = true
71
-
72
- # Logger prints to STDERR by default, to e.g. print to stdout:
73
- require 'logger'
74
- config.logger = Logger.new(STDOUT)
75
-
76
- # Changes Faraday adapter
77
- # config.adapter = :patron
78
-
79
- # Merged with the default client options hash
80
- # config.client_options = { :ssl => false }
81
-
82
- # When getting the error 'hostname does not match the server certificate'
83
- # use the API at https://yoursubdomain.zendesk.com/api/v2
84
- end
85
- ```
86
-
87
- Note: This ZendeskAPI API client only supports basic authentication at the moment.
88
-
89
- ## Usage
90
-
91
- The result of configuration is an instance of ZendeskAPI::Client which can then be used in two different methods.
92
-
93
- One way to use the client is to pass it in as an argument to individual classes.
94
-
95
- ```ruby
96
- ZendeskAPI::Ticket.new(client, :id => 1, :priority => "urgent") # doesn't actually send a request, must explicitly call #save
97
- ZendeskAPI::Ticket.create(client, :subject => "Test Ticket", :comment => { :value => "This is a test" }, :submitter_id => client.current_user.id, :priority => "urgent")
98
- ZendeskAPI::Ticket.find(client, :id => 1)
99
- ZendeskAPI::Ticket.destroy(client, :id => 1)
100
- ```
101
-
102
- Another way is to use the instance methods under client.
103
-
104
- ```ruby
105
- client.tickets.first
106
- client.tickets.find(:id => 1)
107
- client.tickets.build(:subject => "Test Ticket")
108
- client.tickets.create(:subject => "Test Ticket", :comment => { :value => "This is a test" }, :submitter_id => client.current_user.id, :priority => "urgent")
109
- client.tickets.destroy(:id => 1)
110
- ```
111
-
112
- The methods under ZendeskAPI::Client (such as .tickets) return an instance of ZendeskAPI::Collection a lazy-loaded list of that resource.
113
- Actual requests may not be sent until an explicit ZendeskAPI::Collection#fetch, ZendeskAPI::Collection#to_a, or an applicable methods such
114
- as #each.
115
-
116
- ### Caveats
117
-
118
- Resource updating is implemented by sending only the `changed?` attributes to the server (see `ZendeskAPI::TrackChanges`).
119
- Unfortunately, this module only hooks into `Hash` meaning any changes to an `Array` not resulting in a new instance will not be tracked and sent.
120
-
121
- ```
122
- zendesk_api_client_rb $ bundle console
123
- > a = ZendeskAPI::Trackie.new(:test => []).tap(&:clear_changes)
124
- > a.changed?(:test)
125
- => false
126
- > a.test << "hello"
127
- => ["hello"]
128
- > a.changed?(:test)
129
- => false
130
- > a.test += %w{hi}
131
- => ["hello", "hi"]
132
- > a.changed?(:test)
133
- => true
134
- ```
135
-
136
- ### Pagination
137
-
138
- ZendeskAPI::Collections can be paginated:
139
-
140
- ```ruby
141
- tickets = client.tickets.page(2).per_page(3)
142
- next_page = tickets.next # => 3
143
- tickets.fetch # GET /api/v2/tickets?page=3&per_page=3
144
- previous_page = tickets.prev # => 2
145
- tickets.fetch # GET /api/v2/tickets?page=2&per_page=3
146
- ```
147
-
148
- Iteration over all resources and pages is handled by Collection#all
149
-
150
- ```ruby
151
- client.tickets.all do |resource|
152
- # every resource, from all pages, will be yielded to this block
153
- end
154
- ```
155
-
156
- If given a block with two arguments, the page number is also passed in.
157
-
158
- ```ruby
159
- client.tickets.all do |resource, page_number|
160
- # all resources will be yielded along with the page number
161
- end
162
- ```
163
-
164
- ### Callbacks
165
-
166
- Callbacks can be added to the ZendeskAPI::Client instance and will be called (with the response env) after all response middleware on a successful request.
167
-
168
- ```ruby
169
- client.insert_callback do |env|
170
- puts env[:response_headers]
171
- end
172
- ```
173
-
174
- ### Resource management
175
-
176
- Individual resources can be created, modified, saved, and destroyed.
177
-
178
- ```ruby
179
- ticket = client.tickets[0] # ZendeskAPI::Ticket.find(client, :id => 1)
180
- ticket.priority = "urgent"
181
- ticket.attributes # => { "priority" => "urgent" }
182
- ticket.save # Will PUT => true
183
- ticket.destroy # => true
184
-
185
- ZendeskAPI::Ticket.new(client, { :priority => "urgent" })
186
- ticket.new_record? # => true
187
- ticket.save # Will POST
188
- ```
189
-
190
- ### Side-loading
191
-
192
- **Warning: this is an experimental feature. Abuse it and lose it.**
193
-
194
- To facilitate a smaller number of requests and easier manipulation of associated data we allow "side-loading", or inclusion, of selected resources.
195
-
196
- For example:
197
- A ZendeskAPI::Ticket is associated with ZendeskAPI::User through the requester_id field.
198
- API requests for that ticket return a structure similar to this:
199
- ```json
200
- "ticket": {
201
- "id": 1,
202
- "url": "http.....",
203
- "requester_id": 7,
204
- ...
205
- }
206
- ```
207
-
208
- Calling ZendeskAPI::Ticket#requester automatically fetches and loads the user referenced above (`/api/v2/users/7`).
209
- Using side-loading, however, the user can be partially loaded in the same request as the ticket.
210
-
211
- ```ruby
212
- tickets = client.tickets.include(:users)
213
- # Or client.tickets(:include => :users)
214
- # Does *NOT* make a request to the server since it is already loaded
215
- tickets.first.requester # => #<ZendeskAPI::User id=...>
216
- ```
217
-
218
- OR
219
-
220
- ```ruby
221
- ticket = client.tickets.find(:id => 1, :include => :users)
222
- ticket.requester # => #<ZendeskAPI::User id=...>
223
- ```
224
-
225
- Currently, this feature is limited to only a few resources and their associations.
226
- They are documented on [developer.zendesk.com](http://developer.zendesk.com/documentation/rest_api/introduction.html#side-loading-\(beta\)).
227
-
228
- ### Search
229
-
230
- Searching is done through the client. Returned is an instance of ZendeskAPI::Collection:
231
-
232
- ```ruby
233
- client.search(:query => "my search query") # /api/v2/search.json?query=...
234
- client.users.search(:query => "my new query") # /api/v2/users/search.json?query=...
235
- ```
236
-
237
- ### Special case: Custom resources paths
238
-
239
- API endpoints such as tickets/recent or topics/show_many can be accessed through chaining.
240
- They will too return an instance of ZendeskAPI::Collection.
241
-
242
- ```ruby
243
- client.tickets.recent
244
- client.topics.show_many(:verb => :post, :ids => [1, 2, 3])
245
- ```
246
-
247
- ### Special Case: Current user
248
-
249
- Use either of the following to obtain the current user instance:
250
-
251
- ```ruby
252
- client.users.find(:id => 'me')
253
- client.current_user
254
- ```
255
-
256
- ### Special Case: Importing a ticket
257
-
258
- Bulk importing tickets allows you to move large amounts of data into Zendesk.
259
-
260
- ```ruby
261
- ticket = ZendeskAPI::Ticket.import(client, :subject => "Help", :comments => [{ :author_id => 19, :value => "This is a comment" }])
262
- ```
263
-
264
- http://developer.zendesk.com/documentation/rest_api/ticket_import.html
265
-
266
- ### Attaching files
267
-
268
- Files can be attached to ticket comments using either a path or the File class and will
269
- be automatically uploaded and attached.
270
-
271
- ```ruby
272
- ticket = ZendeskAPI::Ticket.new(client, :comment => { :value => "attachments" })
273
- ticket.comment.uploads << "img.jpg"
274
- ticket.comment.uploads << File.new("img.jpg")
275
- ticket.save
276
- ```
277
-
278
- ### Apps API
279
-
280
- v1.1.0 introduces support for the Zendesk [Apps API](http://developer.zendesk.com/documentation/apps/reference/api.html)
281
-
282
- #### Creating Apps
283
-
284
- ```ruby
285
- upload = client.apps.uploads.create!(:file => "path/to/app.zip")
286
- client.apps.create!(:name => "test", :upload_id => upload.id)
287
-
288
- # Or
289
-
290
- app = ZendeskAPI::App.new(client, :name => "test")
291
- app.upload = "path/to/app.zip"
292
- app.save!
293
-
294
- # Or
295
-
296
- upload = ZendeskAPI::App::Upload.new(client, :file => "path/to/app.zip")
297
- upload.save!
298
-
299
- app = ZendeskAPI::App.new(client, :name => "test")
300
- app.upload_id = upload.id
301
- app.save!
302
-
303
- # Or
304
-
305
- client.apps.create!(:name => "test", :upload => "app.zip")
306
- ```
307
-
308
- *Note: job statuses are currently not supported, so you must manually poll the job status API for app creation.*
309
-
310
- ```ruby
311
- body = {}
312
- until %w{failed completed}.include?(body["status"])
313
- response = client.connection.get(app.response.headers["Location"])
314
- body = response.body
315
-
316
- sleep(body["retry_in"])
317
- end
318
- ```
319
-
320
- #### Updating Apps
321
-
322
- ```ruby
323
- upload = client.apps.uploads.create!(:file => "NewApp.zip")
324
-
325
- # Then
326
-
327
- client.apps.update!(:id => 123, :upload_id => upload.id)
328
-
329
- # Or
330
-
331
- app = ZendeskAPI::App.new(client, :id => 123)
332
- app.upload_id = upload.id
333
- app.save!
334
-
335
- # Or
336
-
337
- ZendeskAPI::App.update!(client, :id => 123, :upload_id => upload.id)
338
- ```
339
-
340
- #### Deleting Apps
341
-
342
- ```ruby
343
- client.apps.destroy!(:id => 123)
344
-
345
- app = ZendeskAPI::App.new(client, :id => 123)
346
- app.destroy!
347
-
348
- ZendeskAPI::App.destroy!(client, :id => 123)
349
- ```
350
-
351
- #### Installing an App
352
-
353
- **Installation name is required**
354
-
355
- ```ruby
356
- installation = ZendeskAPI::AppInstallation.new(client, :app_id => 123, :settings => { :name => 'Name' })
357
- installation.save!
358
-
359
- # or
360
-
361
- client.apps.installations.create!(:app_id => 123, :settings => { :name => 'Name' })
362
-
363
- # or
364
-
365
- ZendeskAPI::AppInstallation.create!(client, :app_id => 123, :settings => { :name => 'Name' })
366
- ```
367
-
368
- #### List Installations
369
-
370
- ```ruby
371
- apps = client.app.installations
372
- apps.fetch!
373
- ```
374
-
375
- #### Update Installation
376
-
377
- ```ruby
378
- client.app.installations.update!(:id => 123, :settings => { :title => "My New Name" })
379
-
380
- installation = ZendeskAPI::AppInstallation.new(client, :id => 123)
381
- installation.settings = { :title => "My New Name" }
382
- installation.save!
383
-
384
- ZendeskAPI::AppInstallation.update!(client, :id => 123, :settings => { :title => "My New Name" })
385
- ```
386
-
387
- #### Delete Installation
388
-
389
- ```ruby
390
- client.app.installations.destroy!(:id => 123)
391
-
392
- installation = ZendeskAPI::AppInstallation.new(client, :id => 123)
393
- installation.destroy!
394
-
395
- ZendeskAPI::AppInstallation.destroy!(client, :id => 123)
396
- ```
397
-
398
-
399
- ## Note on Patches/Pull Requests
400
- 1. Fork the project.
401
- 2. Make your feature addition or bug fix.
402
- 3. Add tests for it. This is important so I don't break it in a future version
403
- unintentionally.
404
- 4. Commit, do not mess with rakefile, version, or history. (if you want to have
405
- your own version, that is fine but bump version in a commit by itself I can
406
- ignore when I pull)
407
- 5. Send me a pull request. Bonus points for topic branches.
408
-
409
- ## Supported Ruby Versions
410
-
411
- Tested with Ruby 1.9, 2.0, 2.1, 2.2 and jRuby.
412
- [![Build Status](https://secure.travis-ci.org/zendesk/zendesk_api_client_rb.png?branch=master)](http://travis-ci.org/zendesk/zendesk_api_client_rb)
413
- [![Gem Version](https://badge.fury.io/rb/zendesk_api.png)](http://badge.fury.io/rb/zendesk_api)
414
- [![Code Climate](https://codeclimate.com/github/zendesk/zendesk_api_client_rb.png)](https://codeclimate.com/github/zendesk/zendesk_api_client_rb)
415
-
416
- ## Copyright and license
417
-
418
- Copyright 2014 Zendesk
419
-
420
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
421
- You may obtain a copy of the License at
422
-
423
- http://www.apache.org/licenses/LICENSE-2.0
424
-
425
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
data/Rakefile DELETED
@@ -1,52 +0,0 @@
1
- require 'rake/testtask'
2
- require 'bundler/gem_tasks'
3
- require 'bump/tasks'
4
-
5
- begin
6
- require 'rspec/core/rake_task'
7
- rescue LoadError
8
- end
9
-
10
- if defined?(RSpec)
11
- desc "Run specs"
12
- RSpec::Core::RakeTask.new("spec") do |t|
13
- t.pattern = "spec/core/**/*_spec.rb"
14
- end
15
-
16
- desc "Run live specs"
17
- RSpec::Core::RakeTask.new("spec:live") do |t|
18
- t.pattern = "spec/live/**/*_spec.rb"
19
- end
20
-
21
- task :clean_live do
22
- sh "rm -rf spec/fixtures/cassettes"
23
- end
24
-
25
- if RUBY_VERSION =~ /1.9/
26
- desc "Find coverage"
27
- task "spec:coverage" do
28
- ENV["COVERAGE"] = "yes"
29
- Rake::Task["spec"].invoke
30
- end
31
- end
32
-
33
- desc 'Default: run specs.'
34
- task :default => "spec"
35
- end
36
-
37
- # extracted from https://github.com/grosser/project_template
38
- rule /^version:bump:.*/ do |t|
39
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
40
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
41
- file = 'lib/zendesk_api/version.rb'
42
-
43
- version_file = File.read(file)
44
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
45
- version_parts[index] = version_parts[index].to_i + 1
46
- version_parts[2] = 0 if index < 2 # remove patch for minor
47
- version_parts[1] = 0 if index < 1 # remove minor for major
48
- new_version = version_parts * '.'
49
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
50
-
51
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
52
- end