### Install Sendsay API Client (Yarn/NPM) Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Installs the Sendsay API JavaScript client using Yarn or NPM. This is the primary method for adding the library to your project. ```bash yarn add sendsay-api ``` -------------------------------- ### Node.js Setup with Fetch Polyfill Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Sets up the Sendsay client in a Node.js environment, requiring the 'isomorphic-fetch' polyfill for network requests. Demonstrates basic API key authentication and a sample request. ```javascript require('isomorphic-fetch'); // Apply the polyfill. const Sendsay = require('sendsay-api'); const sendsay = new Sendsay({ apiKey: 'secret' }); sendsay.request({ action: 'sys.settings.get', list: ['about.id']}).then(function(res) { console.log(res.list['about.id']); }) ``` -------------------------------- ### Import Sendsay API Client (CommonJS) Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Imports the Sendsay API client in a CommonJS environment, typically used in Node.js or older JavaScript setups. ```javascript const Sendsay = require('sendsay-api'); ``` -------------------------------- ### Sendsay API Request with API Key Authentication Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Demonstrates how to authenticate with the Sendsay API using an API key and make a request to retrieve system settings. ```javascript var sendsay = new Sendsay({ apiKey: '...' }); sendsay.request({ action: 'sys.settings.get', list: ['about.id']}).then(function(res) { console.log(res.list['about.id']); }) ``` -------------------------------- ### Initialize Sendsay with API Key and Make Request Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/index.html Initializes the Sendsay client using an API key stored in local storage. It then makes a 'sys.settings.get' request to retrieve 'about.id' and logs the settings or any errors to the console. ```javascript window.sendsay = new Sendsay({ apiKey: window.localStorage.getItem('apiKey') }); var req = sendsay.request({ action: 'sys.settings.get', list: [ 'about.id' ], }); req.then( function(res) { var settings = res.list; console.log('Sendsay', settings); }, function(err) { console.log('Sendsay', err); }); ``` -------------------------------- ### Initialize Sendsay with Basic Auth and Make Request Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/index.html Initializes the Sendsay client with basic authentication details parsed from local storage. It then makes a 'sys.settings.get' request to retrieve 'about.id' and logs the settings or any errors to the console. ```javascript window.sendsayBasic = new Sendsay({ auth: JSON.parse(window.localStorage.getItem('auth')) }); var req = sendsayBasic.request({ action: 'sys.settings.get', list: [ 'about.id' ], }); req.then( function(res) { var settings = res.list; console.log('Sendsay Basic', settings); }, function(err) { console.log('Sendsay Basic', err); }); ``` -------------------------------- ### Initialize Sendsay with Cookies and Make Request Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/index.html Initializes the Sendsay client and sets the session and policy from cookies. It then makes a 'sys.settings.get' request to retrieve 'about.id' and logs the settings or any errors to the console. ```javascript window.sendsayCookie = new Sendsay(); sendsayCookie.setSessionFromCookie(); sendsayCookie.setPolicyFromCookie(); var req = sendsayCookie.request({ action: 'sys.settings.get', list: [ 'about.id' ], }); req.then( function(res) { var settings = res.list; console.log('Sendsay Cookie', settings); }, function(err) { console.log('Sendsay Cookie', err); }); ``` -------------------------------- ### Sendsay API Simple Request for Settings Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Performs a simple request to the Sendsay API to retrieve various system settings. The response contains a list of requested settings. ```javascript var req = sendsay.request({ action: 'sys.settings.get', list: [ 'about.confirm', 'about.id', 'about.label.member', 'about.name', 'about.open.dt', 'about.open.visitor', 'about.owner.email', 'about.tarif', 'about.user', 'anketa.id.base', 'anketa.id.custom', 'interface.type', 'interface.type.user', 'issue.email.sender.moderation', 'issue.pte.datakey', 'lbac.inuse', 'lbac.on', 'member.hard.limit', 'member.hard.rest', 'member.noconfirm.limit', 'member.noconfirm.rest', 'pase.autopayment', 'pase.destination', 'pase.left', 'pase.state', 'about.chat.on', ], }); req.then(function(res) { var settings = res.list; console.log(settings); }); ``` -------------------------------- ### Sendsay API Request with Login and Password Authentication Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Shows how to authenticate with the Sendsay API using login credentials. The client automatically creates a session before the first request. ```javascript var sendsay = new Sendsay({ auth: { login: 'login', sublogin: 'optional', password: 'secret', } }); sendsay.request({ action: 'sys.settings.get', list: ['about.id']}).then(function(res) { console.log(res.list['about.id']); }) ``` -------------------------------- ### Sendsay API Login Method Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Demonstrates authenticating with the Sendsay API using a dedicated `login` method. This method explicitly handles the authentication process. ```javascript var sendsay = new Sendsay(); sendsay.login({ login: 'login', sublogin: 'optional', password: 'secret', }).then(function() { // The sendsay instance is authenticated. Do a request. }) ``` -------------------------------- ### Include Sendsay API Client via CDN (Minified) Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Includes the minified Sendsay API client directly into an HTML page using a CDN link. Suitable for quick integration without a build process. ```html ``` -------------------------------- ### Include Sendsay API Client via CDN (Unminified) Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Includes the unminified Sendsay API client directly into an HTML page using a CDN link. Useful for debugging or development. ```html ``` -------------------------------- ### Import Sendsay API Client (ES6 Modules) Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Imports the Sendsay API client into an ES6 module environment. This allows for modern JavaScript development practices. ```javascript import Sendsay from 'sendsay-api'; ``` -------------------------------- ### Sendsay Client Configuration with Custom API URL Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Configures the Sendsay client with a custom API endpoint URL, overriding the default. This is useful for development or staging environments. ```javascript var sendsay = new Sendsay({ apiUrl: 'https://api.development.sendsay.ru' }) ``` -------------------------------- ### Set Sendsay Session Manually Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Manually sets the Sendsay session using a provided session string. This is an alternative to automatic session management. ```javascript sendsay.setSession('secret'); ``` -------------------------------- ### Retrieve Sendsay Session from Custom Cookie Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Retrieves the Sendsay session information from a custom-named cookie. This allows flexibility in cookie naming conventions. ```javascript sendsay.setSessionFromCookie('custom_cookie_name'); ``` -------------------------------- ### Retrieve Sendsay Session from Default Cookie Source: https://github.com/sendsay-ru/sendsay-api-js/blob/master/README.md Retrieves the Sendsay session information from the default cookie named 'sendsay_session'. This is useful for maintaining user sessions across requests. ```javascript sendsay.setSessionFromCookie(); // By default the cookie's name is 'sendsay_session'. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.