zendesk_api 0.1.11 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +1 -3
  3. data/Gemfile +24 -0
  4. data/Gemfile.lock +75 -10
  5. data/Procfile +1 -0
  6. data/Rakefile +10 -3
  7. data/Readme.md +65 -0
  8. data/bin/zendesk +26 -0
  9. data/config.ru +6 -0
  10. data/config/mongoid.yml +81 -0
  11. data/lib/zendesk_api/actions.rb +2 -2
  12. data/lib/zendesk_api/collection.rb +15 -4
  13. data/lib/zendesk_api/console/base.rb +12 -0
  14. data/lib/zendesk_api/console/console.rb +144 -0
  15. data/lib/zendesk_api/console/extensions.rb +183 -0
  16. data/lib/zendesk_api/console/options.rb +41 -0
  17. data/lib/zendesk_api/resource.rb +12 -1
  18. data/lib/zendesk_api/resources.rb +28 -8
  19. data/lib/zendesk_api/server/base.rb +119 -0
  20. data/lib/zendesk_api/server/docs/account_settings.md +145 -0
  21. data/lib/zendesk_api/server/docs/activity_stream.md +121 -0
  22. data/lib/zendesk_api/server/docs/attachments.md +73 -0
  23. data/lib/zendesk_api/server/docs/autocomplete.md +29 -0
  24. data/lib/zendesk_api/server/docs/categories.md +193 -0
  25. data/lib/zendesk_api/server/docs/custom_roles.md +88 -0
  26. data/lib/zendesk_api/server/docs/forum_subscriptions.md +139 -0
  27. data/lib/zendesk_api/server/docs/forums.md +229 -0
  28. data/lib/zendesk_api/server/docs/group_memberships.md +229 -0
  29. data/lib/zendesk_api/server/docs/groups.md +212 -0
  30. data/lib/zendesk_api/server/docs/introduction.md +159 -0
  31. data/lib/zendesk_api/server/docs/job_statuses.md +86 -0
  32. data/lib/zendesk_api/server/docs/locales.md +124 -0
  33. data/lib/zendesk_api/server/docs/macros.md +287 -0
  34. data/lib/zendesk_api/server/docs/organizations.md +253 -0
  35. data/lib/zendesk_api/server/docs/problems.md +117 -0
  36. data/lib/zendesk_api/server/docs/requests.md +256 -0
  37. data/lib/zendesk_api/server/docs/satisfaction_ratings.md +136 -0
  38. data/lib/zendesk_api/server/docs/search.md +106 -0
  39. data/lib/zendesk_api/server/docs/sharing_agreements.md +57 -0
  40. data/lib/zendesk_api/server/docs/side_loading.md +125 -0
  41. data/lib/zendesk_api/server/docs/suspended_tickets.md +182 -0
  42. data/lib/zendesk_api/server/docs/tags.md +36 -0
  43. data/lib/zendesk_api/server/docs/ticket_audits.md +657 -0
  44. data/lib/zendesk_api/server/docs/ticket_export.md +121 -0
  45. data/lib/zendesk_api/server/docs/ticket_fields.md +277 -0
  46. data/lib/zendesk_api/server/docs/ticket_import.md +65 -0
  47. data/lib/zendesk_api/server/docs/ticket_metrics.md +125 -0
  48. data/lib/zendesk_api/server/docs/tickets.md +622 -0
  49. data/lib/zendesk_api/server/docs/topic_comments.md +221 -0
  50. data/lib/zendesk_api/server/docs/topic_subscriptions.md +140 -0
  51. data/lib/zendesk_api/server/docs/topic_votes.md +154 -0
  52. data/lib/zendesk_api/server/docs/topics.md +335 -0
  53. data/lib/zendesk_api/server/docs/triggers.md +199 -0
  54. data/lib/zendesk_api/server/docs/user_identities.md +279 -0
  55. data/lib/zendesk_api/server/docs/users.md +400 -0
  56. data/lib/zendesk_api/server/docs/views.md +505 -0
  57. data/lib/zendesk_api/server/helper.rb +104 -0
  58. data/lib/zendesk_api/server/html_renderer.rb +98 -0
  59. data/lib/zendesk_api/server/models/user_request.rb +16 -0
  60. data/lib/zendesk_api/server/models/zlib_json.rb +13 -0
  61. data/lib/zendesk_api/server/public/config.rb +26 -0
  62. data/lib/zendesk_api/server/public/favicon.ico +0 -0
  63. data/lib/zendesk_api/server/public/images/glyphicons-halflings-white.png +0 -0
  64. data/lib/zendesk_api/server/public/images/glyphicons-halflings.png +0 -0
  65. data/lib/zendesk_api/server/public/images/spinner.gif +0 -0
  66. data/lib/zendesk_api/server/public/images/zendesk_developers_bg.png +0 -0
  67. data/lib/zendesk_api/server/public/images/zendesk_developers_header.png +0 -0
  68. data/lib/zendesk_api/server/public/javascripts/application.js +186 -0
  69. data/lib/zendesk_api/server/public/javascripts/bootstrap-alert.js +90 -0
  70. data/lib/zendesk_api/server/public/javascripts/bootstrap-button.js +96 -0
  71. data/lib/zendesk_api/server/public/javascripts/bootstrap-carousel.js +169 -0
  72. data/lib/zendesk_api/server/public/javascripts/bootstrap-collapse.js +157 -0
  73. data/lib/zendesk_api/server/public/javascripts/bootstrap-dropdown.js +100 -0
  74. data/lib/zendesk_api/server/public/javascripts/bootstrap-modal.js +218 -0
  75. data/lib/zendesk_api/server/public/javascripts/bootstrap-popover.js +98 -0
  76. data/lib/zendesk_api/server/public/javascripts/bootstrap-scrollspy.js +151 -0
  77. data/lib/zendesk_api/server/public/javascripts/bootstrap-tab.js +135 -0
  78. data/lib/zendesk_api/server/public/javascripts/bootstrap-tooltip.js +275 -0
  79. data/lib/zendesk_api/server/public/javascripts/bootstrap-transition.js +61 -0
  80. data/lib/zendesk_api/server/public/javascripts/bootstrap-typeahead.js +285 -0
  81. data/lib/zendesk_api/server/public/sass/screen.scss +102 -0
  82. data/lib/zendesk_api/server/public/sass/styles.scss +5 -0
  83. data/lib/zendesk_api/server/public/stylesheets/developer.screen.css +836 -0
  84. data/lib/zendesk_api/server/public/stylesheets/screen.css +129 -0
  85. data/lib/zendesk_api/server/public/stylesheets/styles.css +6208 -0
  86. data/lib/zendesk_api/server/templates/footer.haml +13 -0
  87. data/lib/zendesk_api/server/templates/header.haml +20 -0
  88. data/lib/zendesk_api/server/templates/index.haml +68 -0
  89. data/lib/zendesk_api/server/templates/layout.haml +44 -0
  90. data/lib/zendesk_api/server/templates/param.haml +4 -0
  91. data/lib/zendesk_api/server/templates/search.haml +23 -0
  92. data/lib/zendesk_api/server/templates/sidebar.haml +7 -0
  93. data/lib/zendesk_api/version.rb +1 -1
  94. data/spec/{association_spec.rb → core/association_spec.rb} +1 -1
  95. data/spec/{client_spec.rb → core/client_spec.rb} +1 -1
  96. data/spec/{collection_spec.rb → core/collection_spec.rb} +1 -1
  97. data/spec/{configuration_spec.rb → core/configuration_spec.rb} +1 -1
  98. data/spec/{create_resource_spec.rb → core/create_resource_spec.rb} +1 -1
  99. data/spec/{data_resource_spec.rb → core/data_resource_spec.rb} +1 -1
  100. data/spec/{inflection_spec.rb → core/inflection_spec.rb} +1 -1
  101. data/spec/{lru_cache_spec.rb → core/lru_cache_spec.rb} +1 -1
  102. data/spec/{middleware → core/middleware}/request/etag_cache_spec.rb +1 -1
  103. data/spec/{middleware → core/middleware}/request/retry_spec.rb +1 -1
  104. data/spec/{middleware → core/middleware}/request/test.jpg +0 -0
  105. data/spec/{middleware → core/middleware}/request/upload_spec.rb +1 -1
  106. data/spec/{middleware → core/middleware}/response/callback_spec.rb +1 -1
  107. data/spec/{middleware → core/middleware}/response/deflate_spec.rb +1 -1
  108. data/spec/{middleware → core/middleware}/response/gzip_spec.rb +1 -1
  109. data/spec/{middleware → core/middleware}/response/parse_iso_dates_spec.rb +1 -1
  110. data/spec/{read_resource_spec.rb → core/read_resource_spec.rb} +1 -1
  111. data/spec/{rescue_spec.rb → core/rescue_spec.rb} +1 -1
  112. data/spec/{resource_spec.rb → core/resource_spec.rb} +1 -1
  113. data/spec/{search_spec.rb → core/search_spec.rb} +1 -1
  114. data/spec/{spec_helper.rb → core/spec_helper.rb} +5 -5
  115. data/spec/{trackie_spec.rb → core/trackie_spec.rb} +1 -1
  116. data/{live → spec/live}/Readme.md +0 -0
  117. data/{live → spec/live}/activity_spec.rb +1 -1
  118. data/{live → spec/live}/audit_spec.rb +1 -1
  119. data/{live → spec/live}/bookmark_spec.rb +1 -1
  120. data/{live → spec/live}/category_spec.rb +1 -1
  121. data/{live → spec/live}/collection_spec.rb +1 -1
  122. data/{live → spec/live}/crm_spec.rb +1 -1
  123. data/{live → spec/live}/custom_role_spec.rb +1 -1
  124. data/{live → spec/live}/forum_spec.rb +1 -1
  125. data/{live → spec/live}/forum_subscription_spec.rb +1 -1
  126. data/{live → spec/live}/group_membership_spec.rb +1 -1
  127. data/{live → spec/live}/group_spec.rb +1 -1
  128. data/{live → spec/live}/identity_spec.rb +1 -1
  129. data/{live → spec/live}/locale_spec.rb +1 -1
  130. data/{live → spec/live}/macro_spec.rb +1 -1
  131. data/{live → spec/live}/mobile_device_spec.rb +1 -1
  132. data/{live → spec/live}/organization_spec.rb +1 -1
  133. data/{live → spec/live}/request_spec.rb +1 -1
  134. data/{live → spec/live}/satisfaction_rating_spec.rb +1 -1
  135. data/{live → spec/live}/setting_spec.rb +1 -1
  136. data/{live → spec/live}/suspended_ticket_spec.rb +1 -1
  137. data/{live → spec/live}/ticket_field_spec.rb +1 -1
  138. data/{live → spec/live}/ticket_metrics_spec.rb +1 -1
  139. data/{live → spec/live}/ticket_spec.rb +1 -1
  140. data/spec/live/topic_comment_spec.rb +24 -0
  141. data/{live → spec/live}/topic_spec.rb +1 -1
  142. data/{live → spec/live}/topic_subscription_spec.rb +1 -1
  143. data/{live → spec/live}/topic_vote_spec.rb +1 -1
  144. data/{live → spec/live}/upload_spec.rb +1 -1
  145. data/{live → spec/live}/user_spec.rb +1 -1
  146. data/{live → spec/live}/view_spec.rb +1 -1
  147. data/spec/macros/resource_macros.rb +1 -1
  148. data/spec/server/app_spec.rb +140 -0
  149. data/spec/server/helper_spec.rb +97 -0
  150. data/spec/server/html_renderer_spec.rb +130 -0
  151. data/spec/server/spec_helper.rb +43 -0
  152. metadata +198 -77
  153. data/live/topic_comment_spec.rb +0 -13
