Class: Sinopac::FunBiz::OrderResult

Inherits:
Object
  • Object
show all
Defined in:
lib/sinopac/funbiz/order_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ OrderResult

Returns a new instance of OrderResult.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sinopac/funbiz/order_result.rb', line 6

def initialize(result)
  @shop_no = result[:ShopNo]
  @status = result[:Status]
  @description = result[:Description]
  @order_params = result[:OrderList].first

  @transaction_no = order_params[:TSNo]
  @order_no = order_params[:OrderNo]
  case order_params[:PayType]
  when 'A'
    @pay_type = :atm
  when 'C'
    @pay_type = :credit_card
  else
    @pay_type = :unknown
  end
  @amount = order_params[:Amount].to_i / 100
  @pay_status = order_params[:PayStatus]
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



4
5
6
# File 'lib/sinopac/funbiz/order_result.rb', line 4

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/sinopac/funbiz/order_result.rb', line 3

def description
  @description
end

#order_noObject (readonly)

Returns the value of attribute order_no.



4
5
6
# File 'lib/sinopac/funbiz/order_result.rb', line 4

def order_no
  @order_no
end

#order_paramsObject (readonly)

Returns the value of attribute order_params.



3
4
5
# File 'lib/sinopac/funbiz/order_result.rb', line 3

def order_params
  @order_params
end

#pay_statusObject (readonly)

Returns the value of attribute pay_status.



4
5
6
# File 'lib/sinopac/funbiz/order_result.rb', line 4

def pay_status
  @pay_status
end

#shop_noObject (readonly)

Returns the value of attribute shop_no.



3
4
5
# File 'lib/sinopac/funbiz/order_result.rb', line 3

def shop_no
  @shop_no
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/sinopac/funbiz/order_result.rb', line 3

def status
  @status
end

#transaction_noObject (readonly)

Returns the value of attribute transaction_no.



4
5
6
# File 'lib/sinopac/funbiz/order_result.rb', line 4

def transaction_no
  @transaction_no
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sinopac/funbiz/order_result.rb', line 26

def success?
  @status == 'S'
end