Method: ShopifyCLI::Tasks::UpdateDashboardURLS#call

Defined in:
lib/shopify_cli/tasks/update_dashboard_urls.rb

#call(ctx, url:, callback_urls:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/shopify_cli/tasks/update_dashboard_urls.rb', line 8

def call(ctx, url:, callback_urls:)
  @ctx = ctx
  project = ShopifyCLI::Project.current
  api_key = project.env.api_key
  result = ShopifyCLI::PartnersAPI.query(ctx, "get_app_urls", apiKey: api_key)
  app = result["data"]["app"]

  constructed_urls = construct_redirect_urls(app["redirectUrlWhitelist"], url, callback_urls)

  return if already_updated(app, constructed_urls, url)

  ShopifyCLI::PartnersAPI.query(@ctx, "update_dashboard_urls", input: {
    applicationUrl: url,
    redirectUrlWhitelist: constructed_urls,
    apiKey: api_key,
  })

  @ctx.puts(@ctx.message("core.tasks.update_dashboard_urls.updated"))
rescue
  @ctx.puts(@ctx.message("core.tasks.update_dashboard_urls.update_error", ShopifyCLI::TOOL_NAME))
  raise
end