Class: Youroom::PostEntry

Inherits:
Entry show all
Defined in:
lib/youroom_api/request/post_entry.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#access_token

Attributes inherited from Base

#host, #port, #url

Instance Method Summary collapse

Methods inherited from Request

#create_entry, #create_participation, #create_room, #create_user, #delete, #destroy_entry, #destroy_participation, #get, #get_all_timeline, #get_attachment, #get_entry, #get_my_group, #get_picture, #get_room_list, #get_room_timeline, #get_unread_timeline, #get_user_list, #get_verify_credentials, #mark_read, #mark_unread, #post

Constructor Details

#initialize(access_token, room_id, content, parent_id = nil, url = BASE_URL) ⇒ PostEntry

Returns a new instance of PostEntry.



5
6
7
8
9
# File 'lib/youroom_api/request/post_entry.rb', line 5

def initialize(access_token, room_id, content, parent_id=nil, url=BASE_URL)
  [room_id, content].each { |arg| required_structure(arg, String, Symbol, Fixnum) }
  @room_id, @content, @parent_id = room_id, content, parent_id
  super(access_token, url)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/youroom_api/request/post_entry.rb', line 3

def content
  @content
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



3
4
5
# File 'lib/youroom_api/request/post_entry.rb', line 3

def parent_id
  @parent_id
end

#room_idObject (readonly)

Returns the value of attribute room_id.



3
4
5
# File 'lib/youroom_api/request/post_entry.rb', line 3

def room_id
  @room_id
end

Instance Method Details

#paramsObject



15
16
17
18
19
20
21
# File 'lib/youroom_api/request/post_entry.rb', line 15

def params
  if parent_id
    { :entry => { :content => content.to_s, :parent_id => parent_id }, :insert_mention => "" }
  else
    { :entry => { :content => content.to_s }, :insert_mention => "" }
  end.optimize
end

#pathObject



11
12
13
# File 'lib/youroom_api/request/post_entry.rb', line 11

def path
  File.join(url, 'r', room_id.to_s, 'entries?format=json')
end