@@ -0,0 +1,12 @@
1
+ require 'zendesk_api/console/extensions'
2
+ require 'zendesk_api/console/console'
3
+
4
+ extend ZendeskAPI::Console
5
+
6
+ require 'zendesk_api/console/options'
7
+ require 'ripl'
8
+
9
+ ARGV.clear
10
+ Ripl.shell.prompt = lambda { "#{cwd.respond_to?(:path) ? '/' + cwd.path : cwd} > " }
11
+ Ripl.shell.extend ZendeskAPI::Console::Eval
12
+ Ripl.start
@@ -0,0 +1,144 @@
1
+ module ZendeskAPI::Console
2
+ ZD_DIRUP = Object.new.tap do |dir|
3
+ dir.instance_eval do
4
+ def /(stuff = nil)
5
+ puts stuff
6
+ end
7
+ end
8
+ end
9
+
10
+ module Eval
11
+ def loop_eval(str)
12
+ split = str.split(/\s*\/\s*/)
13
+ split[1..-1] = split[1..-1].map do |s|
14
+ s =~ /\d+/ ? s : "\"#{s}\""
15
+ end
16
+ split = split.join('/')
17
+ split += '/' if str[-1] == '/'
18
+ # puts ZendeskAPI::Console::ZD_DIRUP
19
+ split.gsub!(/\.\./, "ZendeskAPI::Console::ZD_DIRUP")
20
+ super(split)
21
+ end
22
+ end
23
+
24
+ def client(&blk)
25
+ return @client if @client && blk.nil?
26
+
27
+ @client = ZendeskAPI::Client.new do |cfg|
28
+ config.each do |k,v|
29
+ cfg.send("#{k}=", v)
30
+ end if config.keys.any?
31
+ blk.call(cfg) unless blk.nil?
32
+ end
33
+ end
34
+
35
+ def help
36
+ <<-END
37
+ This is help.
38
+ END
39
+ end
40
+
41
+ def username(username)
42
+ client.config.username = username
43
+ end
44
+
45
+ def password(password)
46
+ client.config.password = password
47
+ end
48
+
49
+ def basic_auth(username, password)
50
+ username(username)
51
+ password(password)
52
+ true
53
+ end
54
+
55
+ def url(url)
56
+ client.config.url = url
57
+ end
58
+
59
+ %w(get post put delete).each do |verb|
60
+ define_method verb do |*args|
61
+ client.connection.send(verb, *args)
62
+ end
63
+ end
64
+
65
+ def cd(new_path = nil)
66
+ if new_path.class.to_s =~ /^Zendesk/
67
+ @path = new_path
68
+ elsif new_path.is_a?(Fixnum) && @path
69
+ @path /= new_path
70
+ else
71
+ @path = nil
72
+ end
73
+
74
+ @path
75
+ end
76
+
77
+ def cwd
78
+ begin
79
+ path
80
+ rescue ArgumentError
81
+ "unconfigured"
82
+ end
83
+ end
84
+
85
+ def ls(*args)
86
+ if args.any?
87
+ args.inject(path) do |obj, arg|
88
+ obj.send(:/, arg)
89
+ end
90
+ elsif path.respond_to?(:to_a)
91
+ format = to_a.map do |elem|
92
+ if elem.method(:format).arity == 1
93
+ elem.format(client)
94
+ else
95
+ elem.format
96
+ end
97
+ end
98
+
99
+ lengths = format.inject([]) do |lengths, object|
100
+ object.each_with_index do |field, i|
101
+ lengths[i] = [field.to_s.length, lengths[i] || 0].max
102
+ end
103
+
104
+ lengths
105
+ end
106
+
107
+ format_headers.each_with_index do |header, i|
108
+ printf("%-#{lengths[i] + 2}s", header)
109
+ end
110
+
111
+ puts
112
+ puts "---"
113
+
114
+ format.each do |object|
115
+ object.each_with_index do |field, i|
116
+ printf("%-#{lengths[i] + 2}s", field)
117
+ end
118
+
119
+ puts
120
+ end
121
+
122
+ nil
123
+ else
124
+ methods = path.public_methods.reject do |method|
125
+ method =~ /^orig_/ || method.to_sym == :method_missing ||
126
+ Object.public_methods.include?(method)
127
+ end
128
+ end
129
+ end
130
+
131
+ def method_missing(*args)
132
+ path.send(*args)
133
+ end
134
+
135
+ def config
136
+ @options ||= {}
137
+ end
138
+
139
+ private
140
+
141
+ def path
142
+ @path || client
143
+ end
144
+ end
@@ -0,0 +1,183 @@
1
+ class ZendeskAPI::FormatError < ArgumentError; end
2
+
3
+ class ZendeskAPI::Collection
4
+ def /(id)
5
+ if id == ZendeskAPI::Console::ZD_DIRUP
6
+ if @collection_path.length == 1
7
+ @client
8
+ else
9
+ @collection_path.shift
10
+ self
11
+ end
12
+ elsif id.is_a?(Fixnum)
13
+ if loaded?
14
+ detect {|obj| obj.id == id}
15
+ else
16
+ find(:id => id)
17
+ end
18
+ elsif !id.is_a?(ZendeskAPI::Collection)
19
+ send(id)
20
+ end
21
+ end
22
+
23
+ alias :orig_log_error :log_error
24
+
25
+ def log_error(e, _)
26
+ raise e
27
+ end
28
+
29
+ def loaded?
30
+ @resources && @resources.any?
31
+ end
32
+
33
+ def to_s
34
+ path
35
+ end
36
+
37
+ def format_headers
38
+ @resource_class.format_headers
39
+ end
40
+ end
41
+
42
+ class ZendeskAPI::Client
43
+ GET_SUBCLASSES = lambda do |ary|
44
+ ary.map! do |klass|
45
+ if klass.name =~ /Resource$/
46
+ GET_SUBCLASSES.call(klass.subclasses)
47
+ else
48
+ klass
49
+ end
50
+ end
51
+
52
+ ary.tap(&:flatten!)
53
+ end
54
+
55
+ def to_s
56
+ "/"
57
+ end
58
+
59
+ def self.resources
60
+ @resources ||= begin
61
+ subclasses = GET_SUBCLASSES.call(ZendeskAPI::Data.subclasses)
62
+ subclasses.delete_if do |resource|
63
+ resource.name =~ /ZendeskAPI(::.*){2,}/
64
+ end
65
+ subclasses.sort_by(&:resource_name)
66
+ end
67
+ end
68
+
69
+ def to_a
70
+ self.class.resources
71
+ end
72
+
73
+ def format_headers
74
+ ["resource name"]
75
+ end
76
+ end
77
+
78
+ class ZendeskAPI::Data
79
+ def /(method)
80
+ if method == ZendeskAPI::Console::ZD_DIRUP
81
+ if association.options.parent
82
+ association.options.parent
83
+ elsif (res = @client.send(self.class.resource_name)).loaded?
84
+ res
85
+ else
86
+ ZendeskAPI::Collection.new(@client, self.class)
87
+ end
88
+ else
89
+ send(method)
90
+ end
91
+ end
92
+
93
+ class << self
94
+ attr_accessor :format_headers
95
+
96
+ def format(client = nil, &block)
97
+ if block_given?
98
+ class_eval do
99
+ define_method :format do
100
+ instance_eval &block
101
+ end
102
+ end
103
+ elsif client && client.send(resource_name).loaded?
104
+ ["@#{resource_name}"]
105
+ else
106
+ [resource_name]
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ class ZendeskAPI::DataResource
113
+ format_headers = %w{id created_at}
114
+
115
+ format do
116
+ if self.format_headers
117
+ self.format_headers.map {|attr| send(attr.to_s.downcase)}
118
+ else
119
+ raise ZendeskAPI::FormatError.new("#{self.class.name} hasn't defined an ouput format")
120
+ end
121
+ end
122
+ end
123
+
124
+ module ZendeskAPI
125
+ ForumSubscription.format_headers = %w{id forum_id user_id created_at}
126
+ GroupMembership.format_headers = %w{id group_id user_id created_at}
127
+ TopicSubscription.format_headers = %w{id topic_id user_id created_at}
128
+ Locale.format_headers = %w{Id Locale Name}
129
+ TicketField.format_headers = %w{Id Type Title Description}
130
+ Macro.format_headers = %w{Id Title}
131
+
132
+ Forum.format_headers = %w{Id Name Description Created Updated}
133
+ Forum.format do
134
+ [id, name, description, created_at, updated_at]
135
+ end
136
+
137
+ Category.format_headers = %w{Id Name Description Position Created Updated}
138
+ Category.format do
139
+ [id, name, description, position, created_at, updated_at]
140
+ end
141
+
142
+ Topic.format_headers = %w{Id Title Type}
143
+ Topic.format do
144
+ [id, title, topic_type]
145
+ end
146
+
147
+ # Topic::*, MobileDevice, TicketMetric, SuspendedTicket, customRole, CrmData...
148
+
149
+ Activity.format_headers = %w{Id Title User Actor Ticket}
150
+ Activity.format do
151
+ [id, title, user.name, actor.name, target.ticket.subject]
152
+ end
153
+
154
+ SatisfactionRating.format_headers = %w{Id Ticket Score Comment}
155
+ SatisfactionRating.format do
156
+ [id, ticket_id, score, comment]
157
+ end
158
+
159
+ Bookmark.format_headers = %w{Id Ticket Created}
160
+ Bookmark.format do
161
+ [id, ticket.id, created_at]
162
+ end
163
+
164
+ User.format_headers = %w{Id Name Email Created Updated}
165
+ User.format do
166
+ [id, name, email, created_at, updated_at]
167
+ end
168
+
169
+ Ticket.format_headers = %w{Id Type Subject Description Status Created Updated}
170
+ Ticket.format do
171
+ [id, type, subject, description, status, created_at, updated_at]
172
+ end
173
+
174
+ Organization.format_headers = %w{Id Name Created Updated}
175
+ Organization.format do
176
+ [id, name, created_at, updated_at]
177
+ end
178
+
179
+ View.format_headers = %w{Id Title Created Updated}
180
+ View.format do
181
+ [id, title, created_at, updated_at]
182
+ end
183
+ end
@@ -0,0 +1,41 @@
1
+ require 'optparse'
2
+ require 'logger'
3
+
4
+ begin
5
+ OptionParser.new do |opts|
6
+ opts.banner = "Usage: zendesk c[onsole] [options]"
7
+
8
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
9
+ config["logger.level"] = v ? Logger::INFO : Logger::WARN
10
+ end
11
+
12
+ opts.on("-c", "--config FILE", "Load a config file") do |c|
13
+ config.replace(YAML.load_file(c))
14
+ end
15
+
16
+ opts.on("-u", "--username USER", "Sets basic auth username") do |u|
17
+ config["username"] = u
18
+ end
19
+
20
+ opts.on("-p", "--password PASS", "Sets basic auth password") do |p|
21
+ config["password"] = p
22
+ end
23
+
24
+ opts.on("-a", "--api URL", "Sets api url") do |a|
25
+ config["url"] = a
26
+ end
27
+
28
+ opts.on_tail("-h", "--help", "Show this message") do
29
+ puts opts
30
+ exit
31
+ end
32
+
33
+ opts.on_tail("--version", "Show version") do
34
+ puts Zendesk::VERSION
35
+ exit
36
+ end
37
+ end.parse!
38
+ rescue OptionParser::MissingArgument => e
39
+ puts e.message
40
+ exit
41
+ end
@@ -11,6 +11,14 @@ module ZendeskAPI
11
11
  include Rescue
