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