lib/centaman/service/coupon_check.rb in centaman-0.1.11 vs lib/centaman/service/coupon_check.rb in centaman-0.1.12
- old
+ new
@@ -1,12 +1,13 @@
module Centaman
class Service::CouponCheck < Centaman::Service
include Centaman::JsonWrapper
- attr_reader :coupon_code
+ attr_reader :coupon_code, :product_area
def after_init(args)
@coupon_code = args[:coupon_code]
+ @product_area = args[:product_area]
require_args
end
def endpoint
'/coupon_services/check'
@@ -17,14 +18,18 @@
end
def options_hash
{
'CouponCode' => coupon_code,
- 'ProductArea' => 'TimedTickets'
+ 'ProductArea' => product_area
}.to_json
end
+ def required_fields
+ [coupon_code, product_area]
+ end
+
def require_args
- raise "coupon_code is required for #{self.class.name}" if coupon_code.nil?
+ raise "coupon_code and product_area required for #{self.class.name}" if required_fields.include?(nil)
end
end
end