class MAndM::Server
Public Instance Methods
messages()
click to toggle source
# File lib/m_and_m/server.rb, line 6 def messages HTTParty.get message_url end
say(to_uuid, message_id)
click to toggle source
# File lib/m_and_m/server.rb, line 10 def say to_uuid, message_id HTTParty.post base_url, body: message_body(to_uuid, message_id), headers: headers end
Private Instance Methods
authenticated_base_url()
click to toggle source
# File lib/m_and_m/server.rb, line 34 def authenticated_base_url "#{base_url}?uuid=#{token}" end
headers()
click to toggle source
# File lib/m_and_m/server.rb, line 22 def headers {'ContentType' => 'application/json'} end
last_message_id()
click to toggle source
# File lib/m_and_m/server.rb, line 26 def last_message_id preferences[:last_message_id] end
message_body(to_uuid, message_id)
click to toggle source
# File lib/m_and_m/server.rb, line 18 def message_body to_uuid, message_id {uuid: token, to_uuid: to_uuid, message_id: message_id} end
message_url()
click to toggle source
# File lib/m_and_m/server.rb, line 38 def message_url last_message_id ? "#{authenticated_base_url}&id=#{last_message_id}" : authenticated_base_url end
token()
click to toggle source
# File lib/m_and_m/server.rb, line 30 def token preferences.ask :token, 'What is the authentication token' end