Home Reference Source

Function

Static Public Summary
public

PUT /admin/recurring_application_charge.xml

public

POST /admin/application_charges.xml

public

POST /admin/discount_codes.xml

public

createJsTag(options: Object, id: Number | String): Promise

POST /admin/js_tags.xml

public

POST /admin/price_kinds.json

public

POST /admin/products.xml

public

POST /admin/recurring_application_charge.xml

public

POST /admin/application_charges/{id}/decline.xml

public

editAsset(options: Object, id: Number | String): Promise

PUT /admin/themes/#{theme_id}/assets/#{id}.xml

public

editCoupon(options: Object, id: Number | String): Promise

PUT /admin/discount_codes/{id}.xml

public

PUT /admin/price_kinds/{id}.xml

public

editProduct(options: Object, id: Number | String): Promise

PUT /admin/products/{id}.xml

public

error(response: Object): Object

Output Request-Promise error, used to create Promise reject

public

get(conn: Object): Promise

GET request

public

getAccount(options: Object, id: number | string): Promise

GET /admin/account.xml

public

getAsset(options: Object, id: Number | String): Promise

GET /admin/themes/#{theme_id}/assets/#{id}.xml

public

getCharge(options: Object, id: Number | String): Promise

GET /admin/application_charges/{id}.xml

public

GET /admin/collections/{id}.xml

public

getCoupon(options: Object, id: Number | String): Promise

GET /admin/discount_codes/{id}.xml

public

GET /admin/price_kinds/{id}.json

public

getProduct(options: Object, id: Number | String): Promise

GET /admin/products/{id}.xml

public

GET /admin/recurring_application_charge.xml

public

listAsset(options: Object, id: Number | String): Promise

GET /admin/themes/#{theme_id}/assets.xml

public

listCharge(options: Object, id: Number | String): Promise

GET /admin/application_charges.xml

public

GET /admin/collections.xml

public

listCoupon(options: Object, id: Number | String): Promise

GET /admin/discount_codes.xml

public

listFile(options: Object, id: Number | String): Promise

GET /admin/files.xml

public

GET /admin/price_kinds.json

public

listProduct(options: Object, id: Number | String): Promise

GET /admin/products.xml

public

listThemes(options: Object, id: Number | String): Promise

GET /admin/themes.xml

public

output(response: Object): Object

Output Request-Promise response, used to create Promise resolve

public

post(conn: Object): Promise

POST request

public

put(conn: Object): Promise

PUT request

public

DELETE request

public

removeAsset(options: Object, id: Number | String): Promise

DELETE /admin/themes/#{theme_id}/assets/#{id}.xml

public

DELETE /admin/discount_codes/{id}.xml

public

removeFile(options: Object, id: Number | String): Promise

DELETE /admin/files/{id}.xml

public

DELETE /admin/price_kinds/{id}.json

public

DELETE /admin/products/{id}.xml

public

DELETE /admin/recurring_application_charge.xml

public

renameAsset(options: Object, id: Number | String): Promise

PUT /admin/themes/#{theme_id}/assets/#{id}/rename.xml

public

Events of Request-Promise

public

token(token: String | Number, secret: String | Number): String

Generate access token for shop

public

uploadAsset(options: Object, id: Number | String): Promise

POST /admin/themes/#{theme_id}/assets.xml

public

uploadFile(options: Object, id: Number | String): Promise

POST /admin/files.xml

Static Public

public changeRecurring(options: Object, id: Number | String): Promise source

import {changeRecurring} from 'insales/lib/api/recurringcharge.js'

PUT /admin/recurring_application_charge.xml

