Class: StockShaker::Request::JDCentralOP

Inherits:
Object
  • Object
show all
Defined in:
lib/stock_shaker/request/jd_central_op.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method = :post) ⇒ JDCentralOP

Returns a new instance of JDCentralOP.



8
9
10
11
12
13
14
15
# File 'lib/stock_shaker/request/jd_central_op.rb', line 8

def initialize(http_method = :post)
  @http_method = http_method
  @api_params = {}
  @business_params = {}
  @header_params = {}

  validate!
end

Instance Attribute Details

#api_paramsObject (readonly)

Returns the value of attribute api_params.



6
7
8
# File 'lib/stock_shaker/request/jd_central_op.rb', line 6

def api_params
  @api_params
end

#business_paramsObject (readonly)

Returns the value of attribute business_params.



6
7
8
# File 'lib/stock_shaker/request/jd_central_op.rb', line 6

def business_params
  @business_params
end

#header_paramsObject (readonly)

Returns the value of attribute header_params.



6
7
8
# File 'lib/stock_shaker/request/jd_central_op.rb', line 6

def header_params
  @header_params
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



6
7
8
# File 'lib/stock_shaker/request/jd_central_op.rb', line 6

def http_method
  @http_method
end

Instance Method Details

#add_api_params(hash) ⇒ Object



17
18
19
20
# File 'lib/stock_shaker/request/jd_central_op.rb', line 17

def add_api_params(hash)
  raise 'api_params is not hash' unless hash.is_a? Hash
  @api_params = hash
end

#add_business_params(hash) ⇒ Object



22
23
24
25
26
27
# File 'lib/stock_shaker/request/jd_central_op.rb', line 22

def add_business_params(hash)
  raise 'business_params is not hash' unless hash.is_a? Hash
  @business_params = {
    param_json: hash.to_json
  }
end

#add_header_params(key, value) ⇒ Object



29
30
31
32
33
# File 'lib/stock_shaker/request/jd_central_op.rb', line 29

def add_header_params(key, value)
  raise 'header param key is not String' unless key.is_a? String
  raise 'header param value is not String' unless value.is_a? String
  @header_params[key] = value
end

#validate!Object



35
36
37
# File 'lib/stock_shaker/request/jd_central_op.rb', line 35

def validate!
  raise 'http_method accepted only :post' unless @http_method.eql?(:post)
end