Module: Model::AppSync
- Extended by:
- ActiveSupport::Concern
- Included in:
- Wechat::Agency, Wechat::App
- Defined in:
- app/models/wechat/model/app_sync.rb
Instance Method Summary collapse
Instance Method Details
#access_token_valid? ⇒ Boolean
15 16 17 18 |
# File 'app/models/wechat/model/app_sync.rb', line 15 def access_token_valid? return false unless access_token_expires_at.acts_like?(:time) access_token_expires_at > Time.current end |
#sync_from_menu ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/wechat/model/app_sync.rb', line 20 def r = api. = r.dig('menu', 'button') .each do || if ['sub_button'].present? parent = self..build(type: 'ParentMenu', name: ['name']) ['sub_button'].each do |sub| parent.children.build(appid: appid, name: sub['name'], menu_type: sub['type'], value: sub['url'] || sub['key']) end parent.save end end end |