Class: Wechat::ApiBase

Inherits:
Object
  • Object
show all
Defined in:
lib/wechat/api_base.rb

Direct Known Subclasses

Api, CorpApi, MpApi

Constant Summary collapse

API_BASE =
'https://api.weixin.qq.com/cgi-bin/'
MP_BASE =
'https://mp.weixin.qq.com/cgi-bin/'
WXA_BASE =
'https://api.weixin.qq.com/wxa/'
OAUTH2_BASE =
'https://api.weixin.qq.com/sns/'
DATACUBE_BASE =
'https://api.weixin.qq.com/datacube/'
TCB_BASE =
'https://api.weixin.qq.com/tcb/'
QYAPI_BASE =
'https://qyapi.weixin.qq.com/cgi-bin/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/wechat/api_base.rb', line 5

def access_token
  @access_token
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/wechat/api_base.rb', line 5

def client
  @client
end

#jsapi_ticketObject (readonly)

Returns the value of attribute jsapi_ticket.



5
6
7
# File 'lib/wechat/api_base.rb', line 5

def jsapi_ticket
  @jsapi_ticket
end

#qcloudObject (readonly)

Returns the value of attribute qcloud.



5
6
7
# File 'lib/wechat/api_base.rb', line 5

def qcloud
  @qcloud
end

Instance Method Details

#callbackipObject



15
16
17
# File 'lib/wechat/api_base.rb', line 15

def callbackip
  get 'getcallbackip'
end

#clear_quotaObject



43
44
45
# File 'lib/wechat/api_base.rb', line 43

def clear_quota
  post 'clear_quota', JSON.generate(appid: Wechat.config[:appid])
end

#media(media_id) ⇒ Object



23
24
25
# File 'lib/wechat/api_base.rb', line 23

def media(media_id)
  get 'media/get', params: { media_id: media_id }, as: :file
end

#media_create(type, file) ⇒ Object



31
32
33
# File 'lib/wechat/api_base.rb', line 31

def media_create(type, file)
  post_file 'media/upload', file, params: { type: type }
end

#media_hq(media_id) ⇒ Object



27
28
29
# File 'lib/wechat/api_base.rb', line 27

def media_hq(media_id)
  get 'media/get/jssdk', params: { media_id: media_id }, as: :file
end

#media_uploadimg(file) ⇒ Object



35
36
37
# File 'lib/wechat/api_base.rb', line 35

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

#media_uploadnews(mpnews_message) ⇒ Object



39
40
41
# File 'lib/wechat/api_base.rb', line 39

def media_uploadnews(mpnews_message)
  post 'media/uploadnews', mpnews_message.to_json
end

#qrcode(ticket) ⇒ Object



19
20
21
# File 'lib/wechat/api_base.rb', line 19

def qrcode(ticket)
  client.get 'showqrcode', params: { ticket: ticket }, base: MP_BASE, as: :file
end