Module: MotionWechat::API
- Defined in:
- lib/motion-wechat/api.rb
Constant Summary collapse
- InvalidMediaObject =
Class.new StandardError
Class Method Summary collapse
-
.instance ⇒ Object
Returns singleton instance of MotionWechat.
Instance Method Summary collapse
- #initialize(key, secret, options = {}) ⇒ Object
-
#register ⇒ Object
Register WechatAPI.
-
#send_text(text) ⇒ Object
Send text to wechat.
Class Method Details
.instance ⇒ Object
21 22 23 24 |
# File 'lib/motion-wechat/api.rb', line 21 def self.instance @config ||= NSBundle.mainBundle.objectForInfoDictionaryKey MotionWechat::Config.info_plist_key @instance = new @config["key"], @config["secret"] end |
Instance Method Details
#initialize(key, secret, options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/motion-wechat/api.rb', line 6 def initialize(key, secret, ={}) @key = key @secret = secret end |
#register ⇒ Object
Register WechatAPI
12 13 14 |
# File 'lib/motion-wechat/api.rb', line 12 def register WXApi.registerApp(@key) end |
#send_text(text) ⇒ Object
Send text to wechat
Example:
MotionWechat::API.instance.send_text "hello, motion"
Arguments:
text: (String)
62 63 64 65 66 67 |
# File 'lib/motion-wechat/api.rb', line 62 def send_text(text) req = SendMessageToWXReq.alloc.init req.bText = false req.text = text WXApi.sendReq(req) end |