12
12
 
13
13
  class << self
14
+ def inherited(klass)
15
+ subclasses.push(klass)
16
+ end
17
+
18
+ def subclasses
19
+ @subclasses ||= []
20
+ end
21
+
14
22
  # The singular resource name taken from the class name (e.g. ZendeskAPI::Ticket -> ticket)
15
23
  def singular_resource_name
16
24
  @singular_resource_name ||= ZendeskAPI::Helpers.snakecase_string(to_s.split("::").last)
@@ -39,6 +47,9 @@ module ZendeskAPI
39
47
  # @return [ZendeskAPI::Association] The association
40
48
  attr_accessor :association
41
49
 
50
+ # Place to dump the last response
51
+ attr_accessor :response
52
+
42
53
  # Create a new resource instance.
43
54
  # @param [Client] client The client to use
44
55
  # @param [Hash] attributes The optional attributes that describe the resource
@@ -98,7 +109,7 @@ module ZendeskAPI
98
109
 
99
110
  # Compares resources by class and id. If id is nil, then by object_id
100
111
  def ==(other)
101
- warn "Trying to compare #{other.class} to a Resource" if other && !other.is_a?(Data)
112
+ warn "Trying to compare #{other.class} to a Resource from #{caller.first}" if other && !other.is_a?(Data)
102
113
  other.is_a?(self.class) && ((other.id && other.id == id) || (other.object_id == self.object_id))
