zendesk_api 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f96cd9aa680347c9634cc608bc65f7affac55544
4
- data.tar.gz: 0e5fafac15dbfe359c94b57ee2f124ae6795dd39
3
+ metadata.gz: a38c30bb79c695637d397682d18f4bcad759e04a
4
+ data.tar.gz: 7a9c3754599b4326995b7b7567561f57b1ff3cce
5
5
  SHA512:
6
- metadata.gz: e0140e3e10c944a83b1edd18c2b11283d80dbbc23f6e45be3697d0cf480fd8bf8349b79e4394873091ae44e742436954817bba12c3ef41768d8b28a0c1371413
7
- data.tar.gz: 9c32f20050b1d1d2b1531abb11cd52d9f197be15bd6a17c97598bd38721bbbce97faac675fa66cb233373ee6c672d4faea0a9fe19576f9655619ecb06025b4f9
6
+ metadata.gz: a6599cae801cf71f177e2b6110d6200a8dc623eae347bcea7341c0afdc1fd5c4e6686311645aeabe15ecffc6dc7ae0ee1503941571ef70321da5a4f7c69dc387
7
+ data.tar.gz: 63d41052bf169196d521f833295e5b6fd46a2f5253e53fa314133bc65e4502ff29ce7c2534854a92928f89acf2b5e6877953825fdd3ce545e2f81adca60aebee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zendesk_api (1.3.4)
4
+ zendesk_api (1.3.5)
5
5
  faraday (~> 0.9)
6
6
  hashie (>= 1.2)
7
7
  inflection
@@ -45,7 +45,7 @@ GEM
45
45
  fssm (0.2.10)
46
46
  haml (4.0.5)
47
47
  tilt
48
- hashie (2.0.5)
48
+ hashie (2.1.0)
49
49
  i18n (0.6.9)
50
50
  inflection (1.0.0)
51
51
  json (1.8.1)
@@ -153,6 +153,18 @@ module ZendeskAPI
153
153
  include Create
154
154
  include Update
155
155
  include Destroy
156
+
157
+ def self.import!(client, attributes)
158
+ new(client, attributes).tap do |comment|
159
+ comment.save!(:path => 'import/' + comment.path)
160
+ end
161
+ end
162
+
163
+ def self.import(client, attributes)
164
+ comment = new(client, attributes)
165
+ return unless comment.save(:path => 'import/' + comment.path)
166
+ comment
167
+ end
156
168
  end
157
169
 
158
170
  class TopicVote < SingularResource
@@ -178,6 +190,18 @@ module ZendeskAPI
178
190
  association = ZendeskAPI::Association.new(:class => TopicVote, :parent => self, :path => 'votes')
179
191
  @votes = ZendeskAPI::Collection.new(@client, TopicVote, opts.merge(:association => association))
180
192
  end
193
+
194
+ def self.import!(client, attributes)
195
+ new(client, attributes).tap do |topic|
196
+ topic.save!(:path => "import/topics")
197
+ end
198
+ end
199
+
200
+ def self.import(client, attributes)
201
+ topic = new(client, attributes)
202
+ return unless topic.save(:path => "import/topics")
203
+ topic
204
+ end
181
205
  end
182
206
 
183
207
  class Activity < Resource
@@ -336,6 +360,16 @@ module ZendeskAPI
336
360
  ZendeskAPI::Collection.new(client, self, :path => "exports/tickets?start_time=#{start_time.to_i}")
337
361
  end
338
362
 
363
+ # Imports a ticket through the imports/tickets endpoint using save!
364
+ # @param [Client] client The {Client} object to be used
365
+ # @param [Hash] attributes The attributes to create.
366
+ # @return [Ticket] Created object or nil
367
+ def self.import!(client, attributes)
368
+ new(client, attributes).tap do |ticket|
369
+ ticket.save!(:path => "imports/tickets")
370
+ end
371
+ end
372
+
339
373
  # Imports a ticket through the imports/tickets endpoint
340
374
  # @param [Client] client The {Client} object to be used
341
375
  # @param [Hash] attributes The attributes to create.
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -11,6 +11,22 @@ describe ZendeskAPI::Topic::TopicComment do
11
11
  it_should_be_deletable
12
12
  it_should_be_readable topic, :comments
13
13
  end
14
+
15
+ describe ".import" do
16
+ it "can import" do
17
+ VCR.use_cassette("topic_comment_import_can_import") do
18
+ old = Time.now - 4*365*24*60*60
19
+ comment = ZendeskAPI::Topic::TopicComment.import(client, valid_attributes.merge(:created_at => old, :topic_id => topic.id))
20
+ ZendeskAPI::Topic::TopicComment.find(client, comment).created_at.year.should == old.year
21
+ end
22
+ end
23
+
24
+ it "returns nothing if import fails" do
25
+ VCR.use_cassette("topic_comment_import_cannot_import") do
26
+ silence_logger { ZendeskAPI::Topic::TopicComment.import(client, {}).should == nil }
27
+ end
28
+ end
29
+ end
14
30
  end
15
31
 
16
32
  describe ZendeskAPI::User::TopicComment do
@@ -2,7 +2,7 @@ require 'core/spec_helper'
2
2
 
3
3
  describe ZendeskAPI::Topic do
4
4
  def valid_attributes
5
- {
5
+ {
6
6
  :forum_id => forum.id, :title => "My Topic",
7
7
  :body => "The mayan calendar ends December 31st. Coincidence? I think not."
8
8
  }
@@ -14,5 +14,21 @@ describe ZendeskAPI::Topic do
14
14
  it_should_be_readable :topics
15
15
  it_should_be_readable current_user, :topics
16
16
  it_should_be_readable forum, :topics
17
- #it_should_be_readable :topics, :show_many, :verb => :post, :ids =>
17
+ #it_should_be_readable :topics, :show_many, :verb => :post, :ids =>
18
+
19
+ describe ".import" do
20
+ it "can import" do
21
+ VCR.use_cassette("topic_import_can_import") do
22
+ old = Time.now - 5*365*24*60*60
23
+ topic = ZendeskAPI::Topic.import(client, valid_attributes.merge(:created_at => old))
24
+ ZendeskAPI::Topic.find(client, topic).created_at.year.should == old.year
25
+ end
26
+ end
27
+
28
+ it "returns nothing if import fails" do
29
+ VCR.use_cassette("topic_import_cannot_import") do
30
+ silence_logger { ZendeskAPI::Topic.import(client, {}).should == nil }
31
+ end
32
+ end
33
+ end
18
34
  end
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.3.4
4
+ version: 1.3.5
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: 2014-03-27 00:00:00.000000000 Z
12
+ date: 2014-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bump