zendesk2 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODU3ZjQzNTA5Y2UzYzM5NmEwZDEyM2QyNjk1NmRmYjFhZDliMTkwNg==
5
+ data.tar.gz: !binary |-
6
+ NTJjNmY4MTVmN2UwYjM5MmY0YmIzODA3YzNiNDI5MWYzNTAxZjdhNw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzA2Y2E0MmI2NzA5MDZmMmRhZjZlNmY3MDQyZDM5YzY4NGU2NWI3NDJjNWNj
10
+ MTkyYjJhNzllMDgyNjMxZjAzZGYyMDA5ODVlM2QzNThlNmQ3NjdjNTM1ZWI4
11
+ OTFmODQyODVlOTYwNTkzNTE3ODJmZjA2NzlmMGVjMzY1MDhhMTk=
12
+ data.tar.gz: !binary |-
13
+ MGNkMjE0M2M4OGFmOTQ4MjM2YTU2Y2M1NzRmMTg4NDFmMGEzZDE0YWM0NDA4
14
+ N2I3MjE2YTNmMTAzM2ViOTVkYjgxMDJkOWNkZTUzNTM2ZWQ1ZWJjN2EzOGFl
15
+ MGZhOTQ2MWY0NDI4OGFhMjM2MGExZDM1ZThlOWU0ZGExZDhjNjA=
data/Guardfile CHANGED
@@ -3,9 +3,9 @@ guard 'bundler' do
3
3
  watch(/^.+\.gemspec/)
4
4
  end
5
5
 
6
- guard 'rspec' do
6
+ guard 'rspec', cmd: 'bundle exec rspec' do
7
7
  watch(%r{^spec/.+_spec\.rb$})
8
8
  watch(%r{^lib/(.+)\.rb$}) { "spec" }
9
9
  watch('spec/spec_helper.rb') { "spec" }
10
- watch(%r{^spec/(support|matchers|shared)/(.+)\.rb$}) { "spec" }
10
+ watch(%r{^spec/(support|matchers|shared)/(.+)\.rb$}) { "spec" }
11
11
  end
@@ -1,19 +1,35 @@
1
1
  class Zendesk2::Client::Organization < Zendesk2::Model
2
- PARAMS = %w[id details domain_names external_id group_id shared_comments shared_tickets tags name notes]
3
-
4
- identity :id, type: :integer
5
- attribute :url, type: :string
6
- attribute :created_at, type: :time
7
- attribute :details, type: :string
8
- attribute :domain_names, type: :array
9
- attribute :external_id, type: :string
10
- attribute :group_id, type: :integer
11
- attribute :shared_comments, type: :boolean
12
- attribute :shared_tickets, type: :boolean
13
- attribute :tags, type: :array
14
- attribute :name, type: :string
15
- attribute :notes, type: :string
16
- attribute :updated_at, type: :time
2
+ PARAMS = %w[id details domain_names external_id group_id organization_fields shared_comments shared_tickets tags name notes]
3
+
4
+ # @return [integer] Automatically assigned when creating organization
5
+ identity :id, type: :integer # ro[yes] required[no]
6
+
7
+ # @return [Date] The time the organization was created
8
+ attribute :created_at, type: :date # ro[yes] required[no]
9
+ # @return [String] In this field you can store any details obout the organization. e.g. the address
10
+ attribute :details, type: :string # ro[no] required[no]
11
+ # @return [Array] An array of domain names associated with this organization
12
+ attribute :domain_names, type: :array # ro[no] required[no]
13
+ # @return [String] A unique external id, you can use this to associate organizations to an external record
14
+ attribute :external_id, type: :string # ro[no] required[no]
15
+ # @return [Integer] New tickets from users in this organization will automatically be put in this group
16
+ attribute :group_id, type: :integer # ro[no] required[no]
17
+ # @return [String] The name of the organization
18
+ attribute :name, type: :string # ro[no] required[yes]
19
+ # @return [String] In this field you can store any notes you have about the organization
20
+ attribute :notes, type: :string # ro[no] required[no]
21
+ # @return [Hash] Custom fields for this organization
22
+ attribute :organization_fields, type: :hash # ro[no] required[no]
23
+ # @return [Boolean] End users in this organization are able to see each other's comments on tickets
24
+ attribute :shared_comments, type: :boolean # ro[no] required[no]
25
+ # @return [Boolean] End users in this organization are able to see each other's tickets
26
+ attribute :shared_tickets, type: :boolean # ro[no] required[no]
27
+ # @return [Array] The tags of the organization
28
+ attribute :tags, type: :array # ro[no] required[no]
29
+ # @return [Date] The time of the last update of the organization
30
+ attribute :updated_at, type: :date # ro[yes] required[no]
31
+ # @return [String] The API url of this organization
32
+ attribute :url, type: :string # ro[yes] required[no]
17
33
 
18
34
  def destroy!
19
35
  requires :identity
@@ -56,4 +72,4 @@ class Zendesk2::Client::Organization < Zendesk2::Model
56
72
  writable_attributes.delete("group_id") if writable_attributes["group_id"].to_s == "0"
57
73
  writable_attributes
58
74
  end
59
- end
75
+ end
@@ -14,9 +14,10 @@ class Zendesk2::Client
14
14
  def get_topic_comments(params={})
15
15
  topic_id = params["topic_id"]
