class Yammdesk::Yammer
Constants
- CONFIG
Public Class Methods
new()
click to toggle source
# File lib/yammdesk/yammer.rb, line 16 def initialize @url = CONFIG['yammdesk']['url'] @token = CONFIG['yammdesk']['token'] @uri = URI(@url) end
Public Instance Methods
get()
click to toggle source
# File lib/yammdesk/yammer.rb, line 23 def get Net::HTTP.start(@uri.host, @uri.port, :use_ssl => @uri.scheme == 'https') do |http| response = http.get(@url + "/messages/in_group/872.json?oaccess_token=#{@token}") @data = JSON.parse(response.body) return @data['messages'] end end
get_thread_replies(thread_id)
click to toggle source
# File lib/yammdesk/yammer.rb, line 32 def get_thread_replies(thread_id) Net::HTTP.start(@uri.host, @uri.port, :use_ssl => @uri.scheme == 'https') do |http| response = http.get(@url + "/messages/in_thread/#{thread_id}.json?oaccess_token=#{@token}") @data = JSON.parse(response.body) return @data['messages'] end end
get_thread_starter(thread_id)
click to toggle source
# File lib/yammdesk/yammer.rb, line 41 def get_thread_starter(thread_id) url = @url + "/messages/#{thread_id}.json?oaccess_token=#{@token}" uri = URI(@url) Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| response = http.get(url) @data = JSON.parse(response.body) return @data end end
is_thread_starter?(id, thread_id)
click to toggle source
# File lib/yammdesk/yammer.rb, line 67 def is_thread_starter?(id, thread_id) if id == thread_id true else false end end
reply_exists?(whd_note, yamm_replies)
click to toggle source
# File lib/yammdesk/yammer.rb, line 52 def reply_exists?(whd_note, yamm_replies) if yamm_replies.find { |yamm| body = CGI.unescapeHTML(yamm['body']['plain']) body = body.gsub('<br/> ', "\n") body = Nokogiri::HTML.parse(body) body = body.text body == whd_note } return true else return false end end
update_thread(thread_id, body)
click to toggle source
# File lib/yammdesk/yammer.rb, line 75 def update_thread(thread_id, body) body = CGI::unescapeHTML(body) body = body.gsub('<br/> ', "\n") body = Nokogiri::HTML.parse(body) body = body.text url = @url + "/messages.json&oaccess_token=#{@token}" uri = URI(url) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data('replied_to_id' => thread_id, 'body' => body) response = https.request(request) puts "DIDN'T FIND:\n#{body}\n\n".white end