Module: Wechat::Api::Public::Base

Included in:
Wechat::Api::Program, Wechat::Api::Public
Defined in:
app/apis/wechat/api/public/base.rb

Constant Summary collapse

BASE =
'https://api.weixin.qq.com/cgi-bin/'

Instance Method Summary collapse

Instance Method Details

#callbackipObject



7
8
9
# File 'app/apis/wechat/api/public/base.rb', line 7

def callbackip
  get 'getcallbackip', base: BASE
end

#clear_quotaObject



20
21
22
# File 'app/apis/wechat/api/public/base.rb', line 20

def clear_quota
  post 'clear_quota', appid: app.appid, base: BASE
end

#jsapi_ticketObject



15
16
17
# File 'app/apis/wechat/api/public/base.rb', line 15

def jsapi_ticket
  get 'ticket/getticket', params: { type: 'jsapi' }, base: BASE
end

#media_uploadimg(file) ⇒ Object



47
48
49
# File 'app/apis/wechat/api/public/base.rb', line 47

def media_uploadimg(file)
  post_file 'media/uploadimg', file, base: BASE
end

#media_uploadnews(mpnews_message) ⇒ Object



52
53
54
# File 'app/apis/wechat/api/public/base.rb', line 52

def media_uploadnews(mpnews_message)
  post 'media/uploadnews', mpnews_message, base: BASE
end

#message_mass_delete(msg_id) ⇒ Object



56
57
58
# File 'app/apis/wechat/api/public/base.rb', line 56

def message_mass_delete(msg_id)
  post 'message/mass/delete', msg_id: msg_id, base: BASE
end

#message_mass_get(msg_id) ⇒ Object



64
65
66
# File 'app/apis/wechat/api/public/base.rb', line 64

def message_mass_get(msg_id)
  post 'message/mass/get', msg_id: msg_id, base: BASE
end

#message_mass_preview(message) ⇒ Object



60
61
62
# File 'app/apis/wechat/api/public/base.rb', line 60

def message_mass_preview(message)
  post 'message/mass/preview', message, base: BASE
end

#qrcode_create_limit_scene(scene_id_or_str) ⇒ Object



33
34
35
36
37
38
39
40
# File 'app/apis/wechat/api/public/base.rb', line 33

def qrcode_create_limit_scene(scene_id_or_str)
  case scene_id_or_str
  when 0.class
    post 'qrcode/create', action_name: 'QR_LIMIT_SCENE', action_info: { scene: { scene_id: scene_id_or_str } }, base: BASE
  else
    post 'qrcode/create', action_name: 'QR_LIMIT_STR_SCENE', action_info: { scene: { scene_str: scene_id_or_str } }, base: BASE
  end
end

#qrcode_create_scene(scene_id_or_str, expire_seconds = 2592000) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/apis/wechat/api/public/base.rb', line 24

def qrcode_create_scene(scene_id_or_str, expire_seconds = 2592000)
  case scene_id_or_str
  when 0.class
    post 'qrcode/create', expire_seconds: expire_seconds, action_name: 'QR_SCENE', action_info: { scene: { scene_id: scene_id_or_str } }, base: BASE
  else
    post 'qrcode/create', expire_seconds: expire_seconds, action_name: 'QR_STR_SCENE', action_info: { scene: { scene_str: scene_id_or_str } }, base: BASE
  end
end

#shorturl(long_url) ⇒ Object



42
43
44
# File 'app/apis/wechat/api/public/base.rb', line 42

def shorturl(long_url)
  post 'shorturl', action: 'long2short', long_url: long_url, base: BASE
end

#tokenObject



11
12
13
# File 'app/apis/wechat/api/public/base.rb', line 11

def token
  client.get 'token', params: { grant_type: 'client_credential', appid: app.appid, secret: app.secret }, base: BASE
end

#wxa_create_qrcode(path, width = 430) ⇒ Object



68
69
70
# File 'app/apis/wechat/api/public/base.rb', line 68

def wxa_create_qrcode(path, width = 430)
  post 'wxaapp/createwxaqrcode', path: path, width: width, base: BASE
end