Module: Airbnb::Service::Hongbao::Api::HongbaoGetUserChinaCouponsResponseSmartclientModule::GenerateInstanceMethods

Defined in:
lib/airbnb/service/hongbao/api/hongbao_data_smartclient_modules.rb

Constant Summary collapse

JSON_NAME_OVERRIDES =
{
}.freeze

Instance Method Summary collapse

Instance Method Details

#coupon_codesObject



1875
# File 'lib/airbnb/service/hongbao/api/hongbao_data_smartclient_modules.rb', line 1875

def coupon_codes; @couponCodes; end

#to_hash(options = nil) ⇒ Object Also known as: to_h

options:

case_from_idl: use the exact case from IDL file to when generating the hash key. Default is false.
ignore_nil_field: do not generate key in the hash, if the value is nil. Useful for inspect or data transport. Default is false.


1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
# File 'lib/airbnb/service/hongbao/api/hongbao_data_smartclient_modules.rb', line 1884

def to_hash(options = nil)
  res = {}
  options ||= {}
  case_from_idl = options.nil? ? false : options[:case_from_idl]
  ignore_nil_field = options.nil? ? false : options[:ignore_nil_field]
  if case_from_idl
    if !(ignore_nil_field && coupon_codes.nil?)
      _json_key_name = JSON_NAME_OVERRIDES.key?(:couponCodes) ? JSON_NAME_OVERRIDES[:couponCodes] : :couponCodes
      res[_json_key_name] = if !coupon_codes.nil?
        raise "coupon_codes should be an Array, while it is #{coupon_codes.class}" unless coupon_codes.is_a?(Array)
        coupon_codes.map do |coupon_codes_item|
          coupon_codes_item
        end
      end
    end
  else # enforcing to use snake case
    if !(ignore_nil_field && coupon_codes.nil?)
      _json_key_name = JSON_NAME_OVERRIDES.key?(:couponCodes) ?  JSON_NAME_OVERRIDES[:couponCodes] : :coupon_codes
      res[_json_key_name] = if !coupon_codes.nil?
        raise "coupon_codes should be an Array, while it is #{coupon_codes.class}" unless coupon_codes.is_a?(Array)
        coupon_codes.map do |coupon_codes_item|
          coupon_codes_item
        end
      end
    end
  end
  res
end

#to_json(options = nil) ⇒ Object



1877
1878
1879
# File 'lib/airbnb/service/hongbao/api/hongbao_data_smartclient_modules.rb', line 1877

def to_json(options = nil)
  JSON.generate(to_hash(options))
end