forked from algolia/algoliasearch-zendesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzendesk.rb
69 lines (62 loc) · 1.51 KB
/
zendesk.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'zendesk_api'
# Help Center support (https://github.com/zendesk/zendesk_api_client_rb/issues/175)
module ZendeskAPI
class Article < Resource; end
class Section < Resource; end
class Translation < Resource; end
class UserSegment < Resource; end
class UserSegment < Resource
namespace 'help_center'
end
class HcLocale < Resource
namespace 'help_center'
def self.singular_resource_name
'locale'
end
end
class Category < Resource
namespace 'help_center'
has_many Section
has_many Article
has_many Translation
end
class Section < Resource
namespace 'help_center'
has_many Article
has_many Translation
has Category
has UserSegment
end
class Article < Resource
namespace 'help_center'
has_many Translation
has Section
has :author, class: User
end
class Topic < Resource; end
class Post < Resource; end
class Comment < Resource; end
class Topic < Resource
namespace 'community'
has_many Post
end
class Post < Resource
namespace 'community'
has_many Comment
has Topic
has :author, class: User
end
class Comment
namespace 'community'
end
CLIENT = ZendeskAPI::Client.new do |config|
config.url = "https://#{CONFIG['app_name']}.zendesk.com/api/v2"
if CONFIG['oauth_token'].nil? # To remove in the end
config.username = CONFIG['email']
config.token = CONFIG['api_token']
else
config.access_token = CONFIG['oauth_token']
end
config.retry = true
end
end