Class: Centaman::Service::CouponCheck

Inherits:
Centaman::Service show all
Includes:
JsonWrapper
Defined in:
lib/centaman/service/coupon_check.rb

Constant Summary

Constants inherited from Wrapper

Wrapper::DEFAULT_TIMEOUT_TIME

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user

Instance Method Summary collapse

Methods included from JsonWrapper

#additional_hash_to_serialize_after_response, #build_object, #build_objects, #final_object_class, #objects

Methods inherited from Centaman::Service

#after_post, #fetch_all, #post, #put

Methods inherited from Wrapper

#generate_token, #headers, #initialize, #options, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout

Constructor Details

This class inherits a constructor from Centaman::Wrapper

Instance Attribute Details

#coupon_codeObject (readonly)

Returns the value of attribute coupon_code.



4
5
6
# File 'lib/centaman/service/coupon_check.rb', line 4

def coupon_code
  @coupon_code
end

#product_areaObject (readonly)

Returns the value of attribute product_area.



4
5
6
# File 'lib/centaman/service/coupon_check.rb', line 4

def product_area
  @product_area
end

Instance Method Details

#after_init(args) ⇒ Object



6
7
8
9
10
# File 'lib/centaman/service/coupon_check.rb', line 6

def after_init(args)
  @coupon_code = args[:coupon_code]
  @product_area = args[:product_area]
  require_args
end

#endpointObject



12
13
14
# File 'lib/centaman/service/coupon_check.rb', line 12

def endpoint
  '/coupon_services/check'
end

#object_classObject



16
17
18
# File 'lib/centaman/service/coupon_check.rb', line 16

def object_class
  Centaman::Object::CouponCheck
end

#options_hashObject



20
21
22
23
24
25
# File 'lib/centaman/service/coupon_check.rb', line 20

def options_hash
  {
    'CouponCode' => coupon_code,
    'ProductArea' => product_area
  }.to_json
end

#require_argsObject



31
32
33
# File 'lib/centaman/service/coupon_check.rb', line 31

def require_args
  raise "coupon_code and product_area required for #{self.class.name}" if required_fields.include?(nil)
end

#required_fieldsObject



27
28
29
# File 'lib/centaman/service/coupon_check.rb', line 27

def required_fields
  [coupon_code, product_area]
end