class App42::AppTab::DiscountResponseBuilder
Public Instance Methods
buildArrayObject(json)
click to toggle source
@param discountJSONObj @return @throws Exception
# File lib/appTab/DiscountResponseBuilder.rb, line 41 def buildArrayObject(json) discountJSONObj = getServiceJSONObject("discounts", json); discountList = Array.new if discountJSONObj.fetch("discount").instance_of?(Array) discountsJSONArray = discountJSONObj.fetch("discount"); discountsJSONArray.length.times do |i| discountJSONObj1 = discountsJSONArray.fetch(i); discountObj = App42::AppTab::Test.new() discountObj = buildDiscountObject(discountJSONObj1); discountObj.strResponse = json discountObj.isResponseSuccess = isResponseSuccess(json) discountList.push(discountObj); end else jsonObjConfig = discountJSONObj.fetch("discount"); discountObj = App42::AppTab::Test.new() discountObj = buildDiscountObject(jsonObjConfig); discountObj.strResponse = json discountObj.isResponseSuccess = isResponseSuccess(json) discountList.push(discountObj); end return discountList; end
buildDiscountObject(discountJSONObj)
click to toggle source
# File lib/appTab/DiscountResponseBuilder.rb, line 19 def buildDiscountObject(discountJSONObj) discount1 = App42::AppTab::Test.new() buildObjectFromJSONTree(discount1, discountJSONObj); if discountJSONObj.key?("discountDetails") if discountJSONObj.fetch("discountDetails").instance_of?(Hash) profileJSONObj = discountJSONObj.fetch("discountDetails"); discounDetails = App42::AppTab::Discount.new(discount1) buildObjectFromJSONTree(discounDetails, profileJSONObj); end end return discount1; end
buildResponse(json)
click to toggle source
# File lib/appTab/DiscountResponseBuilder.rb, line 9 def buildResponse(json) discountsJSONObj = getServiceJSONObject("discounts", json); discountJSONObj = discountsJSONObj.fetch("discount"); discountData = App42::AppTab::Test.new() discountData = buildDiscountObject(discountJSONObj); discountData.strResponse = json discountData.isResponseSuccess = isResponseSuccess(json) return discountData; end