103
114
  end
104
115
  alias :eql :==
@@ -10,7 +10,13 @@ module ZendeskAPI
10
10
  # @internal Begin actual Resource definitions
11
11
 
12
12
  class Locale < ReadResource; end
13
- class CRMData < DataResource; end
13
+
14
+ class CRMData < DataResource
15
+ class << self
16
+ alias :resource_name :singular_resource_name
17
+ end
18
+ end
19
+
14
20
  class CRMDataStatus < DataResource; end
15
21
  class CustomRole < DataResource; end
16
22
  class Role < DataResource; end
@@ -88,11 +94,19 @@ module ZendeskAPI
88
94
  has User
89
95
  end
90
96
 
97
+ class TopicComment < Data
98
+ has Topic
99
+ has User
100
+ has_many Attachment
101
+ end
102
+
91
103
  class Topic < Resource
92
- class TopicComment < Resource
93
- has Topic
94
- has User
95
- has_many Attachment
104
+ class TopicComment < TopicComment
105
+ extend Read
106
+
107
+ include Create
108
+ include Update
109
+ include Destroy
96
110
  end
97
111
 
98
112
  class TopicVote < SingularResource
@@ -194,7 +208,7 @@ module ZendeskAPI
194
208
  end
195
209
 
196
210
  class TicketMetric < DataResource
