Module: MtopHelper

Included in:
SuperTest
Defined in:
lib/common/mtop_helper.rb

Defined Under Namespace

Classes: MtopV4

Instance Method Summary collapse

Instance Method Details

#mtop_get(opts = {}) ⇒ Object

功能:

发起mtop请求,请求方式为get

参数解释:

  • opts=> ‘api名称’, :api_version => ‘版本’, :api_data => ‘数据’, :env_type => ‘waptest’/‘wapa’/‘m’

Example:

Example #1:

opts = { :api_name => ‘mtop.trip.hotel.hotelSearch’,

:api_version => '1.0',
:api_data => '{"cityCode":"110100","checkIn":"2016-03-20","checkOut":"2016-03-21","radius":"-1","order":"0","dir":"0","pageNo":"1","pageSize":"20","offset":"-1","sellerId":"-1","isKeZhan":"0","priceMin":"0","priceMax":"-1","labels":"0","isSug":"0","isB2G":"0","isNeedSelectData":"0","filterByPayment":"0","isDisplayMultiRate":"0","useTemplate":"0","filterLaterPay":"0","isIncludePayLater":"1"}',
:env_type => 'waptest'

}

mtop_get opts



34
35
36
37
38
# File 'lib/common/mtop_helper.rb', line 34

def mtop_get(opts={})
    operator = MtopV4.new opts
    operator.to_get
    operator.request
end

#mtop_post(opts = {}) ⇒ Object

功能:

发起mtop请求,请求方式为post

参数解释:

  • opts=> ‘api名称’, :api_version => ‘版本’, :api_data => ‘数据’, :env_type => ‘waptest’/‘wapa’/‘m’

Example:

Example #1: opts = { :api_name => ‘mtop.trip.hotel.hotelSearch’,

:api_version => '1.0',
:api_data => '{"cityCode":"110100","checkIn":"2016-03-20","checkOut":"2016-03-21","radius":"-1","order":"0","dir":"0","pageNo":"1","pageSize":"20","offset":"-1","sellerId":"-1","isKeZhan":"0","priceMin":"0","priceMax":"-1","labels":"0","isSug":"0","isB2G":"0","isNeedSelectData":"0","filterByPayment":"0","isDisplayMultiRate":"0","useTemplate":"0","filterLaterPay":"0","isIncludePayLater":"1"}',
:env_type => 'waptest'

} mtop_post opts



56
57
58
59
60
# File 'lib/common/mtop_helper.rb', line 56

def mtop_post(opts={})
    operator = MtopV4.new opts
    operator.to_post
    operator.request
end