Asset

Assets are files which create Your theme. It can be any file from stylesheet, javascript, image or extra snippet code. You can add them, modify or delete.


Asset properties

key { "key" : "snippets/product_options.tpl" }
It's a path to the asset in a store. In this example asset product_options.tpl is in snippets folder.
public_url { "public_url" : "https://static.shoplo.com/0003/s/1/assets/ico_cart.png" }
This is a public URL of this asset. Templates, snippets and layout don't have a public_url.
content_type { "content_type" : "image/png" }
MIME representation of the content.
size { "size" : "8943" }
The asset size in bytes.
content { "content" : "{snippet file="instock_reminder_app"}" }
Asset which is added.

Receive a list of all Assets

GET /services/themes/{id}/assets

Returns all assets of the requested theme. It returns only metadata about those resources. If You need the content of the asset, you need to request it individually.

HTTP/1.1 200 OK
{
    "assets" => [
        {
            "key" : "layout/base.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 13085
        },
        {
            "key" : "templates/home.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 2416
        },
        {
            "key" : "templates/category.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 4485
        },
        {
            "key" : "templates/product.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 13510
        },
        {
            "key" : "templates/page.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 264
        },
        {
            "key" : "templates/collection.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 1528
        },
        {
            "key" : "templates/404.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 216
        },
        {
            "key" : "templates/cart.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 1805
        },
        {
            "key" : "snippets/product_option.tpl",
            "public_url" : null,
            "content_type" : "text/html",
            "size" : 9663
        },
        {
            "key" : "assets/base.js",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/base.js",
            "content_type" : "text/javascript",
            "size" : 2292
        },
        {
            "key" : "assets/base.js",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/base.js",
            "content_type" : "application/javascript",
            "size" : 2292
        },
        {
            "key" : "assets/cart.js",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/cart.js",
            "content_type" : "application/javascript",
            "size" : 2292
        },
        {
            "key" : "assets/fonts.css",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/fonts.css",
            "content_type" : "text/css",
            "size" : 855
        },
        {
            "key" : "assets/fonts.css",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/fonts.css",
            "content_type" : "text/css",
            "size" : 855
        },
        {
            "key" : "assets/ad_next.png",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/ad_next.png",
            "content_type" : "image/png",
            "size" : 355
        },
        {
            "key" : "assets/ad_prev.png",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/ad_prev.png",
            "content_type" : "image/png",
            "size" : 364
        },
        {
            "key" : "assets/bg.png",
            "public_url" : "https://static.shoplo.com/8515/s/24/assets/bg.png",
            "content_type" : "image/png",
            "size" : 364
        },
    ]
}

Receive a single asset

GET /services/themes/{id}/assets?asset[key]=templates/product.tpl

If You want to receive a single asset You need to send a key which consists of two part separated by forward slash. First part is a folder where the asset is (it can be one of those: layout, templates, assets, snippets) and the second part is the filename of the asset. Examples: layout/base.tpl or assets/bg.png

Response
HTTP/1.1 200 OK
{
    "asset": {
        "key" : "snippets/cart_widget.tpl",
        "public_url" : null,
        "content_type" : "text/html",
        "size" : 1351,
        "content" : "<div id="cartWidget" class="push-right">
                         <a href="{reverse_url name='shop_cart'}">
                            {$settings->translate_your_cart}:
                          <span class="cartPrice" data-price="{$cart->total_price|money_
                          without_currency}">{$cart->total_price|money_without_currency}
                          </span> {$shop->currency}
                         </a>
                        </div>",
        }
}

Create an asset

POST services/themes/{id}/assets

Create new asset or update an existing ones.

Request
{
    "asset": {
        "key" : "templates/404.tpl",
        "content" : "<div class="container page-content">
                <div class="row">
                    <span id="info404">404</span>
                    <p>Page which You are looking for not exist.</p>
                    <a href="/" class="btn btn-black">Go to Home Page</a>
                </div>
            </div>"
    }
}
Response
HTTP/1.1 200 OK
{
    "asset": {
        "key" : "templates/404.tpl",
        "public_url": null,
        "content_type" : "text/html",
        "size" : 894,
        "content" : "<div class="container page-content">
            <div class="row">
                <span id="info404">404</span>
                <p>Page which You are looking for not exist.</p>
                <a href="/" class="btn btn-black">Go to Home Page</a>
            </div>
        </div>"
    }
}

Delete an asset

DELETE services/themes/{id}/assets?asset[key]=assets/bg.png

Delete an existing asset

Response
HTTP/1.1 200 OK
{
    "status" : "ok",
}