197
- include Read
211
+ extend Read
198
212
  end
199
213
 
200
214
  class Ticket < Resource
@@ -262,23 +276,29 @@ module ZendeskAPI
262
276
  has_many :custom_fields, :class => TicketField
263
277
  end
264
278
 
279
+ class ViewCount < DataResource; end
280
+
265
281
  class View < ReadResource
266
282
  has_many :tickets, :class => Ticket
267
283
  has_many :rows, :class => ViewRow, :path => "execute"
268
284
  has :execution, :class => ViewExecution
285
+ has ViewCount, :path => "count"
269
286
 
270
287
  def self.preview(client, options = {})
271
288
  Collection.new(client, ViewRow, options.merge(:path => "views/preview", :verb => :post))
272
289
  end
273
290
  end
274
291
 
275
-
276
292
  class GroupMembership < Resource
277
293
  has User
278
294
  has Group
279
295
  end
280
296
 
281
297
  class User < Resource
298
+ class TopicComment < TopicComment
299
+ extend Read
300
+ end
301
+
282
302
  class Identity < Resource
283
303
  # Makes this identity the primary one bumping all other identities down one
284
304
  put :make_primary
@@ -315,7 +335,7 @@ module ZendeskAPI
315
335
 
316
336
  has_many ForumSubscription
317
337
  has_many TopicSubscription
318
- has_many :topic_comments, :class => Topic::TopicComment
338
+ has_many :topic_comments, :class => TopicComment
319
339
  has_many :topic_votes, :class => Topic::TopicVote
320
340
 
321
341
  has CRMData