Class: Top4R::Trade

Inherits:
Object
  • Object
show all
Includes:
ModelMixin
Defined in:
lib/top4r/model/trade.rb

Overview

Trade model

Constant Summary collapse

@@ATTRIBUTES =
[:id, :seller_nick, :buyer_nick, :title, :type, :created, :iid, :price, 
:pic_path, :num, :tid, :buyer_message, :shipping_type, :alipay_no, :payment, :sid, 
:discount_fee, :adjust_fee, :snapshot_url, :snapshot, :status, :seller_rate, :buyer_rate, 
:buyer_memo, :seller_memo, :trade_memo, :pay_time, :end_time, :modified, :buyer_obtain_point_fee, 
:point_fee, :real_point_fee, :total_fee, :post_fee, :buyer_alipay_no, :receiver_name,
:receiver_state, :receiver_city, :receiver_district, :receiver_address, :receiver_zip, 
:receiver_mobile, :receiver_phone, :consign_time, :buyer_email, :commission_fee, 
:seller_alipay_no, :seller_mobile, :seller_phone, :seller_name, :seller_email, 
:available_confirm_fee, :has_post_fee, :received_payment, :cod_fee, :timeout_action_time, 
:is_3D, :buyer_flag, :seller_flag, :num_iid, :promotion, :promotion_details, :invoice_name, :orders]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModelMixin

included

Class Method Details

.attributesObject



75
# File 'lib/top4r/model/trade.rb', line 75

def attributes; @@ATTRIBUTES; end

.default_public_fieldsObject



77
78
79
80
81
# File 'lib/top4r/model/trade.rb', line 77

def default_public_fields
  ["buyer_nick", "seller_nick", "tid", "modified", "title", "type", "status", "created", "price", 
    "sid", "pic_path", "iid", "payment", "alipay_no", "shipping_type", "pay_time", "end_time", 
    "orders"] + Top4R::Order.default_public_fields
end

Instance Method Details

#add_memo(memo) ⇒ Object



88
89
90
91
# File 'lib/top4r/model/trade.rb', line 88

def add_memo(memo)
  valid_memo(memo)
  @client.trade(@tid, :add_memo, {:memo => memo})
end

#close(reason = "现关闭本交易!") ⇒ Object



84
85
86
# File 'lib/top4r/model/trade.rb', line 84

def close(reason = "现关闭本交易!")
  @client.trade(@tid, :close, {:close_reason => reason})
end

#confirm_feesObject



98
99
100
# File 'lib/top4r/model/trade.rb', line 98

def confirm_fees
  @client.trade(@tid, :confirmfee, {:is_detail => "IS_FATHER"})
end

#deliver(options = {}) {|delivery| ... } ⇒ Object

Yields:

  • (delivery)


102
103
104
105
106
107
# File 'lib/top4r/model/trade.rb', line 102

def deliver(options = {}, &block)
  delivery = Delivery.new(options)
  yield delivery if block_given?
  delivery.tid = @tid
  @client.deliver_trade(delivery)
end

#unmarshal_other_attrsObject



109
110
111
112
113
114
115
# File 'lib/top4r/model/trade.rb', line 109

def unmarshal_other_attrs
  @id = @tid
  if @orders.is_a?(Hash)
    @orders = @orders["order"].map{|order| Order.new(order)}
  end
  self
end

#update_memo(memo) ⇒ Object



93
94
95
96
# File 'lib/top4r/model/trade.rb', line 93

def update_memo(memo)
  valid_memo(memo)
  @client.trade(@tid, :update_memo, {:memo => memo})
end