Module: WeChat::Menu

Extended by:
ActiveSupport::Concern
Includes:
Entity::Base
Defined in:
lib/we_chat/menu.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Entity::Base

#delete_from_we_chat, #get_we_chat_id_from_data, #reset_we_chat_id, #set_we_chat_id, #submit_to_we_chat, #submitted_to_we_chat?, #update_to_we_chat

Instance Method Details

#children_to_we_chat_dataObject



24
25
26
# File 'lib/we_chat/menu.rb', line 24

def children_to_we_chat_data
  self.children.inject([]) {|list, item| list << item.to_we_chat_data}
end

#to_we_chat_dataObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/we_chat/menu.rb', line 8

def to_we_chat_data
  result = {}
  result[:name] = self.name
  if self.top_node?
    result[:sub_button] = children_to_we_chat_data
  else
    result[:type] = self.menu_type
    if self.view?
      result[:url] = self.menu_url
    else
      result[:key] = self.menu_key
    end
  end
  result
end