Function
Static Public Summary | ||
public |
changeRecurring(options: Object, id: Number | String): Promise PUT /admin/recurring_application_charge.xml |
|
public |
createCharge(options: Object, id: Number | String): Promise POST /admin/application_charges.xml |
|
public |
createCoupon(options: Object, id: Number | String): Promise POST /admin/discount_codes.xml |
|
public |
createJsTag(options: Object, id: Number | String): Promise POST /admin/js_tags.xml |
|
public |
createPriceKind(options: Object, id: Number | String): Promise POST /admin/price_kinds.json |
|
public |
createProduct(options: Object, id: Number | String): Promise POST /admin/products.xml |
|
public |
createRecurring(options: Object, id: Number | String): Promise POST /admin/recurring_application_charge.xml |
|
public |
declineCharge(options: Object, id: Number | String): Promise POST /admin/application_charges/{id}/decline.xml |
|
public |
PUT /admin/themes/#{theme_id}/assets/#{id}.xml |
|
public |
editCoupon(options: Object, id: Number | String): Promise PUT /admin/discount_codes/{id}.xml |
|
public |
editPriceKind(options: Object, id: Number | String): Promise PUT /admin/price_kinds/{id}.xml |
|
public |
editProduct(options: Object, id: Number | String): Promise PUT /admin/products/{id}.xml |
|
public |
Output Request-Promise error, used to create Promise reject |
|
public |
GET request |
|
public |
getAccount(options: Object, id: number | string): Promise GET /admin/account.xml |
|
public |
GET /admin/themes/#{theme_id}/assets/#{id}.xml |
|
public |
GET /admin/application_charges/{id}.xml |
|
public |
getCollection(options: Object, id: Number | String): Promise GET /admin/collections/{id}.xml |
|
public |
GET /admin/discount_codes/{id}.xml |
|
public |
getPriceKind(options: Object, id: Number | String): Promise GET /admin/price_kinds/{id}.json |
|
public |
getProduct(options: Object, id: Number | String): Promise GET /admin/products/{id}.xml |
|
public |
getRecurring(options: Object, id: Number | String): Promise GET /admin/recurring_application_charge.xml |
|
public |
GET /admin/themes/#{theme_id}/assets.xml |
|
public |
listCharge(options: Object, id: Number | String): Promise GET /admin/application_charges.xml |
|
public |
listCollection(options: Object, id: Number | String): Promise GET /admin/collections.xml |
|
public |
listCoupon(options: Object, id: Number | String): Promise GET /admin/discount_codes.xml |
|
public |
GET /admin/files.xml |
|
public |
listPriceKind(options: Object, id: Number | String): Promise 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 Request-Promise response, used to create Promise resolve |
|
public |
POST request |
|
public |
PUT request |
|
public |
DELETE request |
|
public |
removeAsset(options: Object, id: Number | String): Promise DELETE /admin/themes/#{theme_id}/assets/#{id}.xml |
|
public |
removeCoupon(options: Object, id: Number | String): Promise DELETE /admin/discount_codes/{id}.xml |
|
public |
removeFile(options: Object, id: Number | String): Promise DELETE /admin/files/{id}.xml |
|
public |
removePriceKind(options: Object, id: Number | String): Promise DELETE /admin/price_kinds/{id}.json |
|
public |
removeProduct(options: Object, id: Number | String): Promise DELETE /admin/products/{id}.xml |
|
public |
removeRecurring(options: Object, id: Number | String): Promise 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 |
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
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' } }
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': '' } }
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' } }
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"
}
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: '' } }
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' } }
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' } }
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:
Name | Type | Attribute | Description |
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 |
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
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"
}
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: '' } }
public error(response: Object): Object source
import error from 'insales/lib/error.js'
Output Request-Promise error, used to create Promise reject
Params:
Name | Type | Attribute | Description |
response | Object | Required, full response data |
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: 'Имя' } } }
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 }}' } }
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' } }
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': '' } }
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': '' } }
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" }
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: '' } }
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' } }
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': 'Карточка заказа' }
]}};
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' } } }
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': ''}]}}
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:
Name | Type | Attribute | Description |
options | Object | ||
options.token | string | Required, access token for shop |
|
options.url | string | Required, shop url |
|
options.page | number | string |
|
Page |
options.per_page | number | string |
|
Coupons per page |
options.updated_since | string |
|
Coupons updated since. Format YYYY-MM-DD |
options.deleted | boolean |
|
Deleted coupons |
id | Number | String | Required, app id |
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:
Name | Type | Attribute | Description |
options | Object | ||
options.token | string | Required, access token for shop |
|
options.url | string | Required, shop url |
|
options.page | number | string |
|
Page |
options.per_page | number | string |
|
Files per page |
id | Number | String | Required, app id |
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"
}
]
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:
Name | Type | Attribute | Description |
options | Object | ||
options.token | string | Required, access token for shop |
|
options.url | string | Required, shop url |
|
options.page | string | number |
|
Page |
options.per_page | string | number |
|
Per page |
options.updated_since | string |
|
Products updated since. Format YYYY-MM-DD |
options.deleted | boolean |
|
Deleted products |
id | Number | String | Required, app id |
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' }]}};
public output(response: Object): Object source
import output from 'insales/lib/output.js'
Output Request-Promise response, used to create Promise resolve
Params:
Name | Type | Attribute | Description |
response | Object | Required |
public post(conn: Object): Promise source
import {post} from 'insales/lib/methods/post.js'
POST request
public remove(conn: Object): Promise source
import {remove} from 'insales/lib/methods/remove.js'
DELETE request
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
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
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
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
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
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
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:
Name | Type | Attribute | Description |
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 |
public request(r: Object): Promise source
import {request} from 'insales/lib/request.js'
Events of Request-Promise
Params:
Name | Type | Attribute | Description |
r | Object | Required, request-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
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' } }
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' } }