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,119 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/content_for'
3
+ require 'sinatra/reloader'
4
+
5
+ require 'compass'
6
+ require 'haml'
7
+
8
+ require 'coderay'
9
+ require 'coderay_bash'
10
+
11
+ require 'json'
12
+ require 'redcarpet'
13
+
14
+ require 'digest/md5'
15
+
16
+ require 'mongoid'
17
+
18
+ require 'zendesk_api/server/models/user_request'
19
+ Mongoid.load!(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'mongoid.yml'))
20
+
21
+ module ZendeskAPI
22
+ module Server
23
+ require 'zendesk_api/server/helper'
24
+ require 'zendesk_api/server/html_renderer'
25
+
26
+ class App < Sinatra::Base
27
+ enable :sessions
28
+
29
+ helpers Sinatra::ContentFor
30
+ helpers Helper
31
+
32
+ configure do
33
+ set :public_folder, File.join(File.dirname(__FILE__), 'public')
34
+ set :views, File.join(File.dirname(__FILE__), 'templates')
35
+
36
+ set :documentation_dir, File.join(File.dirname(__FILE__), "docs")
37
+
38
+ documentation = Dir.glob(File.join(settings.documentation_dir, "*.md")).inject({}) do |docs, entry|
39
+ body = HtmlRenderer.render(File.open(entry, &:read))
40
+ headers = HtmlRenderer.markdown.renderer.headers.dup
41
+
42
+ HtmlRenderer.markdown.renderer.headers.clear
43
+
44
+ docs.merge(File.basename(entry, ".md") => { :body => body, :headers => headers })
45
+ end
46
+
47
+ set :documentation, documentation
48
+ set :help, documentation["introduction"][:body]
49
+
50
+ autocomplete = settings.documentation.inject([]) do |accum, (resource, content)|
51
+ accum.push(resource)
52
+ accum.concat(content[:headers].map {|header| "#{resource}##{header}"})
53
+ accum
54
+ end + ["help"]
55
+
56
+ set :autocomplete, autocomplete
57
+ end
58
+
59
+ configure :development do
60
+ register Sinatra::Reloader
61
+ end
62
+
63
+ get '/' do
64
+ haml :index, :format => :html5
65
+ end
66
+
67
+ get '/:object_id' do
68
+ begin
69
+ @user_request = UserRequest.where(:_id => Moped::BSON::ObjectId(params[:object_id])).first
70
+ rescue Moped::Errors::InvalidObjectId; end
71
+
72
+ if @user_request
73
+ params["url"] = @user_request.url
74
+ @path = @user_request.path
75
+
76
+ @method = @user_request.method
77
+ @json = @user_request.json
78
+ @url_params = @user_request.url_params
79
+
80
+ set_request(@user_request.request) unless @user_request.request.empty?
81
+ set_response(@user_request.response) unless @user_request.response.empty?
82
+ end
83
+
84
+ haml :index, :format => :html5
85
+ end
86
+
87
+ post '/search' do
88
+ if md = settings.documentation[params[:query]]
89
+ md[:body]
90
+ else
91
+ settings.help
92
+ end
93
+ end
94
+
95
+ post '/' do
96
+ @method = (params.delete("method") || "get").downcase.to_sym
97
+ @path = coerce_path(params.delete("url"))
98
+ @json = params.delete("json")
99
+ @url_params = (params.delete("params") || {}).delete_if do |param|
100
+ !param["name"] || !param["value"] || (param["name"].empty? && param["value"].empty?)
101
+ end
102
+
103
+ execute_request unless @error
104
+
105
+ @user_request = UserRequest.create(
106
+ :method => @method,
107
+ :url => params["url"],
108
+ :path => @path,
109
+ :json => @json,
110
+ :url_params => @url_params,
111
+ :request => @user_request_hash,
112
+ :response => @user_response_hash
113
+ ) unless @error
114
+
115
+ haml :index, :format => :html5
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,145 @@
1
+ ## Account Settings
2
+
3
+ ### JSON Format
4
+ Account Settings are read-only. They contain settings for the various aspects of an Account.
5
+
6
+ ### Branding
7
+
8
+ | Name | Type | Comment
9
+ | ---------------------------------- | ------- | -------
10
+ | header_color | string | HEX of the header color
11
+ | page_background_color | string | HEX of the page background color
12
+ | tab_background_color | string | HEX of tab background color
13
+ | text_color | string | HEX of the text color, usually matched to contrast well with `header_color`
14
+
15
+ ### Apps
16
+
17
+ | Name | Type | Comment
18
+ | ---------------------------------- | ------- | -------
19
+ | use | boolean | The Account can use apps
20
+ | create_private | boolean | The Account can create private apps
21
+ | create_public | boolean | The Account can create public apps
22
+
23
+ ### Tickets
24
+
25
+ | Name | Type | Comment
26
+ | ---------------------------------- | ------- | -------
27
+ | comments_public_by_default | boolean | Comments from agents are public by default
28
+ | list_newest_comments_first | boolean | When viewing a ticket, show the newest comments and events first
29
+ | collaboration | boolean | CCs may be added to a ticket
30
+ | private_attachments | boolean | Users must login to acesss attachments
31
+ | agent_collision | boolean | Clients should provide an indicator when a ticket is being viewed by another agent
32
+ | list_empty_views | boolean | Clients should display Views with no matching Tickets in menus
33
+ | maximum_personal_views_to_list | number | Maximum number of personal Views clients should display in menus
34
+ | tagging | boolean | Tickets may be tagged
35
+
36
+ ### Chat
37
+
38
+ | Name | Type | Comment
39
+ | ---------------------------------- | ------- | -------
40
+ | enabled | boolean | Chat is enabled
41
+ | maximum_requests | number | The maximum number of chat requests an agent may handle at one time
42
+ | welcome_message | string | The message automatically sent to end-users when they begin chatting with an agent
43
+
44
+ ### Twitter
45
+
46
+ | Name | Type | Comment
47
+ | ---------------------------------- | ------- | -------
48
+ | shorten_url | string | Possible values: 'always', 'optional', 'never'
49
+
50
+ ### Voice
51
+
52
+ | Name | Type | Comment
53
+ | ---------------------------------- | ------- | -------
54
+ | enabled | boolean | Voice is enabled
55
+ | maintenance | boolean |
56
+ | logging | boolean |
57
+
58
+ ### Users
59
+
60
+ | Name | Type | Comment
61
+ | ---------------------------------- | ------- | -------
62
+ | tagging | boolean | Users may be tagged
63
+
64
+ ### Screencast
65
+
66
+ | Name | Type | Comment
67
+ | ---------------------------------- | ------- | -------
68
+ | enabled_for_tickets | boolean | Account can record Screencasts on Tickets.
69
+ | host | string | The Screenr domain used when recording and playing Screencasts.
70
+ | tickets_recorder_id | string | The Screenr Recorder id used when recording Screencasts.
71
+
72
+
73
+ #### Example
74
+
75
+ ```js
76
+ "settings": {
77
+ "branding": {
78
+ "header_color": "1A00C3",
79
+ "page_background_color": "333333",
80
+ "tab_background_color": "3915A2",
81
+ "text_color": "FFFFFF"
82
+ },
83
+ "apps":{
84
+ "use": true,
85
+ "create_private": false,
86
+ "create_public": true
87
+ },
88
+ "tickets": {
89
+ "comments_public_by_default": true,
90
+ "list_newest_comments_first": true,
91
+ "collaboration": true,
92
+ "private_attachments": true,
93
+ "agent_collision": true
94
+ "list_empty_views": true,
95
+ "maximum_personal_views_to_list": 12,
96
+ "tagging": true
97
+ },
98
+ "chat": {
99
+ "maximum_request_count": 5,
100
+ "welcome_message": "Hello, how may I help you?",
101
+ "enabled": true
102
+ },
103
+ "voice": {
104
+ "enabled": true,
105
+ "maintenance": false,
106
+ "logging": true
107
+ },
108
+ "twitter": {
109
+ "shorten_url":"optional"
110
+ },
111
+ "users": {
112
+ "tagging":true
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Show Settings
118
+ `GET /api/v2/account/settings.json`
119
+
120
+ This shows the settings that are available for the account.
121
+
122
+ #### Allowed For:
123
+
124
+ * Agents
125
+
126
+ #### Using curl
127
+
128
+ ```bash
129
+ curl https://{subdomain}.zendesk.com/api/v2/account/settings.json \
130
+ -v -u {email_address}:{password}
131
+ ```
132
+
133
+ #### Example Response
134
+
135
+ ```http
136
+ Status: 200 OK
137
+
138
+ "settings": {
139
+ "apps": {.. },
140
+ "tickets": { ... },
141
+ "chat": { ... },
142
+ "twitter": { ... },
143
+ "users": { ... }
144
+ }
145
+ ```
@@ -0,0 +1,121 @@
1
+ ## Activity Stream
2
+
3
+ The **activity stream** is a per agent event stream. It will give access to the most recent events that relate to the agent polling the API.
4
+
5
+ ### JSON Format
6
+ Ticket activity events are represented as JSON objects which have the following keys:
7
+
8
+ | Name | Type | Read-only | Mandatory | Comment
9
+ | ---------------- | ---------------------- | --------- | --------- | -------
10
+ | id | integer | yes | no | Automatically assigned upon creation
11
+ | url | string | yes | no | The API url of this activity
12
+ | title | string | yes | yes | Description of this activity
13
+ | verb | string | yes | yes | Identifies the type of the activity
14
+ | user | [User](users.md) | yes | yes | The user this activity pertains to
15
+ | actor | [User](users.md) | yes | yes | The actor causing the creation of the activity
16
+ | created_at | date | yes | no | When this record was created
17
+ | updated_at | date | yes | no | When this record last got updated
18
+ | object | object | yes | no | The content of this activity. Can be a ticket, comment, or change.
19
+ | target | object | yes | no | The target of this activity, a ticket.
20
+
21
+ #### Example
22
+ ```js
23
+ {
24
+ "id": 35,
25
+ "url": "https://company.zendesk.com/api/v2/activities/35.json",
26
+ "verb": "tickets.assignment",
27
+ "title": "John Hopeful assigned ticket #123 to you",
28
+ "user": { ... },
29
+ "actor": { ... },
30
+ "created_at": "2012-03-05T10:38:52Z",
31
+ "updated_at": "2012-03-05T10:38:52Z"
32
+ }
33
+ ```
34
+
35
+ ### List Activities
36
+ `GET /api/v2/activities.json`
37
+
38
+ #### Allowed For:
39
+
40
+ * Agents
41
+
42
+ Lists activities pertaining to the user performing the request.
43
+
44
+ #### Request Parameters
45
+
46
+ You can pass an optional `since` parameter which designates a timestamp offset, and the API
47
+ will only return activities happening after that offset. The format of the `since` parameter
48
+ must be in UTC on ISO8601 form `%Y-%m-%dT%H:%M:%SZ`, e.g. `2012-04-03T16:02:46Z`
49
+
50
+ #### Using curl
51
+
52
+ ```bash
53
+ curl https://{subdomain}.zendesk.com/api/v2/activities.json \
54
+ -v -u {email_address}:{password}
55
+ ```
56
+
57
+ #### Example Response
58
+
59
+ ```http
60
+ Status: 200 OK
61
+
62
+ {
63
+ "activities": [
64
+ {
65
+ "id": 35,
66
+ "url": "https://company.zendesk.com/api/v2/activities/35.json",
67
+ "verb": "tickets.assignment",
68
+ "title": "John Hopeful assigned ticket #123 to you",
69
+ "user": { ... },
70
+ "actor": { ... },
71
+ "created_at": "2012-03-05T10:38:52Z",
72
+ "updated_at": "2012-03-05T10:38:52Z"
73
+ },
74
+ {
75
+ "id": 45,
76
+ "url": "https://company.zendesk.com/api/v2/activities/45.json",
77
+ "verb": "tickets.comment",
78
+ "title": "John Hopeful commented in ticket #44",
79
+ "user": { ... },
80
+ "actor": { ... },
81
+ "created_at": "2012-03-05T11:32:44Z",
82
+ "updated_at": "2012-03-05T11:32:44Z"
83
+ }
84
+ ]
85
+ }
86
+ ```
87
+
88
+ ### Show Activity
89
+ `GET /api/v2/activities/{id}.json`
90
+
91
+ #### Allowed For:
92
+
93
+ * Agent
94
+
95
+ Only provides access to an activities pertaining to the agent executing the request
96
+
97
+ #### Using curl
98
+
99
+ ```bash
100
+ curl https://{subdomain}.zendesk.com/api/v2/activities/{id}.json \
101
+ -v -u {email_address}:{password}
102
+ ```
103
+
104
+ #### Example Response
105
+
106
+ ```http
107
+ Status: 200 OK
108
+
109
+ {
110
+ "activity": {
111
+ "id": 45,
112
+ "url": "https://company.zendesk.com/api/v2/activities/45.json",
113
+ "verb": "tickets.comment",
114
+ "title": "John Hopeful commented in ticket #44",
115
+ "user": { ... },
116
+ "actor": { ... },
117
+ "created_at": "2012-03-05T11:32:44Z",
118
+ "updated_at": "2012-03-05T11:32:44Z"
119
+ }
120
+ }
121
+ ```
@@ -0,0 +1,73 @@
1
+ ## Attachments
2
+
3
+ ### JSON Format
4
+ Attachments are represented as JSON objects with the following keys:
5
+
6
+ | Name | Type | Read-only | Comment
7
+ | ------------ | ---------------- | --------- | -------
8
+ | id | integer | yes | Automatically assigned when created
9
+ | file_name | string | yes | The name of the image file
10
+ | content_url | string | yes | A full URL where the attachment image file can be downloaded
11
+ | content_type | string | yes | The content type of the image. Example value: `image/png`
12
+ | size | integer | yes | The size of the image file in bytes
13
+ | thumbnails | array | yes | An array of [Photo](#attachments) objects. Note that thumbnails do not have thumbnails.
14
+
15
+ #### Example
16
+ ```js
17
+ {
18
+ "id": 928374,
19
+ "file_name": "my_funny_profile_pic.png",
20
+ "content_url": "https://company.zendesk.com/attachments/my_funny_profile_pic.png",
21
+ "content_type": "image/png",
22
+ "size": 166144,
23
+ "thumbnails": [
24
+ {
25
+ "id": 928375,
26
+ "file_name": "my_funny_profile_pic_thumb.png",
27
+ "content_url": "https://company.zendesk.com/attachments/my_funny_profile_pic_thumb.png",
28
+ "content_type": "image/png",
29
+ "size": 58298
30
+ }
31
+ ]
32
+ }
33
+ ```
34
+
35
+ ### Uploading files
36
+ `POST /api/v2/uploads.json`
37
+
38
+ Adding multiple attachments to the same upload is handled by splitting requests and
39
+ passing the token received from the first request to each subsequent one.
40
+
41
+ #### Allowed For
42
+
43
+ * End Users
44
+
45
+ #### Using curl
46
+
47
+ ```bash
48
+ curl -u username:password -H "Content-Type: application/binary" \
49
+ --data-binary @file.dat -X POST \
50
+ "https://helpdesk.zendesk.com/api/v2/uploads.json?filename=myfile.dat&token={optional_token}"
51
+ ```
52
+
53
+ #### Example Response
54
+
55
+ ```http
56
+ Status: 201 Created
57
+
58
+ {
59
+ "upload": {
60
+ "token": "6bk3gql82em5nmf",
61
+ "attachments": [
62
+ {
63
+ "id": 498483,
64
+ "name": "crash.log",
65
+ "content_url": "https://company.zendesk.com/attachments/crash.log",
66
+ "content_type": "text/plain",
67
+ "size": 2532,
68
+ "thumbnails": []
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ ```