zendesk2 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +89 -86
- data/lib/zendesk2/client/models/topic.rb +53 -0
- data/lib/zendesk2/client/models/topics.rb +12 -0
- data/lib/zendesk2/client/requests/create_topic.rb +33 -0
- data/lib/zendesk2/client/requests/destroy_topic.rb +28 -0
- data/lib/zendesk2/client/requests/get_topic.rb +26 -0
- data/lib/zendesk2/client/requests/get_topics.rb +18 -0
- data/lib/zendesk2/client/requests/update_topic.rb +30 -0
- data/lib/zendesk2/client.rb +8 -0
- data/lib/zendesk2/version.rb +1 -1
- data/spec/topics_spec.rb +10 -0
- metadata +12 -3
- data/.rspec +0 -1
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,9 +7,9 @@ Ruby client for the [Zendesk V2 API](http://developer.zendesk.com/documentation/
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
```ruby
|
11
|
+
gem 'zendesk2'
|
12
|
+
```
|
13
13
|
Or install it yourself as:
|
14
14
|
|
15
15
|
$ gem install zendesk2
|
@@ -50,107 +50,110 @@ Currently support resources
|
|
50
50
|
* Ticket
|
51
51
|
* Organization
|
52
52
|
* Forums
|
53
|
+
* Topics
|
53
54
|
|
54
55
|
All collection are accessed like so:
|
55
56
|
```ruby
|
56
57
|
client.users.all
|
57
|
-
=>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
=> <Zendesk2::Client::Users
|
59
|
+
count=1779,
|
60
|
+
next_page_link="https://dev.zendesk.com/api/v2/users.json?page=2",
|
61
|
+
previous_page_link=nil
|
62
|
+
[
|
63
|
+
<Zendesk2::Client::User
|
64
|
+
id=125394183,
|
65
|
+
url="https://dev.zendesk.com/api/v2/users/125394183.json",
|
65
66
|
...
|
66
|
-
|
67
|
-
|
67
|
+
>
|
68
|
+
]
|
68
69
|
```
|
69
70
|
Collections also respond to `create` and `new`
|
71
|
+
```ruby
|
72
|
+
client.users.create(email: "ohhai@example.org", name: "lulz")
|
73
|
+
=> <Zendesk2::Client::User
|
74
|
+
id=234020811,
|
75
|
+
...
|
76
|
+
url="https://engineyarddev.zendesk.com/api/v2/users/234020811.json",
|
77
|
+
...
|
78
|
+
email="ohhai@example.org",
|
79
|
+
>
|
80
|
+
```
|
70
81
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
=> <Zendesk2::Client::User
|
83
|
-
id=nil,
|
84
|
-
...
|
85
|
-
url=nil,
|
86
|
-
...
|
87
|
-
email="ohhai@example.org",
|
88
|
-
...
|
89
|
-
>
|
90
|
-
|
82
|
+
```ruby
|
83
|
+
client.users.new(email: "ohhai@example.org")
|
84
|
+
=> <Zendesk2::Client::User
|
85
|
+
id=nil,
|
86
|
+
...
|
87
|
+
url=nil,
|
88
|
+
...
|
89
|
+
email="ohhai@example.org",
|
90
|
+
...
|
91
|
+
>
|
92
|
+
```
|
91
93
|
#### Paging
|
92
94
|
|
93
95
|
Paged collections respond to `next_page` and `previous_page` when appropriate. `page_size` and `page` can be passed directly to the collection to control size and index.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
96
|
+
```ruby
|
97
|
+
page = client.users.all("per_page" => 1, "page" => 4)
|
98
|
+
=> <Zendesk2::Client::Users
|
99
|
+
count=1780,
|
100
|
+
next_page_link="https://dev.zendesk.com/api/v2/users.json?page=5&per_page=1",
|
101
|
+
previous_page_link="https://dev.zendesk.com/api/v2/users.json?page=3&per_page=1"
|
102
|
+
[
|
103
|
+
<Zendesk2::Client::User
|
104
|
+
id=217761652,
|
105
|
+
url="https://dev.zendesk.com/api/v2/users/217761652.json",
|
106
|
+
external_id=nil,
|
107
|
+
name="Guy Dude",
|
108
|
+
...
|
109
|
+
>
|
110
|
+
]
|
111
|
+
```
|
112
|
+
```ruby
|
113
|
+
page.next_page
|
114
|
+
=> <Zendesk2::Client::Users
|
115
|
+
count=1780,
|
116
|
+
next_page_link="https://dev.zendesk.com/api/v2/users.json?page=6&per_page=1",
|
117
|
+
previous_page_link="https://dev.zendesk.com/api/v2/users.json?page=4&per_page=1"
|
118
|
+
[
|
119
|
+
<Zendesk2::Client::User
|
120
|
+
id=217761742,
|
121
|
+
url="https://dev.zendesk.com/api/v2/users/217761742.json",
|
122
|
+
...
|
123
|
+
name="epitaphical osteofibrous",
|
124
|
+
...
|
125
|
+
>
|
126
|
+
]
|
127
|
+
```
|
128
|
+
```ruby
|
129
|
+
page.previous_page
|
130
|
+
=> <Zendesk2::Client::Users
|
131
|
+
count=1780,
|
132
|
+
next_page_link="https://dev.zendesk.com/api/v2/users.json?page=5&per_page=1",
|
133
|
+
previous_page_link="https://dev.zendesk.com/api/v2/users.json?page=3&per_page=1"
|
134
|
+
[
|
135
|
+
<Zendesk2::Client::User
|
136
|
+
id=217761652,
|
137
|
+
url="https://dev.zendesk.com/api/v2/users/217761652.json",
|
138
|
+
...
|
139
|
+
name="Guy Dude",
|
140
|
+
...
|
141
|
+
>
|
142
|
+
]
|
143
|
+
```
|
140
144
|
#### Models
|
141
145
|
|
142
146
|
All models respond to `destroy` and `save` if applicable. `save` performs a 'create' operation if there is no identity provided or an 'update' if there is an identity.
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
+
```ruby
|
148
|
+
Zendesk2::Client::Ticket.new.save # performs a create
|
149
|
+
Zendesk2::Client::Ticket.new(id: 1).save # performs an update
|
150
|
+
```
|
147
151
|
Attributes can be enumerated by the `attributes` method.
|
148
152
|
|
149
153
|
## Releasing
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
$ gem bump -trv (major|minor|patch)
|
155
|
+
$ gem install gem-release
|
156
|
+
$ gem bump -trv (major|minor|patch)
|
154
157
|
|
155
158
|
## Contributing
|
156
159
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Zendesk2::Client::Topic < Cistern::Model
|
2
|
+
extend Zendesk2::Attributes
|
3
|
+
|
4
|
+
PARAMS = %w[id title body submitter_id updater_id forum_id locked pinned highlighted position tags]
|
5
|
+
|
6
|
+
identity :id, type: :integer # ro[yes] mandatory[no] Automatically assigned upon creation
|
7
|
+
attribute :url, type: :string # ro[yes] mandatory[no] The API url of this topic
|
8
|
+
attribute :title, type: :string # ro[no] mandatory[yes] The title of the topic
|
9
|
+
attribute :body, type: :string # ro[no] mandatory[yes] The unescaped body of the topic
|
10
|
+
attribute :topic_type, type: :string # ro[yes] mandatory[no] The type of topic. Either "articles", "ideas" or "questions"
|
11
|
+
attribute :submitter_id, type: :integer # ro[no] mandatory[no] The id of the user who submitted the topic
|
12
|
+
attribute :updater_id, type: :integer # ro[no] mandatory[no] The id of the person to last update the topic
|
13
|
+
attribute :forum_id, type: :integer # ro[no] mandatory[no] Forum that the topic is associated to
|
14
|
+
attribute :locked, type: :boolean # ro[no] mandatory[no] Whether comments are allowed
|
15
|
+
attribute :pinned, type: :boolean # ro[no] mandatory[no] If the topic is marked as pinned and hence eligible to show up on the front page
|
16
|
+
attribute :highlighted, type: :boolean # ro[no] mandatory[no] Set to true to highlight a topic within its forum
|
17
|
+
attribute :answered, type: :boolean # ro[yes] mandatory[no] Set to true if the topic is a question and it has been marked as answered.
|
18
|
+
attribute :position, type: :integer # ro[no] mandatory[no] The position of this topic relative to other topics in the same forum
|
19
|
+
attribute :tags, type: :array # ro[no] mandatory[no] The tags set on the topic
|
20
|
+
attribute :created_at, type: :date # ro[yes] mandatory[no] The time the topic was created
|
21
|
+
|
22
|
+
assoc_accessor :submitter, collection: :users
|
23
|
+
assoc_accessor :updater, collection: :users
|
24
|
+
assoc_accessor :forum
|
25
|
+
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
requires :identity
|
29
|
+
|
30
|
+
connection.destroy_topic("id" => self.identity)
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroyed?
|
34
|
+
!self.reload
|
35
|
+
end
|
36
|
+
|
37
|
+
def save
|
38
|
+
data = if new_record?
|
39
|
+
requires :title, :body
|
40
|
+
connection.create_topic(params).body["topic"]
|
41
|
+
else
|
42
|
+
requires :identity
|
43
|
+
connection.update_topic(params).body["topic"]
|
44
|
+
end
|
45
|
+
merge_attributes(data)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def params
|
51
|
+
Cistern::Hash.slice(Zendesk2.stringify_keys(attributes), *PARAMS)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Zendesk2::Client::Topics < Cistern::Collection
|
2
|
+
include Zendesk2::PagedCollection
|
3
|
+
include Zendesk2::Searchable
|
4
|
+
|
5
|
+
model Zendesk2::Client::Topic
|
6
|
+
|
7
|
+
self.collection_method= :get_topics
|
8
|
+
self.collection_root= "topics"
|
9
|
+
self.model_method= :get_topic
|
10
|
+
self.model_root= "topic"
|
11
|
+
self.search_type= "topic"
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def create_topic(params={})
|
4
|
+
request(
|
5
|
+
:body => {"topic" => params},
|
6
|
+
:method => :post,
|
7
|
+
:path => "/topics.json",
|
8
|
+
)
|
9
|
+
end
|
10
|
+
end # Real
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def create_topic(params={})
|
14
|
+
identity = self.class.new_id
|
15
|
+
|
16
|
+
record = {
|
17
|
+
"id" => identity,
|
18
|
+
"url" => url_for("/topics/#{identity}.json"),
|
19
|
+
"created_at" => Time.now.iso8601,
|
20
|
+
"updated_at" => Time.now.iso8601,
|
21
|
+
}.merge(params)
|
22
|
+
|
23
|
+
path = "/topics.json"
|
24
|
+
self.data[:topics][identity]= record
|
25
|
+
|
26
|
+
response(
|
27
|
+
:method => :post,
|
28
|
+
:body => {"topic" => record},
|
29
|
+
:path => path,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end # Mock
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def destroy_topic(params={})
|
4
|
+
id = params["id"]
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :delete,
|
8
|
+
:path => "/topics/#{id}.json"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def destroy_topic(params={})
|
15
|
+
id = params["id"]
|
16
|
+
path = "/topics/#{id}.json"
|
17
|
+
|
18
|
+
body = self.data[:topics].delete(id)
|
19
|
+
response(
|
20
|
+
:method => :delete,
|
21
|
+
:path => path,
|
22
|
+
:body => {
|
23
|
+
"topic" => body,
|
24
|
+
},
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def get_topic(params={})
|
4
|
+
id = params["id"]
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :get,
|
8
|
+
:path => "/topics/#{id}.json"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end # Real
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def get_topic(params={})
|
15
|
+
id = params["id"]
|
16
|
+
body = self.data[:topics][id]
|
17
|
+
|
18
|
+
response(
|
19
|
+
:path => "/topics/#{id}.json",
|
20
|
+
:body => {
|
21
|
+
"topic" => body
|
22
|
+
},
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end # Mock
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def get_topics(params={})
|
4
|
+
page_params = Zendesk2.paging_parameters(params)
|
5
|
+
|
6
|
+
request(
|
7
|
+
:params => page_params,
|
8
|
+
:method => :get,
|
9
|
+
:path => "/topics.json",
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class Mock
|
14
|
+
def get_topics(params={})
|
15
|
+
page(params, :topics, "/topics.json", "topics")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class Real
|
3
|
+
def update_topic(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :put,
|
8
|
+
:path => "/topics/#{id}.json",
|
9
|
+
:body => {
|
10
|
+
"topic" => params
|
11
|
+
},
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class Mock
|
16
|
+
def update_topic(params={})
|
17
|
+
id = params.delete("id")
|
18
|
+
path = "/topics/#{id}.json"
|
19
|
+
|
20
|
+
body = self.data[:topics][id].merge!(params)
|
21
|
+
response(
|
22
|
+
:method => :put,
|
23
|
+
:path => path,
|
24
|
+
:body => {
|
25
|
+
"topic" => body
|
26
|
+
},
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/zendesk2/client.rb
CHANGED
@@ -7,6 +7,8 @@ class Zendesk2::Client < Cistern::Service
|
|
7
7
|
collection :categories
|
8
8
|
model :forum
|
9
9
|
collection :forums
|
10
|
+
model :topic
|
11
|
+
collection :topics
|
10
12
|
model :organization
|
11
13
|
collection :organizations
|
12
14
|
model :ticket
|
@@ -16,17 +18,20 @@ class Zendesk2::Client < Cistern::Service
|
|
16
18
|
|
17
19
|
request :create_category
|
18
20
|
request :create_forum
|
21
|
+
request :create_topic
|
19
22
|
request :create_organization
|
20
23
|
request :create_ticket
|
21
24
|
request :create_user
|
22
25
|
request :destroy_category
|
23
26
|
request :destroy_forum
|
27
|
+
request :destroy_topic
|
24
28
|
request :destroy_organization
|
25
29
|
request :destroy_ticket
|
26
30
|
request :destroy_user
|
27
31
|
request :get_current_user
|
28
32
|
request :get_category
|
29
33
|
request :get_forum
|
34
|
+
request :get_topic
|
30
35
|
request :get_organization
|
31
36
|
request :get_organization_tickets
|
32
37
|
request :get_organization_users
|
@@ -34,6 +39,7 @@ class Zendesk2::Client < Cistern::Service
|
|
34
39
|
request :get_user
|
35
40
|
request :get_categories
|
36
41
|
request :get_forums
|
42
|
+
request :get_topics
|
37
43
|
request :get_organizations
|
38
44
|
request :get_requested_tickets
|
39
45
|
request :get_ccd_tickets
|
@@ -42,6 +48,7 @@ class Zendesk2::Client < Cistern::Service
|
|
42
48
|
request :search
|
43
49
|
request :update_category
|
44
50
|
request :update_forum
|
51
|
+
request :update_topic
|
45
52
|
request :update_organization
|
46
53
|
request :update_ticket
|
47
54
|
request :update_user
|
@@ -118,6 +125,7 @@ class Zendesk2::Client < Cistern::Service
|
|
118
125
|
:organizations => {},
|
119
126
|
:tickets => {},
|
120
127
|
:forums => {},
|
128
|
+
:topics => {},
|
121
129
|
:categories => {},
|
122
130
|
}
|
123
131
|
end
|
data/lib/zendesk2/version.rb
CHANGED
data/spec/topics_spec.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "topics" do
|
4
|
+
let(:client) { create_client }
|
5
|
+
let(:forum) { client.forums.create(name: Zendesk2.uuid) }
|
6
|
+
it_should_behave_like "a resource",
|
7
|
+
:topics,
|
8
|
+
lambda { {title: Zendesk2.uuid, body: Zendesk2.uuid, forum_id: forum.id} },
|
9
|
+
lambda { {title: Zendesk2.uuid, body: Zendesk2.uuid} }
|
10
|
+
end
|
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.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cistern
|
@@ -83,7 +83,6 @@ extensions: []
|
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
85
|
- .gitignore
|
86
|
-
- .rspec
|
87
86
|
- .travis.yml
|
88
87
|
- Gemfile
|
89
88
|
- Guardfile
|
@@ -101,17 +100,21 @@ files:
|
|
101
100
|
- lib/zendesk2/client/models/organizations.rb
|
102
101
|
- lib/zendesk2/client/models/ticket.rb
|
103
102
|
- lib/zendesk2/client/models/tickets.rb
|
103
|
+
- lib/zendesk2/client/models/topic.rb
|
104
|
+
- lib/zendesk2/client/models/topics.rb
|
104
105
|
- lib/zendesk2/client/models/user.rb
|
105
106
|
- lib/zendesk2/client/models/users.rb
|
106
107
|
- lib/zendesk2/client/requests/create_category.rb
|
107
108
|
- lib/zendesk2/client/requests/create_forum.rb
|
108
109
|
- lib/zendesk2/client/requests/create_organization.rb
|
109
110
|
- lib/zendesk2/client/requests/create_ticket.rb
|
111
|
+
- lib/zendesk2/client/requests/create_topic.rb
|
110
112
|
- lib/zendesk2/client/requests/create_user.rb
|
111
113
|
- lib/zendesk2/client/requests/destroy_category.rb
|
112
114
|
- lib/zendesk2/client/requests/destroy_forum.rb
|
113
115
|
- lib/zendesk2/client/requests/destroy_organization.rb
|
114
116
|
- lib/zendesk2/client/requests/destroy_ticket.rb
|
117
|
+
- lib/zendesk2/client/requests/destroy_topic.rb
|
115
118
|
- lib/zendesk2/client/requests/destroy_user.rb
|
116
119
|
- lib/zendesk2/client/requests/get_categories.rb
|
117
120
|
- lib/zendesk2/client/requests/get_category.rb
|
@@ -126,6 +129,8 @@ files:
|
|
126
129
|
- lib/zendesk2/client/requests/get_requested_tickets.rb
|
127
130
|
- lib/zendesk2/client/requests/get_ticket.rb
|
128
131
|
- lib/zendesk2/client/requests/get_tickets.rb
|
132
|
+
- lib/zendesk2/client/requests/get_topic.rb
|
133
|
+
- lib/zendesk2/client/requests/get_topics.rb
|
129
134
|
- lib/zendesk2/client/requests/get_user.rb
|
130
135
|
- lib/zendesk2/client/requests/get_users.rb
|
131
136
|
- lib/zendesk2/client/requests/search.rb
|
@@ -133,6 +138,7 @@ files:
|
|
133
138
|
- lib/zendesk2/client/requests/update_forum.rb
|
134
139
|
- lib/zendesk2/client/requests/update_organization.rb
|
135
140
|
- lib/zendesk2/client/requests/update_ticket.rb
|
141
|
+
- lib/zendesk2/client/requests/update_topic.rb
|
136
142
|
- lib/zendesk2/client/requests/update_user.rb
|
137
143
|
- lib/zendesk2/error.rb
|
138
144
|
- lib/zendesk2/logger.rb
|
@@ -146,6 +152,7 @@ files:
|
|
146
152
|
- spec/spec_helper.rb
|
147
153
|
- spec/support/client_helper.rb
|
148
154
|
- spec/tickets_spec.rb
|
155
|
+
- spec/topics_spec.rb
|
149
156
|
- spec/users_spec.rb
|
150
157
|
- zendesk2.gemspec
|
151
158
|
homepage: http://joshualane.com/zendesk2
|
@@ -180,4 +187,6 @@ test_files:
|
|
180
187
|
- spec/spec_helper.rb
|
181
188
|
- spec/support/client_helper.rb
|
182
189
|
- spec/tickets_spec.rb
|
190
|
+
- spec/topics_spec.rb
|
183
191
|
- spec/users_spec.rb
|
192
|
+
has_rdoc:
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|