Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/zenpush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def z
@z ||= ZenPush::Zendesk.new
end

#
#
def file_to_category_forum_entry(file)
absolute_path = File.realpath(file)
parts = absolute_path.split('/')
Expand Down
6 changes: 5 additions & 1 deletion lib/zenpush/zendesk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class Zendesk
headers 'Content-Type' => 'application/json'
# debug_output

attr_reader :mode

def initialize(b = nil, u = nil, p = nil)
if b.nil? || u.nil? || p.nil?
creds = YAML.load_file(File.join(ENV['HOME'], '.zenpush.yml'))
b ||= creds['uri']
u ||= creds['user']
p ||= creds['password']
@mode = creds['mode']
end

self.class.base_uri b + '/api/v1'
Expand Down Expand Up @@ -68,13 +71,14 @@ def entry(entry_id, options = {})

# Find category by name
def find_category(category_name, options = {})
return nil if mode == 'starter'
self.categories.detect {|c| c['name'] == category_name}
end

# Find forum by name, knowing the category name
def find_forum(category_name, forum_name, options = {})
category = self.find_category(category_name, options)
if category
if category || mode == 'starter'
self.forums.detect {|f| f['name'] == forum_name}
end
end
Expand Down