Module: Model::Post

Extended by:
ActiveSupport::Concern
Defined in:
app/models/wechat/model/post.rb

Instance Method Summary collapse

Instance Method Details

#appObject



18
19
20
21
# File 'app/models/wechat/model/post.rb', line 18

def app
  return @app if defined? @app
  @app = WechatApp.first
end

#to_wechatObject



9
10
11
12
13
14
15
16
# File 'app/models/wechat/model/post.rb', line 9

def to_wechat
  r = app.api.material_add_news xx
  if r['media_id']
    post_sync = app.post_syncs.find_or_initialize_by(source_id: r['media_id'])
    post_sync.post = self
    post_sync.save
  end
end

#xxObject



23
24
25
26
27
28
29
30
31
# File 'app/models/wechat/model/post.rb', line 23

def xx
  {
    title: title,
    thumb_media_id: thumb_media_id,
    show_cover_pic: 0,
    content: content,
    content_source_url: 'https://one.work'
  }
end