Class: StockShaker::Request::ShopeeOP
- Inherits:
-
Object
- Object
- StockShaker::Request::ShopeeOP
- Defined in:
- lib/stock_shaker/request/shopee_op.rb
Instance Attribute Summary collapse
-
#api_name ⇒ Object
readonly
Returns the value of attribute api_name.
-
#api_params ⇒ Object
readonly
Returns the value of attribute api_params.
-
#header_params ⇒ Object
readonly
Returns the value of attribute header_params.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
Instance Method Summary collapse
- #add_api_params(hash) ⇒ Object
- #add_header_params(key, value) ⇒ Object
-
#initialize(api_name = nil, http_method = :post) ⇒ ShopeeOP
constructor
A new instance of ShopeeOP.
- #validate! ⇒ Object
Constructor Details
#initialize(api_name = nil, http_method = :post) ⇒ ShopeeOP
Returns a new instance of ShopeeOP.
8 9 10 11 12 13 14 15 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 8 def initialize(api_name = nil, http_method = :post) @api_name = api_name @http_method = http_method @api_params = {} @header_params = {} validate! end |
Instance Attribute Details
#api_name ⇒ Object (readonly)
Returns the value of attribute api_name.
6 7 8 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 6 def api_name @api_name end |
#api_params ⇒ Object (readonly)
Returns the value of attribute api_params.
6 7 8 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 6 def api_params @api_params end |
#header_params ⇒ Object (readonly)
Returns the value of attribute header_params.
6 7 8 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 6 def header_params @header_params end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
6 7 8 |
# File 'lib/stock_shaker/request/shopee_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/shopee_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_header_params(key, value) ⇒ Object
22 23 24 25 26 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 22 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
28 29 30 31 |
# File 'lib/stock_shaker/request/shopee_op.rb', line 28 def validate! raise 'api_name is required' if @api_name.blank? raise 'http_method accepted only :get or :post' unless %i[get post].include?(@http_method) end |