<?php

namespace App\Console\Commands;

use App\Services\Shopify\CustomersService;
use Illuminate\Console\Command;

class GetShopifyCompanyContactGids extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'noldus:get-shopify-company-contact-gids {location_id}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Gets company contacts gids from Shopify';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle(CustomersService $service)
    {
        $locationId = $this->argument('location_id');
        if (!$locationId) {
            $this->error('You have to specify the company location shipify id (just numbers)');
            return 0;
        }

        $data = $service->getCompanyLocationContactGidsExtra("gid://shopify/CompanyLocation/$locationId");

        echo json_encode($data);
        return 0;
    }
}
