zendesk_api 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- zendesk_api (0.1.9)
10
+ zendesk_api (0.1.10)
11
11
  faraday (>= 0.8.0)
12
12
  faraday_middleware (>= 0.8.7)
13
13
  hashie
data/Readme.md CHANGED
@@ -208,6 +208,16 @@ client.users.find(:id => 'me')
208
208
  client.current_user
209
209
  ```
210
210
 
211
+ ### Special Case: Importing a ticket
212
+
213
+ Bulk importing tickets allows you to move large amounts of data into Zendesk.
214
+
215
+ ```ruby
216
+ ticket = ZendeskAPI::Ticket.import(client, :subject => "Help", :comments => [{ :author_id => 19, :value => "This is a comment" }])
217
+ ```
218
+
219
+ http://developer.zendesk.com/documentation/rest_api/ticket_import.html
220
+
211
221
  ### Attaching files
212
222
 
213
223
  Files can be attached to ticket comments using either a path or the File class and will
@@ -220,7 +220,7 @@ module ZendeskAPI
220
220
  klass.find(@client, :id => resource_id, :association => instance_association)
221
221
  elsif found = method_missing(resource_name.to_sym)
222
222
  wrap_resource(found, klass, class_level_association)
223
- elsif klass.ancestors.include?(DataResource)
223
+ elsif klass.superclass == DataResource
224
224
  rescue_client_error do
225
225
  response = @client.connection.get(instance_association.generate_path(:with_parent => true))
226
226
  klass.new(@client, response.body[klass.singular_resource_name].merge(:association => instance_association))
@@ -193,7 +193,9 @@ module ZendeskAPI
193
193
  alias :save! :save
194
194
  end
195
195
 
196
- class TicketMetric < ReadResource; end
196
+ class TicketMetric < DataResource
197
+ include Read
198
+ end
197
199
 
198
200
  class Ticket < Resource
199
201
  class Audit < DataResource; end
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -11,6 +11,11 @@ describe ZendeskAPI::Association do
11
11
  ZendeskAPI::TestResource.has :child, :class => ZendeskAPI::TestResource::TestChild
12
12
  end
13
13
 
14
+ it "should not try and fetch nil child" do
15
+ instance.child_id = nil
16
+ instance.child.should be_nil
17
+ end
18
+
14
19
  it "should cache an set object" do
15
20
  instance.child = child
16
21
  instance.child.should == child
@@ -22,11 +27,6 @@ describe ZendeskAPI::Association do
22
27
  instance.child_id.should == child.id
23
28
  end
24
29
 
25
- it "should not set id on set if it was not there" do
26
- instance.child = child
27
- instance.child_id.should == nil
28
- end
29
-
30
30
  it "should build a object set via hash" do
31
31
  instance.child = {:id => 2}
32
32
  instance.child.id.should == 2
@@ -37,9 +37,8 @@ describe ZendeskAPI::Association do
37
37
  instance.child.id.should == 2
38
38
  end
39
39
 
40
- it "should fetch a unknown object" do
41
- stub_json_request(:get, %r{test_resources/1/child}, json(:test_child => {:id => 2}))
42
- instance.child.id.should == 2
40
+ it "should not fetch an unknown object" do
41
+ instance.child.should be_nil
43
42
  end
44
43
 
45
44
  it "should fetch an object known by id" do
@@ -77,8 +77,8 @@ describe ZendeskAPI::DataResource do
77
77
 
78
78
  context "instance method" do
79
79
  context "with no side-loading" do
80
- subject { ZendeskAPI::TestResource.new(client, :id => 1) }
81
- before(:each) { stub_json_request(:get, %r{test_resources/\d+/test_resource}, json(:test_resource => {})) }
80
+ subject { ZendeskAPI::TestResource.new(client, :id => 1, :test_resource_id => 1) }
81
+ before(:each) { stub_json_request(:get, %r{test_resources/\d+}, json(:test_resource => {})) }
82
82
 
83
83
  it "should attempt to grab the resource from the host" do
84
84
  subject.test_resource.should be_instance_of(ZendeskAPI::TestResource)
@@ -89,7 +89,7 @@ describe ZendeskAPI::DataResource do
89
89
  end
90
90
 
91
91
  context "with a client error" do
92
- before(:each) { stub_request(:get, %r{test_resources/\d+/test_resource}).to_return(:status => 500) }
92
+ before(:each) { stub_request(:get, %r{test_resources/\d+}).to_return(:status => 500) }
93
93
 
94
94
  it "should handle it properly" do
95
95
  expect { silence_logger{ subject.test_resource.should be_nil } }.to_not raise_error
@@ -99,7 +99,7 @@ describe ZendeskAPI::DataResource do
99
99
  context "with an explicit path set" do
100
100
  before(:each) do
101
101
  ZendeskAPI::TestResource.has ZendeskAPI::TestResource, :path => "blergh"
102
- stub_json_request(:get, %r{test_resources/\d+/blergh}, json(:test_resource => {}))
102
+ stub_json_request(:get, %r{blergh/\d+}, json(:test_resource => {}))
103
103
  end
104
104
 
105
105
  it "should call the right path" do
@@ -380,6 +380,14 @@ describe ZendeskAPI::Resource do
380
380
  end
381
381
  end
382
382
 
383
+ context "Ticket#assignee" do
384
+ subject { ZendeskAPI::Ticket.new(client, :id => 1, :assignee_id => nil) }
385
+
386
+ it "should not try and make a request" do
387
+ subject.assignee.should be_nil
388
+ end
389
+ end
390
+
383
391
  context "#new" do
384
392
  it "builds with hash" do
385
393
  object = ZendeskAPI::TestResource.new(client, {})
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: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-29 00:00:00.000000000 Z
13
+ date: 2012-11-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bump