Class: ItchRewards::CLI::Commands::Rewards::Update
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- ItchRewards::CLI::Commands::Rewards::Update
- Includes:
- AuthOptions, Helper
- Defined in:
- lib/itch_rewards/cli.rb
Instance Method Summary collapse
Methods included from Helper
#authenticated_client, #authenticated_client!, #cli, #color, #objects_to_table, #render_table, #show_rewards
Methods included from AuthOptions
Instance Method Details
#call(game_id:, reward_id:, **options) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/itch_rewards/cli.rb', line 205 def call(game_id:, reward_id:, **) client = authenticated_client!() game = client.game(game_id) rewards = game.rewards reward_id = reward_id.to_i reward_list = rewards.list reward = reward_list.find {|reward| reward.id == reward_id } unless reward cli.error "Could not find reward with id: #{reward_id} for game #{game.name} (#{game.id})" exit 1 end unless [:archived].nil? reward.archived = [:archived] end i(amount description price title).each do |field| if [field] reward.public_send("#{field}=", [field]) end end rewards.save reward_list show_rewards(game) end |