Module: Wechat::Api::Platform::Component

Included in:
Wechat::Api::Platform
Defined in:
app/apis/wechat/api/platform/component.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#authorizer_token(appid, refresh_token) ⇒ Object



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

def authorizer_token(appid, refresh_token)
  body = {
    component_appid: app.appid,
    authorizer_appid: appid,
    authorizer_refresh_token: refresh_token
  }

  post 'api_authorizer_token', **body, base: BASE
end

#component_tokenObject



43
44
45
46
47
48
49
50
51
# File 'app/apis/wechat/api/platform/component.rb', line 43

def component_token
  body = {
    component_appid: app.appid,
    component_appsecret: app.secret,
    component_verify_ticket: app.verify_ticket
  }

  client.post 'api_component_token', body.to_json, base: BASE  # use client without access token
end

#create_preauthcodeObject



5
6
7
8
9
10
11
# File 'app/apis/wechat/api/platform/component.rb', line 5

def create_preauthcode
  body = {
    component_appid: app.appid
  }

  post 'api_create_preauthcode', **body, base: BASE
end

#get_authorizer_info(appid) ⇒ Object



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

def get_authorizer_info(appid)
  body = {
    component_appid: app.appid,
    authorizer_appid: appid
  }

  r = post 'api_get_authorizer_info', **body, base: BASE
  r['authorizer_info']
end

#query_auth(auth_code) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'app/apis/wechat/api/platform/component.rb', line 13

def query_auth(auth_code)
  body = {
    component_appid: app.appid,
    authorization_code: auth_code
  }

  r = post 'api_query_auth', **body, base: BASE
  r['authorization_info']
end