4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/shopify-cli/tasks/ensure_loopback_url.rb', line 4
def call(ctx)
@ctx = ctx
api_key = Project.current.env.api_key
result = ShopifyCli::PartnersAPI.query(ctx, 'get_app_urls', apiKey: api_key)
loopback = OAuth::REDIRECT_HOST
app = result['data']['app']
urls = app['redirectUrlWhitelist']
if urls.grep(/#{loopback}/).empty?
with_loopback = urls.push(loopback)
ShopifyCli::PartnersAPI.query(@ctx, 'update_dashboard_urls', input: {
redirectUrlWhitelist: with_loopback, apiKey: api_key
})
end
end
|