Examples:

 insales.changeRecurring({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   price: 1010
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.price string | number

Required, price

id Number | String

Required, app id

Return:

Promise

public createCharge(options: Object, id: Number | String): Promise source

import {createCharge} from 'insales/lib/api/charge.js'

POST /admin/application_charges.xml

Examples:

 insales.createCharge({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   charge: {
      'application-charge': {
        'name': 'Купи слона',
        'price': '180.0',
        'return-url': 'http://application.my/check_payment_url/%id_in_my_application'
      }
   }
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'application-charge':
   { 'created-at': '2011-11-11T11:11:11+03:00',
     id: '1234',
     name: 'Купи слона',
     price: '180.0',
     'return-url': 'http://application.my/check_payment_url/%id_in_my_application',
     status: 'pending',
     test: '',
     'updated-at': '2011-11-11T11:11:11+03:00',
     'confirmation-url': 'http://shop-test.myinsales.ru/admin/invoices/123456' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.charge object

Required, charge info

id Number | String

Required, app id

Return:

Promise

public createCoupon(options: Object, id: Number | String): Promise source

import {createCoupon} from 'insales/lib/api/coupon.js'

POST /admin/discount_codes.xml

Examples:

 insales.createCoupon({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   coupon: {
      'discount_code': {
        'code': 'frandom2',
        'act_once': 'true',
        'discount': 10,
        'type_id': 1,
        'description': 'API code',
        'disabled': 0,
        'expired-at': '2030-06-09'
      }
   }
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'discount-code':
    { 'act-once': 'true',
      'act-once-for-client': '',
      code: 'frandom2',
      'created-at': '2011-11-11T11:11:11+03:00',
      description: 'API code',
      disabled: 'false',
      discount: '10.0',
      'expired-at': '2030-06-09',
      id: '100000',
      'min-price': '',
      'type-id': '1',
      'updated-at': '2011-11-11T11:11:11+03:00',
      worked: 'true',
      'discount-collections': '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.coupon object

Required, coupon

id Number | String

Required, app id

Return:

Promise

public createJsTag(options: Object, id: Number | String): Promise source

import {createJsTag} from 'insales/lib/api/jstag.js'

POST /admin/js_tags.xml

Examples:

 insales.createJsTag({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   jstag: {
     'js-tag': {
       'type': 'JsTag::TextTag',
       'content': 'http://link'
     }
   }
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'file-tag':
   { 'account-id': '12345',
     'application-password-id': '12345',
     content: 'http://link',
     'created-at': '2011-11-11 11:11:11 +0300',
     id: '12345',
     name: '',
     'updated-at': '2011-11-11 11:11:11 +0300' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.jstag object

Required, jstag

id Number | String

Required, app id

Return:

Promise

public createPriceKind(options: Object, id: Number | String): Promise source

import {createPriceKind} from 'insales/lib/api/pricekind.js'

POST /admin/price_kinds.json

Examples:

 insales.createPriceKind({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   pricekind: {
      'price_kind': {
        'title': 'name'
      }
   }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 {
   "id": 113,
   "price_index": 3,
   "show_in_lists": true,
   "title": "name",
   "variant_price_method_name": "price3"
 }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.pricekind object

Required, price kind

id Number | String

Required, app id

Return:

Promise

public createProduct(options: Object, id: Number | String): Promise source

import {createProduct} from 'insales/lib/api/product.js'

POST /admin/products.xml

Examples:

 insales.createProduct({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   product: {
     'product': {
       'category-id': '1',
       'title': 'Product 1',
       'variants-attributes': {
         'variants-attribute': {
           'sku': '12345',
           'quantity': '1',
           'price': '100'
         }
       }
     }
   }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { product:
   { archived: 'false',
     available: '',
     'canonical-url-collection-id': '',
     'category-id': '1',
     'created-at': '2011-11-11 11:11:11 +0300',
     id: '12345',
     'is-hidden': 'false',
     'sort-weight': '',
     unit: 'pcs',
     'updated-at': '2011-11-11 11:11:11 +0300',
     title: 'Product 1',
     'short-description': '',
     permalink: 'product-1',
     'html-title': '',
     'meta-keywords': '',
     'meta-description': '',
     'currency-code': 'RUR',
     'collections-ids': '',
     images: '',
     'option-names': '',
     properties: '',
     characteristics: '',
     'product-field-values': '',
     variants: { variant: [Object] },
     description: '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.coupon object

Required, product

id Number | String

Required, app id

Return:

Promise

public createRecurring(options: Object, id: Number | String): Promise source

import {createRecurring} from 'insales/lib/api/recurringcharge.js'

POST /admin/recurring_application_charge.xml

Examples:

 insales.createRecurring({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   price: 1000
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'recurring-application-charge':
   { blocked: 'false',
     'created-at': '2011-11-11T11:11:11+03:00',
     id: '12345',
     monthly: '1000.0',
     'paid-till': '2011-11-21',
     'trial-expired-at': '2011-12-11',
     'updated-at': '2011-11-11T11:11:11+03:00' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.price string | number

Required, price

id Number | String

Required, app id

Return:

Promise

public declineCharge(options: Object, id: Number | String): Promise source

import {declineCharge} from 'insales/lib/api/charge.js'

POST /admin/application_charges/{id}/decline.xml

Examples:

 insales.declineCharge({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   chargeid: '12345'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'application-charge':
   { 'created-at': '2011-11-11T11:11:11+03:00',
     id: '1234',
     name: 'Купи слона',
     price: '180.0',
     'return-url': 'http://application.my/check_payment_url/%id_in_my_application',
     status: 'declined',
     test: '',
     'updated-at': '2011-11-11T11:11:11+03:00',
     'confirmation-url': 'http://shop-test.myinsales.ru/admin/invoices/123456' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.chargeid number | string

Required, charge id

id Number | String

Required, app id

Return:

Promise

public editAsset(options: Object, id: Number | String): Promise source

import {editAsset} from 'insales/lib/api/asset.js'

PUT /admin/themes/#{theme_id}/assets/#{id}.xml

Examples:

 insales.editAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   theme: '643879',
   assetId: '60423000',
   asset: {
     content: 'Amazing template for page {{product.title}}'
   }
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { asset:
   { id: '60423000',
     'theme-id': '643879',
     type: 'Asset::Template',
     name: 'page.new_page.liquid',
     'content-type': 'text/x-liquid',
     'file-size': '52',
     'human-readable-name': 'Страница: new_page' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.asset Object

Required, asset content

options.theme Number | String

Required, theme id

options.assetId Number | String

Required, asset id

id Number | String

Required, app id

Return:

Promise

public editCoupon(options: Object, id: Number | String): Promise source

import {editCoupon} from 'insales/lib/api/coupon.js'

PUT /admin/discount_codes/{id}.xml

Examples:

 insales.editCoupon({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   couponid: '100000',
   coupon: {
     'discount_code': {
       'code': 'frandom3'
     }
   }
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.couponid number | string

Required, coupon id

options.coupon object

Required, coupon

id Number | String

Required, app id

Return:

Promise

public editPriceKind(options: Object, id: Number | String): Promise source

import {editPriceKind} from 'insales/lib/api/pricekind.js'

PUT /admin/price_kinds/{id}.xml

Examples:

 insales.editPriceKind({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   id: '111',
   pricekind: {
      'price_kind': {
        'title': 'name123'
      }
   }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 {
   "id": 111,
   "price_index": 3,
   "show_in_lists": true,
   "title": "name123",
   "variant_price_method_name": "price3"
 }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.id number | string

Required, price kind id

options.pricekind object

Required, price kind

id Number | String

Required, app id

Return:

Promise

public editProduct(options: Object, id: Number | String): Promise source

import {editProduct} from 'insales/lib/api/product.js'

PUT /admin/products/{id}.xml

Examples:

 insales.editProduct({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   productid: '12345',
   product: {
     'product': {
       'title': 'Product 2',
     }
   }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { product:
   { archived: 'false',
     available: '',
     'canonical-url-collection-id': '',
     'category-id': '1',
     'created-at': '2011-11-11 11:11:11 +0300',
     id: '12345',
     'is-hidden': 'false',
     'sort-weight': '',
     unit: 'pcs',
     'updated-at': '2011-11-11 11:11:11 +0300',
     title: 'Product 2',
     'short-description': '',
     permalink: 'product-1',
     'html-title': '',
     'meta-keywords': '',
     'meta-description': '',
     'currency-code': 'RUR',
     'collections-ids': '',
     images: '',
     'option-names': '',
     properties: '',
     characteristics: '',
     'product-field-values': '',
     variants: { variant: [Object] },
     description: '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.productid number | string

Required, product id

options.product object

Required, product

id Number | String

Required, app id

Return:

Promise

public error(response: Object): Object source

import error from 'insales/lib/error.js'

Output Request-Promise error, used to create Promise reject

Params:

NameTypeAttributeDescription
response Object

Required, full response data

Return:

Object

Return Properties:

NameTypeAttributeDescription
type String

Name of error

url String

Url where error happen

method String

Http method

msg String

Error message

response Object

Full response

statusCode Number

Status code

public get(conn: Object): Promise source

import {get} from 'insales/lib/methods/get.js'

GET request

Params:

NameTypeAttributeDescription
conn Object
conn.id string

Required, app id

conn.token string

Required, token to access shop

conn.url string

Required, shop url

conn.api string

Required, api endpoint

conn.query object
  • optional

URL query string

Return:

Promise

public getAccount(options: Object, id: number | string): Promise source

import {getAccount} from 'insales/lib/api/account.js'

GET /admin/account.xml

Examples:

 insales.getAccount({
   token: '1234567890',
   url: 'shop-test.myinsales.ru'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { account:
    { blocked: 'false',
      city: 'Москва',
      'contact-phone': '',
      country: 'RU',
      'enable-cart-discounts': 'true',
      'enable-client-discounts': 'false',
      'enable-group-discounts': 'true',
      'enable-order-discounts': 'false',
      'hide-items-out-of-stock': 'false',
      id: '12345',
      'notification-email': '',
      organization: '',
      'sms-notification-phone': '',
      state: 'г Москва',
      subdomain: 'shop-test',
      email: 'mail@mail.ru',
      icq: '',
      phone: '+71234567890',
      title: 'Название магазина',
      'minimum-items-price': '',
      'stock-currency-exchange-rate': '1.0',
      'client-cookies-whitelist': '',
      'main-host': 'shop-test.myinsales.ru',
      'next-order-number': '1040',
      'time-zone': 'Moscow',
      owner:
       { 'created-at': '2011-11-11 11:11:11 +0400',
         email: 'mail@mail.ru',
         id: '12345',
          name: 'Имя' } } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id number | string

Required, app id

Return:

Promise

public getAsset(options: Object, id: Number | String): Promise source

import {getAsset} from 'insales/lib/api/asset.js'

GET /admin/themes/#{theme_id}/assets/#{id}.xml

Examples:

 insales.getAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   theme: '643879',
   assetId: '60423000'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 {{ asset:
    { id: '60423000',
      'theme-id': '643879',
      type: 'Asset::Template',
      name: 'page.new_page.liquid',
      'content-type': 'text/x-liquid',
      'file-size': '0',
      'human-readable-name': 'Страница: new_page',
      content: 'new page {{ page.title }}' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.theme Number | String

Required, theme id

options.assetId Number | String

Required, asset id

id Number | String

Required, app id

Return:

Promise

public getCharge(options: Object, id: Number | String): Promise source

import {getCharge} from 'insales/lib/api/charge.js'

GET /admin/application_charges/{id}.xml

Examples:

 insales.getCharge({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   chargeid: '12345'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'application-charge':
   { 'created-at': '2011-11-11T11:11:11+03:00',
     id: '1234',
     name: 'Купи слона',
     price: '180.0',
     'return-url': 'http://application.my/check_payment_url/%id_in_my_application',
     status: 'pending',
     test: '',
     'updated-at': '2011-11-11T11:11:11+03:00',
     'confirmation-url': 'http://shop-test.myinsales.ru/admin/invoices/123456' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.chargeid number | string

Required, charge id

id Number | String

Required, app id

Return:

Promise

public getCollection(options: Object, id: Number | String): Promise source

import {getCollection} from 'insales/lib/api/collection.js'

GET /admin/collections/{id}.xml

Examples:

 insales.getCollection({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   collectionid: '11111'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { collection:
   { 'created-at': '2011-11-11 11:11:11 +0300',
     id: '1234567',
     'is-hidden': 'true',
     'parent-id': '22222',
     position: '1',
     recursive: '',
     'updated-at': '2011-11-11 11:11:11 +0300',
     title: 'Name 1',
     description: '',
     'html-title': '',
     'meta-description': '',
     'meta-keywords': '',
     permalink: 'name1',
     url: '/collection/name1',
     'seo-description': '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.collectionid. number | string

Required, collection id

id Number | String

Required, app id

Return:

Promise

public getCoupon(options: Object, id: Number | String): Promise source

import {getCoupon} from 'insales/lib/api/coupon.js'

GET /admin/discount_codes/{id}.xml

Examples:

 insales.getCoupon({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   couponid: '1076619'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'discount-code':
    { 'act-once': 'false',
      'act-once-for-client': 'false',
      code: 'WWWWWW',
      'created-at': '2011-11-11T11:11:11+03:00',
      description: '',
      disabled: 'false',
      discount: '10.0',
      'expired-at': '2011-11-11',
      id: '1111111',
      'min-price': '0.0',
      'type-id': '1',
      'updated-at': '2011-11-11T11:11:11+03:00',
      worked: 'true',
      'discount-collections': '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.couponid number | string

Required, coupon id

id Number | String

Required, app id

Return:

Promise

public getPriceKind(options: Object, id: Number | String): Promise source

import {getPriceKind} from 'insales/lib/api/pricekind.js'

GET /admin/price_kinds/{id}.json

Examples:

 insales.getPriceKind({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   id: '111'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output: { "id": 111, "price_index": 1, "show_in_lists": true, "title": "тест 1", "variant_price_method_name": "price2" }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.id number | string

Required, price kind id

id Number | String

Required, app id

Return:

Promise

public getProduct(options: Object, id: Number | String): Promise source

import {getProduct} from 'insales/lib/api/product.js'

GET /admin/products/{id}.xml

Examples:

 insales.getProduct({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   productid: '12345'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { product:
   { archived: 'false',
     available: 'true',
     'canonical-url-collection-id': '',
     'category-id': '1',
     'created-at': '2011-11-11 11:11:11 +0300',
     id: '12345',
     'is-hidden': 'false',
     'sort-weight': '',
     unit: 'pcs',
     'updated-at': '2011-11-11 11:11:11 +0300',
     title: 'Product 1',
     'short-description': '',
     permalink: 'product-1',
     'html-title': '',
     'meta-keywords': '',
     'meta-description': '',
     'currency-code': 'RUR',
     'collections-ids': '',
     images: '',
     'option-names': '',
     properties: '',
     characteristics: '',
     'product-field-values': '',
     variants: { variant: [Object] },
     description: '' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.productid number | string

Required, product id

id Number | String

Required, app id

Return:

Promise

public getRecurring(options: Object, id: Number | String): Promise source

import {getRecurring} from 'insales/lib/api/recurringcharge.js'

GET /admin/recurring_application_charge.xml

Examples:

 insales.getRecurring({
   token: '1234567890',
   url: 'shop-test.myinsales.ru'
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'recurring-application-charge':
   { blocked: 'false',
     'created-at': '2011-11-11T11:11:11+03:00',
     id: '12345',
     monthly: '1000.0',
     'paid-till': '2011-11-21',
     'trial-expired-at': '2011-12-11',
     'updated-at': '2011-11-11T11:11:11+03:00' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id Number | String

Required, app id

Return:

Promise

public listAsset(options: Object, id: Number | String): Promise source

import {listAsset} from 'insales/lib/api/asset.js'

GET /admin/themes/#{theme_id}/assets.xml

Examples:

 insales.listAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   theme: '643879'
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'assets':
    { 'asset':
       [ { id: '60410193',
           'theme-id': '643879',
           type: 'Asset::Template',
           name: 'order.liquid',
           'content-type': 'text/x-liquid',
           'file-size': '5125',
           'human-readable-name': 'Карточка заказа' }
        ]}};

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.theme Number | String

Required, theme id

id Number | String

Required, app id

Return:

Promise

public listCharge(options: Object, id: Number | String): Promise source

import {listCharge} from 'insales/lib/api/charge.js'

GET /admin/application_charges.xml

Examples:

 insales.listCharge({
   token: '1234567890',
   url: 'shop-test.myinsales.ru'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'application-charges':
   { 'application-charge':
      { 'created-at': '2011-11-11T11:11:11+03:00',
        id: '1234',
        name: 'Купи слона',
        price: '180.0',
        'return-url': 'http://application.my/check_payment_url/%id_in_my_application',
        status: 'pending',
        test: '',
        'updated-at': '2011-11-11T11:11:11+03:00',
        'confirmation-url': 'http://shop-test.myinsales.ru/admin/invoices/123456' } } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id Number | String

Required, app id

Return:

Promise

public listCollection(options: Object, id: Number | String): Promise source

import {listCollection} from 'insales/lib/api/collection.js'

GET /admin/collections.xml

Examples:

 insales.listCollection({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'collections':
    { 'collection':
       [{ 'created-at': '2011-11-11 11:11:11 +0300',
         id: '1234567',
         'is-hidden': 'true',
         'parent-id': '11111',
         position: '1',
         recursive: '',
         'updated-at': '2011-11-11 11:11:11 +0300',
         title: 'Name 1',
         description: '',
         'html-title': '',
         'meta-description': '',
         'meta-keywords': '',
         permalink: 'name1',
         url: '/collection/name1',
         'seo-description': '' },
        {'created-at': '2011-11-11 11:11:11 +0300',
          id: '12345678',
          'is-hidden': 'true',
          'parent-id': '11111',
          position: '2',
          recursive: '',
          'updated-at': '2011-11-11 11:11:11 +0300',
          title: 'Name 2',
          description: '',
          'html-title': '',
          'meta-description': '',
          'meta-keywords': '',
          permalink: 'name2',
          url: '/collection/name2',
          'seo-description': ''}]}}

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id Number | String

Required, app id

Return:

Promise

public listCoupon(options: Object, id: Number | String): Promise source

import {listCoupon} from 'insales/lib/api/coupon.js'

GET /admin/discount_codes.xml

Examples:

 insales.listCoupon({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'discount-codes':
    { 'discount-code':
       [{ 'act-once': 'false',
         'act-once-for-client': 'false',
         code: 'WWWWWW',
         'created-at': '2011-11-11T11:11:11+03:00',
         description: '',
         disabled: 'false',
         discount: '10.0',
         'expired-at': '2011-11-11',
         id: '1111111',
         'min-price': '0.0',
         'type-id': '1',
         'updated-at': '2011-11-11T11:11:11+03:00',
         worked: 'true',
         'discount-collections': '' },
       { 'act-once': 'false',
         'act-once-for-client': 'false',
         code: 'WWWWWY',
         'created-at': '2011-11-11T11:11:11+03:00',
         description: '',
         disabled: 'false',
         discount: '10.0',
         'expired-at': '2011-11-11',
         id: '1111112',
         'min-price': '0.0',
         'type-id': '1',
         'updated-at': '2011-11-11T11:11:11+03:00',
         worked: 'true',
         'discount-collections': '' }]}}

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.page number | string
  • optional
  • default: 1

Page

options.per_page number | string
  • optional
  • default: 250

Coupons per page

options.updated_since string
  • optional

Coupons updated since. Format YYYY-MM-DD

options.deleted boolean
  • optional

Deleted coupons

id Number | String

Required, app id

Return:

Promise

public listFile(options: Object, id: Number | String): Promise source

import {listFile} from 'insales/lib/api/file.js'

GET /admin/files.xml

Examples:

 insales.listFile({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'files':
    { 'file':
       [{ 'created-at': '2011-11-11T11:11:11+03:00',
         id: '11111',
         'absolute-url': 'http://static2.insales.ru/files/1/6050/194466/original/1.gif' },
        { 'created-at': '2011-11-11T11:11:11+03:00',
         id: '11112',
         'absolute-url': 'http://static2.insales.ru/files/1/6050/194466/original/1.gif' }]}}

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.page number | string
  • optional
  • default: 1

Page

options.per_page number | string
  • optional
  • default: 250

Files per page

id Number | String

Required, app id

Return:

Promise

public listPriceKind(options: Object, id: Number | String): Promise source

import {listPriceKind} from 'insales/lib/api/pricekind.js'

GET /admin/price_kinds.json

Examples:

 insales.listPriceKind({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 [
   {
       "id": 111,
       "price_index": 1,
       "show_in_lists": true,
       "title": "тест 1",
       "variant_price_method_name": "price2"
   },
   {
       "id": 112,
       "price_index": 2,
       "show_in_lists": true,
       "title": "тест2",
       "variant_price_method_name": "price3"
   }
 ]

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id Number | String

Required, app id

Return:

Promise

public listProduct(options: Object, id: Number | String): Promise source

import {listProduct} from 'insales/lib/api/product.js'

GET /admin/products.xml

Examples:

 insales.listProduct({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
 }).then(response => {
   console.info(response.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { products:
   { product:
      [{ archived: 'false',
        available: '',
        'canonical-url-collection-id': '',
        'category-id': '1',
        'created-at': '2011-11-11 11:11:11 +0300',
        id: '12345',
        'is-hidden': 'false',
        'sort-weight': '',
        unit: 'pcs',
        'updated-at': '2011-11-11 11:11:11 +0300',
        title: 'Product 1',
        'short-description': '',
        permalink: 'product-1',
        'html-title': '',
        'meta-keywords': '',
        'meta-description': '',
        'currency-code': 'RUR',
        'collections-ids': '',
        images: '',
        'option-names': '',
        properties: '',
        characteristics: '',
        'product-field-values': '',
        variants: { variant: [Object] },
        description: '' },
      { archived: 'false',
        available: '',
        'canonical-url-collection-id': '',
        'category-id': '1',
        'created-at': '2011-11-11 11:11:11 +0300',
        id: '123456',
        'is-hidden': 'false',
        'sort-weight': '',
        unit: 'pcs',
        'updated-at': '2011-11-11 11:11:11 +0300',
        title: 'Product 2',
        'short-description': '',
        permalink: 'product-2',
        'html-title': '',
        'meta-keywords': '',
        'meta-description': '',
        'currency-code': 'RUR',
        'collections-ids': '',
        images: '',
        'option-names': '',
        properties: '',
        characteristics: '',
        'product-field-values': '',
        variants: { variant: [Object] },
        description: '' }]}}

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.page string | number
  • optional
  • default: 1

Page

options.per_page string | number
  • optional
  • default: 100

Per page

options.updated_since string
  • optional

Products updated since. Format YYYY-MM-DD

options.deleted boolean
  • optional

Deleted products

id Number | String

Required, app id

Return:

Promise

public listThemes(options: Object, id: Number | String): Promise source

import {listThemes} from 'insales/lib/api/themes.js'

GET /admin/themes.xml

Examples:

 insales.listThemes({
   token: '1234567890',
   url: 'shop-test.myinsales.ru'
 }).then(response => {
   console.info(response.data.themes);
 }).catch(err => {
   console.error(err);
 });

Output:

 { 'themes':
    { theme:
        [ { 'created-at': '2016-05-12 20:12:08 +0300',
            description: '',
            'errors-text': '',
            id: '626874',
            'is-mobile': 'false',
            'is-published': 'false',
            title: 'Custom',
            'updated-at': '2016-06-17 07:59:26 +0300' },
          { 'created-at': '2016-06-01 21:55:16 +0300',
            description: '',
            'errors-text': '',
            id: '634252',
            'is-mobile': 'false',
            'is-published': 'true',
            title: 'Custom2',
            'updated-at': '2016-07-14 06:19:55 +0300' }]}};

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.theme Number | String

Required, theme id

id Number | String

Required, app id

Return:

Promise

public output(response: Object): Object source

import output from 'insales/lib/output.js'

Output Request-Promise response, used to create Promise resolve

Params:

NameTypeAttributeDescription
response Object

Required

Return:

Object

Return Properties:

NameTypeAttributeDescription
data Object

Response body

response Object

Full response

statusCode Number

Status code

callLimits Object

API call limit

callLimits.current number
callLimits.remaining number
callLimits.max Number

public post(conn: Object): Promise source

import {post} from 'insales/lib/methods/post.js'

POST request

Params:

NameTypeAttributeDescription
conn Object
conn.id string

Required, app id

conn.token string

Required, token to access shop

conn.url string

Required, shop url

conn.api string

Required, api endpoint

conn.obj object
  • optional

HTTP POST data

Return:

Promise

public put(conn: Object): Promise source

import {put} from 'insales/lib/methods/put.js'

PUT request

Params:

NameTypeAttributeDescription
conn Object
conn.id string

Required, app id

conn.token string

Required, token to access shop

conn.url string

Required, shop url

conn.api string

Required, api endpoint

conn.obj object

HTTP PUT data

Return:

Promise

public remove(conn: Object): Promise source

import {remove} from 'insales/lib/methods/remove.js'

DELETE request

Params:

NameTypeAttributeDescription
conn Object
conn.id string

Required, app id

conn.token string

Required, token to access shop

conn.url string

Required, shop url

conn.api string

Required, api endpoint

Return:

Promise

public removeAsset(options: Object, id: Number | String): Promise source

import {removeAsset} from 'insales/lib/api/asset.js'

DELETE /admin/themes/#{theme_id}/assets/#{id}.xml

Examples:

 insales.removeAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
     theme: '643879',
     assetId: '60423000'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.theme Number | String

Required, theme id

options.assetId Number | String

Required, asset id

id Number | String

Required, app id

Return:

Promise

public removeCoupon(options: Object, id: Number | String): Promise source

import {removeCoupon} from 'insales/lib/api/coupon.js'

DELETE /admin/discount_codes/{id}.xml

Examples:

 insales.removeCoupon({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   couponid: '100000'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.couponid number | string

Required, coupon id

id Number | String

Required, app id

Return:

Promise

public removeFile(options: Object, id: Number | String): Promise source

import {removeFile} from 'insales/lib/api/file.js'

DELETE /admin/files/{id}.xml

Examples:

 insales.removeFile({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   fileid: '12345'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.fileid number | string

Required, file id

id Number | String

Required, app id

Return:

Promise

public removePriceKind(options: Object, id: Number | String): Promise source

import {removePriceKind} from 'insales/lib/api/pricekind.js'

DELETE /admin/price_kinds/{id}.json

Examples:

 insales.removePriceKind({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   id: '111'
 }).then(output => {
   console.info(output.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.id number | string

Required, price kind id

id Number | String

Required, app id

Return:

Promise

public removeProduct(options: Object, id: Number | String): Promise source

import {removeProduct} from 'insales/lib/api/product.js'

DELETE /admin/products/{id}.xml

Examples:

 insales.removeProduct({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   productid: '12345'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.productid number | string

Required, product id

id Number | String

Required, app id

Return:

Promise

public removeRecurring(options: Object, id: Number | String): Promise source

import {removeRecurring} from 'insales/lib/api/recurringcharge.js'

DELETE /admin/recurring_application_charge.xml

Examples:

 insales.changeRecurring({
   token: '1234567890',
   url: 'shop-test.myinsales.ru'
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 200

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

id Number | String

Required, app id

Return:

Promise

public renameAsset(options: Object, id: Number | String): Promise source

import {renameAsset} from 'insales/lib/api/asset.js'

PUT /admin/themes/#{theme_id}/assets/#{id}/rename.xml

Examples:

 insales.renameAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   theme: '643879',
   assetId: '60423000',
   assets: {
     'asset': {
       'new_name': 'page.amazing_new_page.liquid'
     }
   }
 }).then(output => {
   console.info(output.response.statusCode);
 }).catch(err => {
   console.error(err);
 });

Output:

 { asset:
   { id: '60423000',
     'theme-id': '643879',
     type: 'Asset::Template',
     name: 'page.amazing_new_page.liquid',
     'content-type': 'text/x-liquid',
     'file-size': '42',
     'human-readable-name': 'Страница: amazing_new_page' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.assets Object

Required, asset new_name

options.theme Number | String

Required, theme id

options.assetId Number | String

Required, asset id

id Number | String

Required, app id

Return:

Promise

public request(r: Object): Promise source

import {request} from 'insales/lib/request.js'

Events of Request-Promise

Params:

NameTypeAttributeDescription
r Object

Required, request-promise

Return:

Promise

public token(token: String | Number, secret: String | Number): String source

import {token} from 'insales/lib/api/token.js'

Generate access token for shop

Examples:

 insales.token('12345');

Output:

 8cfa2282b17de0a598c010f5f0109e7d

Params:

NameTypeAttributeDescription
token String | Number

Required, token receive when install app

secret String | Number

Required, app secret

Return:

String

access token

public uploadAsset(options: Object, id: Number | String): Promise source

import {uploadAsset} from 'insales/lib/api/asset.js'

POST /admin/themes/#{theme_id}/assets.xml

Examples:

 insales.uploadAsset({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   theme: '643879',
   asset: {
      'name': 'logo.png',
      'src': 'http://www.insales.ru/assets/images/content/logo.png',
      'type': 'Asset::Media'
      }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { asset:
    { id: '60374631',
      'theme-id': '643879',
      type: 'Asset::Media',
      name: 'logo.png',
      'content-type': 'image/jpeg',
      'file-size': '71373',
      'human-readable-name': 'logo.png',
        asset_url: '/assets/1/4903/643879/v_1467231594/logo.png?1467234697' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.theme Number | String

Required, theme id

id Number | String

Required, app id

options.asset object

Required, asset property

Return:

Promise

public uploadFile(options: Object, id: Number | String): Promise source

import {uploadFile} from 'insales/lib/api/file.js'

POST /admin/files.xml

Examples:

 insales.uploadFile({
   token: '1234567890',
   url: 'shop-test.myinsales.ru',
   files: {
      'file': {
        'src': 'http://url'
      }
   }
 }).then(output => {
   console.info(output.data);
 }).catch(err => {
   console.error(err);
 });

Output:

 { file:
   { 'created-at': '2011-11-11T11:11:11+03:00',
     id: '111111',
     'absolute-url': 'http://static-internal.insales.ru' } }

Params:

NameTypeAttributeDescription
options Object
options.token string

Required, access token for shop

options.url string

Required, shop url

options.file object

Required, url to file

id Number | String

Required, app id

Return:

Promise