Class: DhanHQ::Resources::KillSwitch
- Defined in:
- lib/DhanHQ/resources/kill_switch.rb
Overview
Resource client to control the trading kill switch feature. API expects killSwitchStatus as query parameter (no body). See dhanhq.co/docs/v2/traders-control/
Constant Summary collapse
- API_TYPE =
:order_api- HTTP_PATH =
"/v2/killswitch"- KILL_SWITCH_STATUSES =
%w[ACTIVATE DEACTIVATE].freeze
Instance Attribute Summary
Attributes inherited from BaseAPI
Instance Method Summary collapse
-
#status ⇒ Hash
Fetches the current kill switch status.
-
#update(status) ⇒ Hash
Enables or disables the kill switch via query parameter (doc: no body).
Methods inherited from BaseAPI
#delete, #get, #initialize, #post, #put
Methods included from AttributeHelper
#camelize_keys, #deep_camelize_keys, #inspect, #normalize_keys, #snake_case, #titleize_keys
Methods included from APIHelper
Constructor Details
This class inherits a constructor from DhanHQ::BaseAPI
Instance Method Details
#status ⇒ Hash
Fetches the current kill switch status.
32 33 34 |
# File 'lib/DhanHQ/resources/kill_switch.rb', line 32 def status get("") end |
#update(status) ⇒ Hash
Enables or disables the kill switch via query parameter (doc: no body).
20 21 22 23 24 25 26 |
# File 'lib/DhanHQ/resources/kill_switch.rb', line 20 def update(status) normalized = status.to_s.upcase.strip raise DhanHQ::ValidationError, "killSwitchStatus must be one of: #{KILL_SWITCH_STATUSES.join(", ")}" unless KILL_SWITCH_STATUSES.include?(normalized) query = "?killSwitchStatus=#{CGI.escape(normalized)}" handle_response(client.post(build_path(query), {})) end |