src/ShopifyApp/Jobs/ScripttagInstaller.php
public function handle()
    {
        // Keep track of whats created
        $created = [];

        // Get the current scripttags installed on the shop
        $api = $this->shop->api();
        $shopScripttags = $api->rest(
            'GET',
            '/admin/script_tags.json',
            [
                'limit'  => 250,
                'fields' => 'id,src',
            ]
        )->body->script_tags;

        foreach ($this->scripttags as $scripttag) {
            // Check if the required scripttag exists on the shop
            if (!$this->scripttagExists($shopScripttags, $scripttag)) {
                // It does not... create the scripttag
                $api->rest('POST', '/admin/script_tags.json', ['script_tag' => $scripttag]);
                $created[] = $scripttag;
            }
        }

        return $created;
    }
public function handle()
    {
        // Keep track of whats created
        $created = [];

        // Get the current scripttags installed on the shop
        $api = $this->shop->api();
        $shopScripttags = $api->rest(
            'GET',
            '/admin/script_tags.json',
            [
                'limit'  => 250,
                'fields' => 'id,src',
            ]
        )->body->script_tags;

        foreach ($this->scripttags as $scripttag) {
            // Check if the required scripttag exists on the shop
            if (!$this->scripttagExists($shopScripttags, $scripttag)) {
                // It does not... create the scripttag
                $api->rest('POST', '/admin/script_tags.json', ['script_tag' => $scripttag]);
                $created[] = $scripttag;
            }
        }

        return $created;
    }
public function handle ( ) { // Keep track of whats created $ created = [ ] ; // Get the current scripttags installed on the shop $ api = $ this -> shop -> api ( ) ; $ shopScripttags = $ api -> rest ( 'GET' , '/admin/script_tags.json' , [ 'limit' => 250 , 'fields' => 'id,src' , ] ) -> body -> script_tags ; foreach ( $ this -> scripttags as $ scripttag ) { // Check if the required scripttag exists on the shop if ( ! $ this -> scripttagExists ( $ shopScripttags , $ scripttag ) ) { // It does not... create the scripttag $ api -> rest ( 'POST' , '/admin/script_tags.json' , [ 'script_tag' => $ scripttag ] ) ; $ created [ ] = $ scripttag ; } } return $ created ; }
Execute the job.

@return array
Execute the job .