16
16
  topic = self.data[:topics][topic_id] # TODO: 404 if !topic
17
- filter = lambda{|comments| comments.select{|c| c["topic_id"] == topic_id}}
17
+ filter = lambda { |comments| comments.select { |c| c["topic_id"] == topic_id } }
18
18
 
19
- page(params, :topic_comments, "/topics/#{topic_id}/comments.json", "topic_comments", filter: filter)
19
+ page(params, :topic_comments, "/topics/#{topic_id}/comments.json", "topic_comments", filter: filter).tap do
20
+ end
20
21
  end
21
22
  end
22
23
  end
@@ -13,12 +13,19 @@ class Zendesk2::Collection < Cistern::Collection
13
13
  def model_method; self.class.model_method; end
14
14
  def model_root; self.class.model_root; end
15
15
 
16
+ def new_page
17
+ page = self.clone
18
+ %w[count next_page_link previous_page_link].each { |k| page.attributes.delete(k) }
19
+ page.records = []
20
+ page
21
+ end
22
+
16
23
  def next_page
17
- clone.clear.all("url" => next_page_link) if next_page_link
24
+ new_page.all("url" => next_page_link) if next_page_link
18
25
  end
19
26
 
20
27
  def previous_page
21
- clone.clear.all("url" => previous_page_link) if previous_page_link
28
+ new_page.all("url" => previous_page_link) if previous_page_link
22
29
  end
23
30
 
24
31
  # Attempt creation of resource and explode if unsuccessful
@@ -39,13 +46,12 @@ class Zendesk2::Collection < Cistern::Collection
39
46
 
40
47
  # Fetch a collection of resources
41
48
  def all(params={})
42
- scoped_attributes = self.class.scopes.inject({}){|r,k| r.merge(k.to_s => send(k))}
43
- scoped_attributes.merge!(params)
49
+ scoped_attributes = self.class.scopes.inject({}){|r,k| r.merge(k.to_s => send(k))}.merge(params)
44
50
  body = connection.send(collection_method, scoped_attributes).body
45
51
 
46
- collection = self.load(body[collection_root])
47
- collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
48
- collection
52
+ self.load(body[collection_root])
53
+ self.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
54
+ self
49
55
  end
50
56
 
51
57
  # Fetch a single of resource
@@ -1,3 +1,3 @@
1
1
  module Zendesk2
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/zendesk2.rb CHANGED
@@ -6,6 +6,7 @@ require 'cistern'
6
6
  require 'faraday'
7
7
  require 'faraday_middleware'
8
8
  require 'jwt'
9
+
9
10
  # stdlib
10
11
  require 'forwardable'
11
12
  require 'logger'
@@ -17,7 +17,7 @@ shared_examples "a resource" do |_collection, _params, _update_params, _options|
17
17
 
18
18
  context "that is paged" do
19
19
  before(:each) do
20
- 2.times.each { collection.create(instance_exec(&_params)) }
20
+ 3.times.each { collection.create(instance_exec(&_params)) }
21
21
  end
22
22
 
23
23
  it "by retrieving the first page" do
@@ -44,7 +44,7 @@ shared_examples "a resource" do |_collection, _params, _update_params, _options|
44
44
  update_params.each {|k,v| record.send(k).should == v}
45
45
  end
46
46
 
47
- it "by destroy a record" do
47
+ it "by destroying a record" do
48
48
  pending if _collection == :forums
49
49
  record = collection.create(params)
50
50
  record.identity.should_not be_nil
data/zendesk2.gemspec CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Zendesk2::VERSION
18
18
 
19
19
  gem.add_dependency "addressable"
20
- gem.add_dependency "cistern", "~> 0.3.0"
21
- gem.add_dependency "faraday"
20
+ gem.add_dependency "cistern", "~> 0.5.1"
21
+ gem.add_dependency "faraday", "~> 0.8.8"
22
22
  gem.add_dependency "faraday_middleware"
23
23
  gem.add_dependency "jwt"
24
24
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Josh Lane
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-26 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: addressable
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,39 +27,34 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: cistern
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 0.3.0
33
+ version: 0.5.1
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 0.3.0
40
+ version: 0.5.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: faraday
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 0.8.8
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: 0.8.8
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: faraday_middleware
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: jwt
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -226,27 +215,26 @@ files:
226
215
  homepage: http://joshualane.com/zendesk2
227
216
  licenses:
228
217
  - MIT
218
+ metadata: {}
229
219
  post_install_message:
230
220
  rdoc_options: []
231
221
  require_paths:
232
222
  - lib
233
223
  required_ruby_version: !ruby/object:Gem::Requirement
234
- none: false
235
224
  requirements:
236
225
  - - ! '>='
237
226
  - !ruby/object:Gem::Version
238
227
  version: '0'
239
228
  required_rubygems_version: !ruby/object:Gem::Requirement
240
- none: false
241
229
  requirements:
242
230
  - - ! '>='
243
231
  - !ruby/object:Gem::Version
244
232
  version: '0'
245
233
  requirements: []
246
234
  rubyforge_project:
247
- rubygems_version: 1.8.25
235
+ rubygems_version: 2.2.0
248
236
  signing_key:
249
- specification_version: 3
237
+ specification_version: 4
250
238
  summary: Zendesk V2 API client
251
239
  test_files:
252
240
  - spec/categories_spec.rb