Class: EmaySoap::Client
- Inherits:
-
Object
- Object
- EmaySoap::Client
- Includes:
- Configurable
- Defined in:
- lib/emay_soap/client.rb
Constant Summary collapse
- ENDPOINT =
'http://sdk4report.eucp.b2m.cn:8080/sdk/SDKService?wsdl'.freeze
Instance Attribute Summary
Attributes included from Configurable
#cdkey, #key, #password, #prefix
Instance Method Summary collapse
- #charge_up(cardno, cardpass) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(method, *args) ⇒ Object
Create all methods via method_missing,.
- #operation(action) ⇒ Object
- #operations ⇒ Object
- #regist_detail_info(options) ⇒ Object
-
#regist_ex ⇒ Object
register cdkey.
-
#send_sms(mobiles, content, options = {}) ⇒ Object
send SMS out.
- #serial_pwd_upd(new_password) ⇒ Object
Methods included from Configurable
default_options, #options, #setup, setup_keys
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/emay_soap/client.rb', line 10 def initialize( = {}) EmaySoap::Configurable.setup_keys.each do |k| instance_variable_set(:"@#{k}", [k] || EmaySoap::Configurable.[k]) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Create all methods via method_missing,
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/emay_soap/client.rb', line 63 def method_missing(method, *args) ary = args.each_with_index.inject([]) do |r, (e, i)| r << ["arg#{i+2}".to_sym, e] end = Hash[ary] if operations.include?(method) call(method, ) else super end end |
Instance Method Details
#charge_up(cardno, cardpass) ⇒ Object
38 39 40 |
# File 'lib/emay_soap/client.rb', line 38 def charge_up(cardno, cardpass) call(:charge_up, arg2: cardno, arg3: cardpass) end |
#operation(action) ⇒ Object
20 21 22 |
# File 'lib/emay_soap/client.rb', line 20 def operation(action) savon.operation(action) end |
#operations ⇒ Object
16 17 18 |
# File 'lib/emay_soap/client.rb', line 16 def operations savon.operations end |
#regist_detail_info(options) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/emay_soap/client.rb', line 29 def regist_detail_info() raise 'Detail info required' if .blank? msg = { arg1: [:e_name], arg2: [:link_man], arg4: [:phone_num], arg5: [:mobile], arg6: [:email], arg7: [:fax], arg8: [:address], arg9: [:postcode] } call(:regist_detail_info, msg) end |
#regist_ex ⇒ Object
register cdkey
25 26 27 |
# File 'lib/emay_soap/client.rb', line 25 def regist_ex call(:regist_ex, arg2: @password) end |
#send_sms(mobiles, content, options = {}) ⇒ Object
send SMS out
50 51 52 53 54 55 56 |
# File 'lib/emay_soap/client.rb', line 50 def send_sms(mobiles, content, = {}) send_at = format_sent_at([:send_at]) unless [:send_at].blank? mobiles = mobiles.is_a?(String) ? [mobiles] : mobiles content = "#{prefix} #{content}" unless prefix.nil? msg = { arg2: send_at, arg3: mobiles, arg4: content, arg5: [:kind], arg6: nil, arg7: [:priority], arg8: [:id] } call(:send_sms, msg) end |
#serial_pwd_upd(new_password) ⇒ Object
58 59 60 |
# File 'lib/emay_soap/client.rb', line 58 def serial_pwd_upd(new_password) call(:serial_pwd_upd, arg2: @password, arg3: new_password) end |