zendesk2 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +6 -4
- data/Guardfile +1 -1
- data/lib/zendesk2/client/models/ticket.rb +1 -1
- data/lib/zendesk2/client/models/ticket_field.rb +75 -0
- data/lib/zendesk2/client/models/ticket_fields.rb +11 -0
- data/lib/zendesk2/client/requests/create_ticket_field.rb +42 -0
- data/lib/zendesk2/client/requests/destroy_ticket_field.rb +27 -0
- data/lib/zendesk2/client/requests/get_ticket_field.rb +34 -0
- data/lib/zendesk2/client/requests/get_ticket_fields.rb +18 -0
- data/lib/zendesk2/client/requests/update_ticket_field.rb +29 -0
- data/lib/zendesk2/client.rb +20 -12
- data/lib/zendesk2/version.rb +1 -1
- data/spec/ticket_fields_spec.rb +9 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDJlNjlkMmU1MDlhNWNmMWRhYmY1MzZlNDcwZjU0NmZmNzc0OGJmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmNiOGE1OGZlOTRmNzkyM2NjMTFmNjE1MDIxNjc1MmZlYzAyMTc5Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDg2OTJlZDNkNDBlZTViODc5MTljMTI1YjJjNGJjZDdiNjNhZDAxNzU0NTQ5
|
10
|
+
OWJiMDNjMzM4MzE2MTgxMGU2MzgzNzY2YTYwNWE5ZWJkNzVmODA1YmNjNmE1
|
11
|
+
NGFmNGY0NmFkMDk3ZDY5NDg1MjQ4NDEzNDBmNzcwNzM3Nzk1YTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWQ2NjJhMTNjZGVlOWU1NDQxOGFiYWMxYjZjYWFmNTc2MTEyOTlkZWNhNzM0
|
14
|
+
YWMyMmNkYjFlZDI0OTU0NTE5MjNjNjRjNTQxNGU2ZTMwNTkxODIzYzE1YmRk
|
15
|
+
NTk2NWU3YzFmMjVlM2I3NGM3YjZmOTdkNTQ5YWUyYWFmNTI2ZTc=
|
data/Gemfile
CHANGED
@@ -7,11 +7,13 @@ gem 'rake'
|
|
7
7
|
#To avoid warnings from JWT
|
8
8
|
gem 'json', '~> 1.7.7'
|
9
9
|
|
10
|
+
group :development, :test do
|
11
|
+
gem 'pry-nav'
|
12
|
+
end
|
13
|
+
|
10
14
|
group :test do
|
11
15
|
gem 'awesome_print'
|
12
|
-
gem 'guard-bundler'
|
13
|
-
gem 'guard-rspec'
|
14
|
-
gem 'pry-nav'
|
15
|
-
gem 'rb-fsevent'
|
16
|
+
gem 'guard-bundler', require: false
|
17
|
+
gem 'guard-rspec', require: false
|
16
18
|
gem 'rspec'
|
17
19
|
end
|
data/Guardfile
CHANGED
@@ -3,7 +3,7 @@ guard 'bundler' do
|
|
3
3
|
watch(/^.+\.gemspec/)
|
4
4
|
end
|
5
5
|
|
6
|
-
guard 'rspec', cmd: 'bundle exec rspec' do
|
6
|
+
guard 'rspec', cmd: 'bundle exec rspec', all_on_start: true, all_after_pass: true do
|
7
7
|
watch(%r{^spec/.+_spec\.rb$})
|
8
8
|
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
9
9
|
watch('spec/spec_helper.rb') { "spec" }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Zendesk2::Client::Ticket < Zendesk2::Model
|
2
2
|
extend Zendesk2::Attributes
|
3
3
|
|
4
|
-
PARAMS = %w[external_id via requester_id submitter_id assignee_id organization_id subject description
|
4
|
+
PARAMS = %w[external_id via requester_id submitter_id assignee_id organization_id subject description custom_fields recipient status collaborator_ids tags]
|
5
5
|
|
6
6
|
# @return [Integer] Automatically assigned when creating tickets
|
7
7
|
identity :id, type: :integer
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class Zendesk2::Client::TicketField < Zendesk2::Model
|
2
|
+
extend Zendesk2::Attributes
|
3
|
+
|
4
|
+
PARAMS = %w[type title description position active required collapsed_for_agents regexp_for_validation title_in_portal visible_in_portal editable_in_portal required_in_portal tag custom_field_options]
|
5
|
+
|
6
|
+
# @return [integer] Automatically assigned upon creation
|
7
|
+
identity :id, type: :integer
|
8
|
+
|
9
|
+
# @return [Boolean] Whether this field is available
|
10
|
+
attribute :active, type: :boolean
|
11
|
+
# @return [String] If this field should be shown to agents by default or be hidden alongside infrequently used fields
|
12
|
+
attribute :collapsed_for_agents, type: :string
|
13
|
+
# @return [Date] The time the ticket field was created
|
14
|
+
attribute :created_at, type: :date
|
15
|
+
# @return [Array] Required and presented for a ticket field of type "tagger"
|
16
|
+
attribute :custom_field_options, type: :array
|
17
|
+
# @return [String] The description of the purpose of this ticket field, shown to users
|
18
|
+
attribute :description, type: :string
|
19
|
+
# @return [Boolean] Whether this field is editable by end users
|
20
|
+
attribute :editable_in_portal, type: :boolean
|
21
|
+
# @return [Integer] A relative position for the ticket fields, determines the order of ticket fields on a ticket
|
22
|
+
attribute :position, type: :integer
|
23
|
+
# @return [String] Regular expression field only. The validation pattern for a field value to be deemed valid.
|
24
|
+
attribute :regexp_for_validation, type: :string
|
25
|
+
# @return [Boolean] If this field is not a system basic field that must be present for all tickets on the account
|
26
|
+
attribute :removable, type: :boolean
|
27
|
+
# @return [Boolean] If it's required for this field to have a value when updated by agents
|
28
|
+
attribute :required, type: :boolean
|
29
|
+
# @return [Boolean] If it's required for this field to have a value when updated by end users
|
30
|
+
attribute :required_in_portal, type: :boolean
|
31
|
+
# @return [Array] Presented for a ticket field of type "tickettype", "priority" or "status"
|
32
|
+
attribute :system_field_options, type: :array
|
33
|
+
# @return [String] A tag value to set for checkbox fields when checked
|
34
|
+
attribute :tag, type: :string
|
35
|
+
# @return [String] The title of the ticket field
|
36
|
+
attribute :title, type: :string
|
37
|
+
# @return [String] The title of the ticket field when shown to end users
|
38
|
+
attribute :title_in_portal, type: :string
|
39
|
+
# @return [String] The type of the ticket field
|
40
|
+
attribute :type, type: :string
|
41
|
+
# @return [Date] The time of the last update of the ticket field
|
42
|
+
attribute :updated_at, type: :date
|
43
|
+
# @return [String] The URL for this resource
|
44
|
+
attribute :url, type: :string
|
45
|
+
# @return [Boolean] Whether this field is available to end users
|
46
|
+
attribute :visible_in_portal, type: :boolean
|
47
|
+
|
48
|
+
def save!
|
49
|
+
data = if new_record?
|
50
|
+
requires :type, :title
|
51
|
+
|
52
|
+
self.custom_field_options ||= []
|
53
|
+
|
54
|
+
connection.create_ticket_field(params).body["ticket_field"]
|
55
|
+
else
|
56
|
+
requires :identity
|
57
|
+
|
58
|
+
connection.update_ticket_field(params.merge("id" => self.identity)).body["ticket_field"]
|
59
|
+
end
|
60
|
+
|
61
|
+
merge_attributes(data)
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy!
|
65
|
+
requires :identity
|
66
|
+
|
67
|
+
connection.destroy_ticket_field("id" => self.identity)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def params
|
73
|
+
Cistern::Hash.slice(Zendesk2.stringify_keys(attributes), *PARAMS)
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Zendesk2::Client::TicketFields < Zendesk2::Collection
|
2
|
+
include Zendesk2::Searchable
|
3
|
+
|
4
|
+
model Zendesk2::Client::TicketField
|
5
|
+
|
6
|
+
self.collection_method = :get_ticket_fields
|
7
|
+
self.collection_root = "ticket_fields"
|
8
|
+
self.model_method = :get_ticket_field
|
9
|
+
self.model_root = "ticket_field"
|
10
|
+
self.search_type = "ticket_field"
|
11
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def create_ticket_field(params={})
|
4
|
+
request(
|
5
|
+
:body => {"ticket_field" => params},
|
6
|
+
:method => :post,
|
7
|
+
:path => "/ticket_fields.json",
|
8
|
+
)
|
9
|
+
end
|
10
|
+
end # Real
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def create_ticket_field(params={})
|
14
|
+
identity = self.class.new_id
|
15
|
+
|
16
|
+
record = {
|
17
|
+
"active" => true,
|
18
|
+
"collapsed_for_agents" => false,
|
19
|
+
"created_at" => Time.now.iso8601,
|
20
|
+
"description" => params["title"],
|
21
|
+
"editable_in_portal" => false,
|
22
|
+
"id" => identity,
|
23
|
+
"position" => 9999,
|
24
|
+
"regexp_for_validation" => nil,
|
25
|
+
"required" => true,
|
26
|
+
"required_in_portal" => false,
|
27
|
+
"title_in_portal" => params["title"],
|
28
|
+
"updated_at" => Time.now.iso8601,
|
29
|
+
"url" => url_for("/ticket_fields/#{identity}.json"),
|
30
|
+
"visible_in_portal" => false,
|
31
|
+
}.merge(params)
|
32
|
+
|
33
|
+
self.data[:ticket_fields][identity] = record
|
34
|
+
|
35
|
+
response(
|
36
|
+
:method => :post,
|
37
|
+
:body => {"ticket_field" => record},
|
38
|
+
:path => "/ticket_fields.json"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end # Mock
|
42
|
+
end # Zendesk2::Client
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def destroy_ticket_field(params={})
|
4
|
+
id = params["id"]
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :delete,
|
8
|
+
:path => "/ticket_fields/#{id}.json"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def destroy_ticket_field(params={})
|
15
|
+
id = params["id"]
|
16
|
+
body = self.data[:ticket_fields].delete(id)
|
17
|
+
|
18
|
+
response(
|
19
|
+
:method => :delete,
|
20
|
+
:path => "/ticket_fields/#{id}.json",
|
21
|
+
:body => {
|
22
|
+
"ticket_field" => body,
|
23
|
+
},
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def get_ticket_field(params={})
|
4
|
+
id = params["id"]
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :get,
|
8
|
+
:path => "/ticket_fields/#{id}.json"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end # Real
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def get_ticket_field(params={})
|
15
|
+
id = params["id"]
|
16
|
+
path = "/ticket_fields/#{id}.json"
|
17
|
+
|
18
|
+
if body = self.data[:ticket_fields][id]
|
19
|
+
response(
|
20
|
+
:path => path,
|
21
|
+
:body => {
|
22
|
+
"ticket_field" => body
|
23
|
+
},
|
24
|
+
)
|
25
|
+
else
|
26
|
+
response(
|
27
|
+
:path => path,
|
28
|
+
:status => 404,
|
29
|
+
:body => {"error" => "RecordNotFound", "description" => "Not found"},
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end # Mock
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def get_ticket_fields(params={})
|
4
|
+
page_params = Zendesk2.paging_parameters(params)
|
5
|
+
|
6
|
+
request(
|
7
|
+
:params => page_params,
|
8
|
+
:method => :get,
|
9
|
+
:path => "/ticket_fields.json",
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class Mock
|
14
|
+
def get_ticket_fields(params={})
|
15
|
+
page(params, :ticket_fields, "/ticket_fields.json", "ticket_fields")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def update_ticket_field(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :put,
|
8
|
+
:path => "/ticket_fields/#{id}.json",
|
9
|
+
:body => {
|
10
|
+
"ticket_field" => params
|
11
|
+
},
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class Mock
|
16
|
+
def update_ticket_field(params={})
|
17
|
+
ticket_field_id = params.delete("id")
|
18
|
+
body = self.data[:ticket_fields][ticket_field_id].merge!(params)
|
19
|
+
|
20
|
+
response(
|
21
|
+
:method => :put,
|
22
|
+
:path => "/ticket_fields/#{ticket_field_id}.json",
|
23
|
+
:body => {
|
24
|
+
"ticket_field" => body
|
25
|
+
},
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/zendesk2/client.rb
CHANGED
@@ -11,6 +11,7 @@ class Zendesk2::Client < Cistern::Service
|
|
11
11
|
collection :groups
|
12
12
|
collection :organizations
|
13
13
|
collection :ticket_audits
|
14
|
+
collection :ticket_fields
|
14
15
|
collection :ticket_metrics
|
15
16
|
collection :tickets
|
16
17
|
collection :ticket_comments
|
@@ -29,6 +30,7 @@ class Zendesk2::Client < Cistern::Service
|
|
29
30
|
model :ticket_comment
|
30
31
|
model :ticket_comment_privacy_change
|
31
32
|
model :ticket_create
|
33
|
+
model :ticket_field
|
32
34
|
model :ticket_notification
|
33
35
|
model :ticket_voice_comment
|
34
36
|
model :topic
|
@@ -42,6 +44,7 @@ class Zendesk2::Client < Cistern::Service
|
|
42
44
|
request :create_group
|
43
45
|
request :create_organization
|
44
46
|
request :create_ticket
|
47
|
+
request :create_ticket_field
|
45
48
|
request :create_topic
|
46
49
|
request :create_topic_comment
|
47
50
|
request :create_user
|
@@ -51,6 +54,7 @@ class Zendesk2::Client < Cistern::Service
|
|
51
54
|
request :destroy_group
|
52
55
|
request :destroy_organization
|
53
56
|
request :destroy_ticket
|
57
|
+
request :destroy_ticket_field
|
54
58
|
request :destroy_topic
|
55
59
|
request :destroy_topic_comment
|
56
60
|
request :destroy_user
|
@@ -74,6 +78,8 @@ class Zendesk2::Client < Cistern::Service
|
|
74
78
|
request :get_ticket_audit
|
75
79
|
request :get_ticket_audits
|
76
80
|
request :get_ticket_comments
|
81
|
+
request :get_ticket_field
|
82
|
+
request :get_ticket_fields
|
77
83
|
request :get_ticket_metric
|
78
84
|
request :get_ticket_metrics
|
79
85
|
request :get_tickets
|
@@ -94,6 +100,7 @@ class Zendesk2::Client < Cistern::Service
|
|
94
100
|
request :update_organization
|
95
101
|
request :update_request
|
96
102
|
request :update_ticket
|
103
|
+
request :update_ticket_field
|
97
104
|
request :update_topic
|
98
105
|
request :update_topic_comment
|
99
106
|
request :update_user
|
@@ -129,7 +136,7 @@ class Zendesk2::Client < Cistern::Service
|
|
129
136
|
@username += "/token" if @auth_token == @token
|
130
137
|
@jwt_token = options[:jwt_token]
|
131
138
|
|
132
|
-
raise "Missing required options: :username" unless @username
|
139
|
+
raise "Missing required options: :username" unless @username
|
133
140
|
raise "Missing required options: :password or :token" unless password || @token
|
134
141
|
|
135
142
|
@connection = Faraday.new({url: @url}.merge(connection_options)) do |builder|
|
@@ -171,18 +178,19 @@ class Zendesk2::Client < Cistern::Service
|
|
171
178
|
|
172
179
|
def self.data
|
173
180
|
@data ||= {
|
174
|
-
:categories
|
175
|
-
:forums
|
176
|
-
:groups
|
177
|
-
:identities
|
178
|
-
:organizations
|
179
|
-
:ticket_audits
|
181
|
+
:categories => {},
|
182
|
+
:forums => {},
|
183
|
+
:groups => {},
|
184
|
+
:identities => {},
|
185
|
+
:organizations => {},
|
186
|
+
:ticket_audits => {},
|
180
187
|
:ticket_comments => {},
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
188
|
+
:ticket_fields => {},
|
189
|
+
:ticket_metrics => {},
|
190
|
+
:tickets => {},
|
191
|
+
:topic_comments => {},
|
192
|
+
:topics => {},
|
193
|
+
:users => {},
|
186
194
|
}
|
187
195
|
end
|
188
196
|
|
data/lib/zendesk2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
@@ -117,6 +117,8 @@ files:
|
|
117
117
|
- lib/zendesk2/client/models/ticket_comment_privacy_change.rb
|
118
118
|
- lib/zendesk2/client/models/ticket_comments.rb
|
119
119
|
- lib/zendesk2/client/models/ticket_create.rb
|
120
|
+
- lib/zendesk2/client/models/ticket_field.rb
|
121
|
+
- lib/zendesk2/client/models/ticket_fields.rb
|
120
122
|
- lib/zendesk2/client/models/ticket_metric.rb
|
121
123
|
- lib/zendesk2/client/models/ticket_metrics.rb
|
122
124
|
- lib/zendesk2/client/models/ticket_notification.rb
|
@@ -135,6 +137,7 @@ files:
|
|
135
137
|
- lib/zendesk2/client/requests/create_group.rb
|
136
138
|
- lib/zendesk2/client/requests/create_organization.rb
|
137
139
|
- lib/zendesk2/client/requests/create_ticket.rb
|
140
|
+
- lib/zendesk2/client/requests/create_ticket_field.rb
|
138
141
|
- lib/zendesk2/client/requests/create_topic.rb
|
139
142
|
- lib/zendesk2/client/requests/create_topic_comment.rb
|
140
143
|
- lib/zendesk2/client/requests/create_user.rb
|
@@ -144,6 +147,7 @@ files:
|
|
144
147
|
- lib/zendesk2/client/requests/destroy_group.rb
|
145
148
|
- lib/zendesk2/client/requests/destroy_organization.rb
|
146
149
|
- lib/zendesk2/client/requests/destroy_ticket.rb
|
150
|
+
- lib/zendesk2/client/requests/destroy_ticket_field.rb
|
147
151
|
- lib/zendesk2/client/requests/destroy_topic.rb
|
148
152
|
- lib/zendesk2/client/requests/destroy_topic_comment.rb
|
149
153
|
- lib/zendesk2/client/requests/destroy_user.rb
|
@@ -168,6 +172,8 @@ files:
|
|
168
172
|
- lib/zendesk2/client/requests/get_ticket_audit.rb
|
169
173
|
- lib/zendesk2/client/requests/get_ticket_audits.rb
|
170
174
|
- lib/zendesk2/client/requests/get_ticket_comments.rb
|
175
|
+
- lib/zendesk2/client/requests/get_ticket_field.rb
|
176
|
+
- lib/zendesk2/client/requests/get_ticket_fields.rb
|
171
177
|
- lib/zendesk2/client/requests/get_ticket_metric.rb
|
172
178
|
- lib/zendesk2/client/requests/get_ticket_metrics.rb
|
173
179
|
- lib/zendesk2/client/requests/get_tickets.rb
|
@@ -188,6 +194,7 @@ files:
|
|
188
194
|
- lib/zendesk2/client/requests/update_organization.rb
|
189
195
|
- lib/zendesk2/client/requests/update_request.rb
|
190
196
|
- lib/zendesk2/client/requests/update_ticket.rb
|
197
|
+
- lib/zendesk2/client/requests/update_ticket_field.rb
|
191
198
|
- lib/zendesk2/client/requests/update_topic.rb
|
192
199
|
- lib/zendesk2/client/requests/update_topic_comment.rb
|
193
200
|
- lib/zendesk2/client/requests/update_user.rb
|
@@ -206,6 +213,7 @@ files:
|
|
206
213
|
- spec/shared/resource.rb
|
207
214
|
- spec/spec_helper.rb
|
208
215
|
- spec/support/client_helper.rb
|
216
|
+
- spec/ticket_fields_spec.rb
|
209
217
|
- spec/tickets_spec.rb
|
210
218
|
- spec/topic_comments_spec.rb
|
211
219
|
- spec/topics_spec.rb
|
@@ -245,6 +253,7 @@ test_files:
|
|
245
253
|
- spec/shared/resource.rb
|
246
254
|
- spec/spec_helper.rb
|
247
255
|
- spec/support/client_helper.rb
|
256
|
+
- spec/ticket_fields_spec.rb
|
248
257
|
- spec/tickets_spec.rb
|
249
258
|
- spec/topic_comments_spec.rb
|
250
259
|
- spec/topics_spec.rb
|