Class: IGMarkets::CLI::Orders
- Inherits:
-
Thor
- Object
- Thor
- IGMarkets::CLI::Orders
- Defined in:
- lib/ig_markets/cli/commands/orders_command.rb
Overview
Implements the ‘ig_markets orders` command.
Instance Method Summary collapse
- #create ⇒ Object
- #delete(deal_id) ⇒ Object
- #delete_all ⇒ Object
- #list ⇒ Object
- #update(deal_id) ⇒ Object
Instance Method Details
#create ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/ig_markets/cli/commands/orders_command.rb', line 37 def create Main.begin_session() do |dealing_platform| deal_reference = dealing_platform.working_orders.create working_order_attributes Main.report_deal_confirmation deal_reference end end |
#delete(deal_id) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ig_markets/cli/commands/orders_command.rb', line 69 def delete(deal_id) Main.begin_session() do |dealing_platform| working_order = dealing_platform.working_orders[deal_id] raise 'No working order with the specified deal ID' unless working_order deal_reference = working_order.delete Main.report_deal_confirmation deal_reference end end |
#delete_all ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/ig_markets/cli/commands/orders_command.rb', line 83 def delete_all Main.begin_session() do |dealing_platform| dealing_platform.working_orders.all.each do |working_order| deal_reference = working_order.delete Main.report_deal_confirmation deal_reference end end end |
#list ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ig_markets/cli/commands/orders_command.rb', line 7 def list Main.begin_session() do |dealing_platform| working_orders = dealing_platform.working_orders.all table = Tables::WorkingOrdersTable.new working_orders puts table end end |
#update(deal_id) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ig_markets/cli/commands/orders_command.rb', line 55 def update(deal_id) Main.begin_session() do |dealing_platform| working_order = dealing_platform.working_orders[deal_id] raise 'No working order with the specified deal ID' unless working_order deal_reference = working_order.update working_order_attributes Main.report_deal_confirmation deal_reference end end |