Class: Cmbchina::SessionObject
- Inherits:
-
Object
- Object
- Cmbchina::SessionObject
- Includes:
- HTTParty
- Defined in:
- lib/cmbchina.rb
Instance Attribute Summary collapse
-
#client_no ⇒ Object
会话号码.
-
#serial_no ⇒ Object
序列号.
Instance Method Summary collapse
- #get_order(bill_no, bill_date) ⇒ Object
-
#initialize(message = nil) ⇒ SessionObject
constructor
A new instance of SessionObject.
- #login(pwd = nil) ⇒ Object
- #logout ⇒ Object
- #query_refund_orders(options) ⇒ Object
- #query_settled_orders(options) ⇒ Object
- #refund(options) ⇒ Object
Constructor Details
#initialize(message = nil) ⇒ SessionObject
Returns a new instance of SessionObject.
117 118 119 120 121 122 123 124 |
# File 'lib/cmbchina.rb', line 117 def initialize( = nil) if .present? and [0]=='Y' @client_no = [1] @serial_no = [2] else raise "could not connect the cmbchina api url" end end |
Instance Attribute Details
#client_no ⇒ Object
会话号码
114 115 116 |
# File 'lib/cmbchina.rb', line 114 def client_no @client_no end |
#serial_no ⇒ Object
序列号
115 116 117 |
# File 'lib/cmbchina.rb', line 115 def serial_no @serial_no end |
Instance Method Details
#get_order(bill_no, bill_date) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/cmbchina.rb', line 153 def get_order( bill_no, bill_date ) = { version: 1, co_no: Cmbchina.co_no, date: bill_date, bill_no: bill_no } = post_command('DirectQuerySingleOrder', ) if .shift == 'Y' and .size > 2 .push bill_no Cmbchina::Order.new( ) end end |
#login(pwd = nil) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/cmbchina.rb', line 126 def login(pwd = nil) pwd = Cmbchina.password unless pwd = post_command('DirectLogonC', { pwd: pwd }) if .present? and [0]=='Y' @client_no = [1] if [1] @serial_no = [2] if [2] else raise "login fails" end end |
#logout ⇒ Object
139 140 141 |
# File 'lib/cmbchina.rb', line 139 def logout post_command('DirectExit') end |
#query_refund_orders(options) ⇒ Object
148 149 150 151 |
# File 'lib/cmbchina.rb', line 148 def query_refund_orders() = post_command('DirectQueryRefundByDate', ()) explan_order_list( ) end |
#query_settled_orders(options) ⇒ Object
143 144 145 146 |
# File 'lib/cmbchina.rb', line 143 def query_settled_orders() = post_command('DirectQuerySettledOrderByPage', ()) explan_order_list( ) end |
#refund(options) ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/cmbchina.rb', line 167 def refund( ) = { date: [:date], bill_no: [:bill_no], amount: [:amount], desc: [:desc], vcode: get_vcode() } post_command('DirectRefund', ) end |