Class: Wechat::ApiBase

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

Direct Known Subclasses

Api, CorpApi

Constant Summary collapse

MP_BASE =
'https://mp.weixin.qq.com/cgi-bin/'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



3
4
5
# File 'lib/wechat/api_base.rb', line 3

def access_token
  @access_token
end

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/wechat/api_base.rb', line 3

def client
  @client
end

#jsapi_ticketObject (readonly)

Returns the value of attribute jsapi_ticket.



3
4
5
# File 'lib/wechat/api_base.rb', line 3

def jsapi_ticket
  @jsapi_ticket
end

Instance Method Details

#callbackipObject



7
8
9
# File 'lib/wechat/api_base.rb', line 7

def callbackip
  get 'getcallbackip'
end

#media(media_id) ⇒ Object



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

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

#media_create(type, file) ⇒ Object



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

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

#media_uploadimg(file) ⇒ Object



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

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

#qrcode(ticket) ⇒ Object



11
12
13
# File 'lib/wechat/api_base.rb', line 11

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