Class: Bump::CLI::Commands::Preview

Inherits:
Base
  • Object
show all
Defined in:
lib/bump/cli/commands/preview.rb

Constant Summary

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Instance Method Details

#call(file:, **options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bump/cli/commands/preview.rb', line 12

def call(file:, **options)
  with_errors_rescued do
    response = post(
      url: API_URL + "/previews",
      body: body(file, **options).to_json
    )

    if response.code == 201
      body = JSON.parse(response.body)
      puts "Preview created : #{ROOT_URL + "/preview/" + body["id"]} (expires at #{body["expires_at"]})"
    else
      display_error(response)
    end
  end
end