zendesk_api 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/zendesk_api/resources.rb +39 -21
- data/lib/zendesk_api/server/docs/account_settings.md +39 -1
- data/lib/zendesk_api/server/docs/automations.md +250 -0
- data/lib/zendesk_api/server/docs/categories.md +4 -4
- data/lib/zendesk_api/server/docs/forums.md +4 -4
- data/lib/zendesk_api/server/docs/introduction.md +5 -1
- data/lib/zendesk_api/server/docs/macros.md +1 -1
- data/lib/zendesk_api/server/docs/organizations.md +19 -0
- data/lib/zendesk_api/server/docs/requests.md +8 -4
- data/lib/zendesk_api/server/docs/suspended_tickets.md +3 -1
- data/lib/zendesk_api/server/docs/tags.md +109 -0
- data/lib/zendesk_api/server/docs/ticket_audits.md +20 -3
- data/lib/zendesk_api/server/docs/tickets.md +20 -2
- data/lib/zendesk_api/server/docs/topic_comments.md +4 -4
- data/lib/zendesk_api/server/docs/topics.md +1 -1
- data/lib/zendesk_api/server/docs/triggers.md +59 -1
- data/lib/zendesk_api/server/docs/user_identities.md +1 -1
- data/lib/zendesk_api/server/docs/users.md +11 -0
- data/lib/zendesk_api/server/docs/views.md +105 -15
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/spec_helper.rb +2 -0
- data/spec/fixtures/zendesk.rb +78 -75
- data/spec/live/ticket_spec.rb +28 -1
- metadata +3 -2
@@ -10,7 +10,7 @@ User identities have the following keys:
|
|
10
10
|
| id | integer | yes | no | Automatically assigned upon creation
|
11
11
|
| url | string | yes | no | The API url of this identity
|
12
12
|
| user_id | integer | yes | yes | The id of the user
|
13
|
-
| type | string | yes | yes | One of "email", "twitter", "facebook" or "
|
13
|
+
| type | string | yes | yes | One of "email", "twitter", "facebook", "google", or "phone_number"
|
14
14
|
| value | string | yes | yes | The identifier for this identity, e.g. an email address
|
15
15
|
| verified | boolean | no | no | Is true of the identity has gone through verification
|
16
16
|
| primary | boolean | no | no | Is true of the primary identity of the user
|
@@ -40,6 +40,7 @@ Users are represented as JSON objects which have the following keys:
|
|
40
40
|
| last_login_at | date | yes | no | A time-stamp of the last time this user logged in to Zendesk
|
41
41
|
| email | string | no | yes | The primary email address of this user
|
42
42
|
| phone | string | no | no | The primary phone number of this user
|
43
|
+
| identities | Array | no | no | Array of user identities (e.g. email and Twitter) associated with this user. See [User Identities](user_identities.html)
|
43
44
|
| signature | string | no | no | The signature of this user. Only agents and admins can have signatures
|
44
45
|
| details | string | no | no | In this field you can store any details obout the user. e.g. the address
|
45
46
|
| notes | string | no | no | In this field you can store any notes you have about the user
|
@@ -201,6 +202,16 @@ Location: /api/v2/users/{new-user-id}.json
|
|
201
202
|
}
|
202
203
|
```
|
203
204
|
|
205
|
+
### Create User with Multiple Identities
|
206
|
+
|
207
|
+
If you have a user with multiple identities, such as email addresses and Twitter accounts, you can also include
|
208
|
+
these values at creation time. This is especially useful when importing users from another system.
|
209
|
+
|
210
|
+
```bash
|
211
|
+
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json \
|
212
|
+
-H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "identities": [{ "type": "email", "value": "test@user.com"}, {"type": "twitter", "value": "tester84" }]}}'
|
213
|
+
```
|
214
|
+
|
204
215
|
### Create Many Users
|
205
216
|
`POST /api/v2/users/create_many.json`
|
206
217
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
## Views
|
2
2
|
|
3
3
|
### JSON Format
|
4
|
-
Views are
|
4
|
+
Views are represented as simple flat JSON objects which have the following keys.
|
5
5
|
|
6
6
|
| Name | Type | Comment
|
7
7
|
| --------------- | ---------------------------| -------------------
|
@@ -36,35 +36,33 @@ View Execution is a read-only object that describes how to display a collection
|
|
36
36
|
|
37
37
|
| Name | Type | Comment
|
38
38
|
| --------------- | ------- | -------
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
| group_order | String | The direction the tickets are grouped. May be one of 'asc' or 'desc'
|
43
|
-
| sort_order | String | The direction the tickets are sorted. May be one of 'asc' or 'desc'
|
44
|
-
| sort_by | String | The ticket field used for sorting. This will either be a title or a custom field id.
|
39
|
+
| columns | Array | The ticket fields to display. Custom fields have an id, title, type and url referencing the [Ticket Field](ticket_fields.md)
|
40
|
+
| group | Object | When present, the structure indicating how the tickets are grouped
|
41
|
+
| sort | Object | The column structure of the field used for sorting.
|
45
42
|
|
46
43
|
#### Example
|
47
44
|
```js
|
48
45
|
{
|
49
46
|
"execution":{
|
50
|
-
"
|
47
|
+
"columns": [
|
51
48
|
{ "id": "status", "title": "Status" },
|
52
|
-
{ "id": "updated", "title": "Updated" }
|
53
|
-
],
|
54
|
-
"custom_fields": [
|
49
|
+
{ "id": "updated", "title": "Updated" },
|
55
50
|
{
|
56
|
-
"id": 5, "title": "Account",
|
51
|
+
"id": 5, "title": "Account", "type": "text",
|
57
52
|
"url": "https://example.zendesk.com/api/v2/ticket_fields/5.json"
|
58
53
|
},
|
59
54
|
...
|
60
55
|
]
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"sort_by":"updated"
|
56
|
+
"group": { "id": "status", "title": "Status", "order": "desc" },
|
57
|
+
"sort": { "id": "updated", "title": "Updated", "order": "desc" }
|
64
58
|
}
|
65
59
|
}
|
66
60
|
```
|
67
61
|
|
62
|
+
# Deprecated
|
63
|
+
|
64
|
+
#
|
65
|
+
|
68
66
|
### Conditions
|
69
67
|
The conditions under which a ticket is selected.
|
70
68
|
|
@@ -313,6 +311,63 @@ Status: 200 OK
|
|
313
311
|
}
|
314
312
|
```
|
315
313
|
|
314
|
+
### Create View
|
315
|
+
`POST /api/v2/views.json`
|
316
|
+
|
317
|
+
#### Allowed For
|
318
|
+
|
319
|
+
* Agents
|
320
|
+
|
321
|
+
#### Using curl
|
322
|
+
|
323
|
+
```bash
|
324
|
+
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/views.json \
|
325
|
+
-H "Content-Type: application/json" -X POST -d '{"view":{"title":"Roger Wilco", "all": [{ "field": "status", "operator": "is", "value": "open" }]}}'
|
326
|
+
```
|
327
|
+
|
328
|
+
#### Example Response
|
329
|
+
|
330
|
+
```http
|
331
|
+
Status: 201 Created
|
332
|
+
Location: /api/v2/view/{new-view-id}.json
|
333
|
+
|
334
|
+
{
|
335
|
+
"view": {
|
336
|
+
"id": 9873843,
|
337
|
+
"title": "Roger Wilco",
|
338
|
+
...
|
339
|
+
}
|
340
|
+
}
|
341
|
+
```
|
342
|
+
|
343
|
+
### Update View
|
344
|
+
`PUT /api/v2/view/{id}.json`
|
345
|
+
|
346
|
+
#### Allowed For
|
347
|
+
|
348
|
+
* Agents
|
349
|
+
|
350
|
+
#### Using curl
|
351
|
+
|
352
|
+
```bash
|
353
|
+
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/view/{id}.json \
|
354
|
+
-H "Content-Type: application/json" -X PUT -d '{"view":{"title":"Roger Wilco II"}}'
|
355
|
+
```
|
356
|
+
|
357
|
+
#### Example Response
|
358
|
+
|
359
|
+
```http
|
360
|
+
Status: 200 OK
|
361
|
+
|
362
|
+
{
|
363
|
+
"view": {
|
364
|
+
"id": 9873843,
|
365
|
+
"title": "Roger Wilco II",
|
366
|
+
...
|
367
|
+
}
|
368
|
+
}
|
369
|
+
```
|
370
|
+
|
316
371
|
### Executing Views
|
317
372
|
`GET /api/v2/views/{id}/execute.json`
|
318
373
|
|
@@ -372,6 +427,41 @@ Status: 200 OK
|
|
372
427
|
}
|
373
428
|
```
|
374
429
|
|
430
|
+
### Getting Tickets from a view
|
431
|
+
`GET /api/v2/views/{id}/tickets.json`
|
432
|
+
|
433
|
+
#### Allowed For
|
434
|
+
|
435
|
+
* Agents
|
436
|
+
|
437
|
+
#### Using curl:
|
438
|
+
|
439
|
+
```bash
|
440
|
+
curl https://{subdomain}.zendesk.com/api/v2/views/{id}/tickets.json \
|
441
|
+
-v -u {email_address}:{password}
|
442
|
+
```
|
443
|
+
|
444
|
+
#### Example Responses
|
445
|
+
|
446
|
+
```http
|
447
|
+
Status: 200 OK
|
448
|
+
|
449
|
+
{
|
450
|
+
"tickets": [
|
451
|
+
{
|
452
|
+
"id": 35436,
|
453
|
+
"subject": "Help I need somebody!",
|
454
|
+
...
|
455
|
+
},
|
456
|
+
{
|
457
|
+
"id": 20057623,
|
458
|
+
"subject": "Not just anybody!",
|
459
|
+
...
|
460
|
+
},
|
461
|
+
]
|
462
|
+
}
|
463
|
+
```
|
464
|
+
|
375
465
|
### Previewing Views
|
376
466
|
`POST /api/v2/views/preview.json`
|
377
467
|
|
data/lib/zendesk_api/version.rb
CHANGED
data/spec/core/spec_helper.rb
CHANGED
data/spec/fixtures/zendesk.rb
CHANGED
@@ -1,88 +1,91 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module ZendeskAPI
|
2
|
+
module Fixtures
|
3
|
+
def user
|
4
|
+
@user ||= find_or_create_user "end-user"
|
5
|
+
end
|
4
6
|
|
5
|
-
def current_user
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
def current_user
|
8
|
+
VCR.use_cassette('current_user') do
|
9
|
+
@current_user ||= client.users.find(:id => 'me')
|
10
|
+
end
|
11
|
+
end
|
10
12
|
|
11
|
-
def agent
|
12
|
-
|
13
|
-
end
|
13
|
+
def agent
|
14
|
+
@agent ||= find_or_create_user "agent"
|
15
|
+
end
|
14
16
|
|
15
|
-
def find_or_create_user(role)
|
16
|
-
|
17
|
-
|
17
|
+
def find_or_create_user(role)
|
18
|
+
VCR.use_cassette("valid_user_#{role}") do
|
19
|
+
email = "zendesk-api-client-ruby-#{role}-#{client.config.username}"
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
21
|
+
client.users.detect {|u| u.email == email } ||
|
22
|
+
client.users.create(
|
23
|
+
:name => "Test Valid with role #{role}",
|
24
|
+
:verified => true,
|
25
|
+
:email => email,
|
26
|
+
:role => role
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
28
30
|
|
29
|
-
def topic
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
31
|
+
def topic
|
32
|
+
VCR.use_cassette('valid_topic') do
|
33
|
+
@topic ||= forum.topics.first
|
34
|
+
@topic ||= client.topics.create(
|
35
|
+
:title => "Test Topic",
|
36
|
+
:body => "This is the body of a topic.",
|
37
|
+
:forum_id => forum.id
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
39
41
|
|
40
|
-
def forum
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
42
|
+
def forum
|
43
|
+
VCR.use_cassette('valid_forum') do
|
44
|
+
@forum ||= client.forums.detect {|f| f.topics.any? }
|
45
|
+
@forum ||= client.forums.create(:name => "Test Forum", :access => "everybody")
|
46
|
+
end
|
47
|
+
end
|
46
48
|
|
47
|
-
def category
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
49
|
+
def category
|
50
|
+
VCR.use_cassette('valid_category') do
|
51
|
+
@category ||= client.categories.first
|
52
|
+
@category ||= client.categories.create(:name => "Test Category")
|
53
|
+
end
|
54
|
+
end
|
53
55
|
|
54
|
-
def ticket
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
56
|
+
def ticket
|
57
|
+
VCR.use_cassette('valid_ticket') do
|
58
|
+
@ticket ||= client.tickets.first
|
59
|
+
@ticket ||= client.tickets.create(
|
60
|
+
:subject => "Test Ticket",
|
61
|
+
:description => "This is a test of the emergency alert system.",
|
62
|
+
:requester_id => user.id
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
64
66
|
|
65
|
-
def suspended_ticket
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
67
|
+
def suspended_ticket
|
68
|
+
VCR.use_cassette('valid_suspended_ticket') do
|
69
|
+
@suspended_ticket ||= client.suspended_tickets.first
|
70
|
+
end
|
71
|
+
end
|
70
72
|
|
71
|
-
def group
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
73
|
+
def group
|
74
|
+
VCR.use_cassette('valid_group') do
|
75
|
+
@ticket ||= client.groups.detect {|g| !g.default}
|
76
|
+
@ticket ||= client.groups.create(:name => "Test Group")
|
77
|
+
end
|
78
|
+
end
|
77
79
|
|
78
|
-
def organization
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
80
|
+
def organization
|
81
|
+
VCR.use_cassette('valid_organization') do
|
82
|
+
@organization ||= current_user.organization
|
83
|
+
end
|
84
|
+
end
|
83
85
|
|
84
|
-
# Global default options, overwritten if using under
|
85
|
-
def default_options
|
86
|
-
|
86
|
+
# Global default options, overwritten if using under
|
87
|
+
def default_options
|
88
|
+
{}
|
89
|
+
end
|
90
|
+
end
|
87
91
|
end
|
88
|
-
|
data/spec/live/ticket_spec.rb
CHANGED
@@ -90,11 +90,38 @@ describe ZendeskAPI::Ticket do
|
|
90
90
|
it "can comment while creating" do
|
91
91
|
VCR.use_cassette("ticket_inline_comments") do
|
92
92
|
ticket = ZendeskAPI::Ticket.new(client, valid_attributes.merge(default_options))
|
93
|
-
ticket.comment = ZendeskAPI::
|
93
|
+
ticket.comment = ZendeskAPI::Ticket::Comment.new(client, :value => "My comment", :public => false)
|
94
94
|
ticket.save!
|
95
95
|
|
96
96
|
ticket.changes.should == {} # comment was set before save
|
97
97
|
ticket.attributes[:comment].should == {"value" => "My comment", "public" => false}
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
describe "import race condition" do
|
102
|
+
it "should handle it" do
|
103
|
+
email = "test+#{rand(100000)}@test.com"
|
104
|
+
|
105
|
+
VCR.use_cassette("ticket_import_race") do
|
106
|
+
threads = []
|
107
|
+
|
108
|
+
3.times do
|
109
|
+
threads << Thread.new do
|
110
|
+
client.insert_callback do |response|
|
111
|
+
Thread.current[:response] = response
|
112
|
+
end
|
113
|
+
|
114
|
+
ZendeskAPI::Ticket.import(client, :requester => { :email => email, :name => "Hello" }, :subject => "Test", :description => "Test")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
threads.map! do |thread|
|
119
|
+
thread.join(3)
|
120
|
+
thread[:response][:status]
|
121
|
+
end
|
122
|
+
|
123
|
+
threads.all? {|st| [201, 422].include?(st)}.should be_true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
100
127
|
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: 0.2.
|
4
|
+
version: 0.2.2
|
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-12-
|
13
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bump
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- lib/zendesk_api/server/docs/activity_stream.md
|
271
271
|
- lib/zendesk_api/server/docs/attachments.md
|
272
272
|
- lib/zendesk_api/server/docs/autocomplete.md
|
273
|
+
- lib/zendesk_api/server/docs/automations.md
|
273
274
|
- lib/zendesk_api/server/docs/categories.md
|
274
275
|
- lib/zendesk_api/server/docs/custom_roles.md
|
275
276
|
- lib/zendesk_api/server/docs/forum_subscriptions.md
|