Sha256: 40536615166026bd7346c18cab569989f185f1df3369c16057bd5f181bd7e850
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'shopify_cli' module ShopifyCli module Tasks class CreateApiClient < ShopifyCli::Task VALID_APP_TYPES = %w(public custom) DEFAULT_APP_URL = 'https://shopify.github.io/shopify-app-cli/help/start-app/' def call(ctx, org_id:, title:, type:) resp = ShopifyCli::PartnersAPI.query( ctx, 'create_app', org: org_id.to_i, title: title, type: type, app_url: DEFAULT_APP_URL, redir: [OAuth::REDIRECT_HOST] ) unless resp ctx.abort("Error - empty response") end errors = resp.dig("errors") if !errors.nil? && errors.any? ctx.abort(errors.map { |err| "#{err['field']} #{err['message']}" }.join(", ")) end user_errors = resp.dig("data", "appCreate", "userErrors") if !user_errors.nil? && user_errors.any? ctx.abort(user_errors.map { |err| "#{err['field']} #{err['message']}" }.join(", ")) end ShopifyCli::Core::Monorail.metadata[:api_key] = resp.dig("data", "appCreate", "app", "apiKey") resp.dig("data", "appCreate", "app") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shopify-cli-1.6.0 | lib/shopify-cli/tasks/create_api_client.rb |
shopify-cli-1.5.0 | lib/shopify-cli/tasks/create_api_client.rb |