Module: Jingubang::Weixin::Qiye::Account
- Includes:
- SendMessage
- Defined in:
- lib/jingubang/weixin/qiye/account.rb,
lib/jingubang/weixin/qiye/account/send_message.rb
Defined Under Namespace
Modules: SendMessage
Constant Summary collapse
- ROOT_DEPARTMENT_ID =
Required fields:
field :corpid, type: String field :access_token, type: String field :expired_at, type: Time field :permanent_code, type: String def refreshed_access_token
1
- BASE_URL =
'https://qyapi.weixin.qq.com'
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_all_user_list ⇒ Object
-
#fetch_department_list ⇒ Object
API methods:.
- #fetch_user(userid) ⇒ Object
- #fetch_user_list(department_id, fetch_child: false) ⇒ Object
Methods included from SendMessage
#send_news_message, #send_text_card_message, #send_text_message
Class Method Details
.included(host_class) ⇒ Object
19 20 21 22 |
# File 'lib/jingubang/weixin/qiye/account.rb', line 19 def self.included(host_class) host_class.include Jingubang::HttpClient host_class.base_url BASE_URL end |
Instance Method Details
#fetch_all_user_list ⇒ Object
39 40 41 |
# File 'lib/jingubang/weixin/qiye/account.rb', line 39 def fetch_all_user_list fetch_user_list ROOT_DEPARTMENT_ID, fetch_child: true end |
#fetch_department_list ⇒ Object
API methods:
26 27 28 29 30 |
# File 'lib/jingubang/weixin/qiye/account.rb', line 26 def fetch_department_list path = "/cgi-bin/department/list?access_token=#{refreshed_access_token}" response = fire_request path, {} response[:department] if response[:errcode]&.zero? end |
#fetch_user(userid) ⇒ Object
43 44 45 46 |
# File 'lib/jingubang/weixin/qiye/account.rb', line 43 def fetch_user userid path = "/cgi-bin/user/get?access_token=#{refreshed_access_token}&userid=#{userid}" response = fire_request path, {} end |
#fetch_user_list(department_id, fetch_child: false) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/jingubang/weixin/qiye/account.rb', line 32 def fetch_user_list department_id, fetch_child: false fetch_child_param = fetch_child ? 1 : 0 path = "/cgi-bin/user/list?access_token=#{refreshed_access_token}&department_id=#{department_id}&fetch_child=#{fetch_child_param}" response = fire_request path, {} response[:userlist] if response[:errcode]&.zero? end |