zendesk_api 1.10.0 → 1.11.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.
- checksums.yaml +4 -4
- data/lib/zendesk_api/actions.rb +15 -0
- data/lib/zendesk_api/collection.rb +4 -4
- data/lib/zendesk_api/resources.rb +5 -3
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/bulk_actions_spec.rb +24 -0
- data/spec/core/collection_spec.rb +7 -0
- data/spec/fixtures/test_resources.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f04331148b43249696fcfbea617e9242e0b7d597
|
4
|
+
data.tar.gz: 1aa537ce2df9a606a33c97460a2d2d86fb9fec19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bfcb398032df2f2bffe40fd32474064e9128b4323d92492462410c2258325bea6ce23aaec29410650b1e39004a3d0eea23b0d34d38725be93a3ffdd4e8745d6
|
7
|
+
data.tar.gz: a66440a160427849ad63d6c56dcc4e18d346575888adb6c182de23ff34ffcf30a22018590a1ca3029032ebd2babafa06c43a3424cee71211215a27cd8f870fba
|
data/lib/zendesk_api/actions.rb
CHANGED
@@ -255,4 +255,19 @@ module ZendeskAPI
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
end
|
258
|
+
|
259
|
+
module UpdateMany
|
260
|
+
def update_many!(client, ids, attributes)
|
261
|
+
association = attributes.delete(:association) || Association.new(:class => self)
|
262
|
+
|
263
|
+
response = client.connection.put("#{association.generate_path}/update_many") do |req|
|
264
|
+
req.params = { :ids => ids.join(',') }
|
265
|
+
req.body = { singular_resource_name => attributes }
|
266
|
+
|
267
|
+
yield req if block_given?
|
268
|
+
end
|
269
|
+
|
270
|
+
JobStatus.new_from_response(client, response)
|
271
|
+
end
|
272
|
+
end
|
258
273
|
end
|
@@ -47,7 +47,7 @@ module ZendeskAPI
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Methods that take a Hash argument
|
50
|
-
methods = %w{create find update destroy}
|
50
|
+
methods = %w{create find update update_many destroy}
|
51
51
|
methods += methods.map {|method| method + "!"}
|
52
52
|
methods.each do |deferrable|
|
53
53
|
# Passes arguments and the proper path to the resource class method.
|
@@ -57,10 +57,10 @@ module ZendeskAPI
|
|
57
57
|
raise NoMethodError.new("undefined method \"#{deferrable}\" for #{@resource_class}", deferrable, args)
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
args << {} unless args.last.is_a?(Hash)
|
61
|
+
args.last.merge!(:association => @association)
|
62
62
|
|
63
|
-
@resource_class.send(deferrable, @client,
|
63
|
+
@resource_class.send(deferrable, @client, *args)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -125,7 +125,7 @@ module ZendeskAPI
|
|
125
125
|
# Gets a incremental export of organizations from the start_time until now.
|
126
126
|
# @param [Client] client The {Client} object to be used
|
127
127
|
# @param [Integer] start_time The start_time parameter
|
128
|
-
# @return [Collection] Collection of {
|
128
|
+
# @return [Collection] Collection of {Organization}
|
129
129
|
def self.incremental_export(client, start_time)
|
130
130
|
ZendeskAPI::Collection.new(client, self, :path => "incremental/organizations?start_time=#{start_time.to_i}")
|
131
131
|
end
|
@@ -370,13 +370,15 @@ module ZendeskAPI
|
|
370
370
|
# Gets a incremental export of ticket events from the start_time until now.
|
371
371
|
# @param [Client] client The {Client} object to be used
|
372
372
|
# @param [Integer] start_time The start_time parameter
|
373
|
-
# @return [Collection] Collection of {
|
373
|
+
# @return [Collection] Collection of {TicketEvent}
|
374
374
|
def self.incremental_export(client, start_time)
|
375
375
|
ZendeskAPI::Collection.new(client, self, :path => "incremental/ticket_events?start_time=#{start_time.to_i}")
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
379
379
|
class Ticket < Resource
|
380
|
+
extend UpdateMany
|
381
|
+
|
380
382
|
class Audit < DataResource
|
381
383
|
class Event < Data
|
382
384
|
has :author, :class => User
|
@@ -673,7 +675,7 @@ module ZendeskAPI
|
|
673
675
|
# Gets a incremental export of users from the start_time until now.
|
674
676
|
# @param [Client] client The {Client} object to be used
|
675
677
|
# @param [Integer] start_time The start_time parameter
|
676
|
-
# @return [Collection] Collection of {
|
678
|
+
# @return [Collection] Collection of {User}
|
677
679
|
def self.incremental_export(client, start_time)
|
678
680
|
ZendeskAPI::Collection.new(client, self, :path => "incremental/users?start_time=#{start_time.to_i}")
|
679
681
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
@@ -42,4 +42,28 @@ describe ZendeskAPI::CreateMany do
|
|
42
42
|
expect(@response.id).to eq('def')
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
describe ZendeskAPI::UpdateMany do
|
47
|
+
subject { ZendeskAPI::BulkTestResource }
|
48
|
+
|
49
|
+
context "update_many!" do
|
50
|
+
let(:attributes) { {:name => 'A', :age => 25} }
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
stub_json_request(:put, %r{bulk_test_resources/update_many}, json(:job_status => {:id => 'ghi'}))
|
54
|
+
@response = subject.update_many!(client, [1,2,3], attributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'calls the update_many endpoint' do
|
58
|
+
assert_requested(:put, %r{bulk_test_resources/update_many\?ids=1,2,3$},
|
59
|
+
:body => json(:bulk_test_resource => attributes)
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns a JobStatus' do
|
64
|
+
expect(@response).to be_instance_of(ZendeskAPI::JobStatus)
|
65
|
+
expect(@response.id).to eq('ghi')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
45
69
|
end
|
@@ -42,6 +42,13 @@ describe ZendeskAPI::Collection do
|
|
42
42
|
assert_requested(:delete, %r{bulk_test_resources/destroy_many\?ids=1,2,3$})
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should defer #update_many! to the resource class" do
|
46
|
+
collection = ZendeskAPI::Collection.new(client, ZendeskAPI::BulkTestResource)
|
47
|
+
stub_json_request(:put, %r{bulk_test_resources/update_many\?}, json(:job_status => {}))
|
48
|
+
collection.update_many!([1,2,3], {:name => 'Mick'})
|
49
|
+
assert_requested(:put, %r{bulk_test_resources/update_many\?ids=1,2,3$})
|
50
|
+
end
|
51
|
+
|
45
52
|
it "should defer #create to the resource class" do
|
46
53
|
stub_json_request(:post, %r{test_resources$}, json(:test_resource => {}))
|
47
54
|
subject.create
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Davidovitz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bump
|
@@ -339,7 +339,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
339
339
|
version: 1.3.6
|
340
340
|
requirements: []
|
341
341
|
rubyforge_project:
|
342
|
-
rubygems_version: 2.4.
|
342
|
+
rubygems_version: 2.4.5
|
343
343
|
signing_key:
|
344
344
|
specification_version: 4
|
345
345
|
summary: Zendesk REST API Client
|