Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scaleapi

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scaleapi - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

54

lib/scaleapi.js

@@ -35,18 +35,14 @@ 'use strict';

* @constructor
* @param {Object} connectionParams - connection options
* @param {string} connectionParams.apikey - your Scale API key
* @param {string} apiKey- your Scale API key
* @returns {ScaleClient} a client for making Scale requests
*/
function ScaleClient(connectionParams) {
function ScaleClient(apiKey) {
if (!(this instanceof ScaleClient)) {
return new ScaleClient(connectionParams);
return new ScaleClient(apiKey);
}
if (!connectionParams) {
throw new ScaleException('no connection parameters');
}
if (!connectionParams.apikey) {
if (!apiKey) {
throw new ScaleException('missing api key');
}
this.apikey = connectionParams.apikey;
this.apiKey = apiKey;
}

@@ -61,3 +57,3 @@

ScaleClient.prototype.fetchTask = function(taskId, cb) {
getrequest('task/' + taskId, this.apikey, {}, (err, json) => {
getrequest('task/' + taskId, this.apiKey, {}, (err, json) => {
if (cb) cb(err, new Task(this, json));

@@ -74,3 +70,3 @@ });

ScaleClient.prototype.cancelTask = function(taskId, cb) {
getrequest('task/' + taskId + '/cancel', this.apikey, {}, (err, json) => {
getrequest('task/' + taskId + '/cancel', this.apiKey, {}, (err, json) => {
if (cb) cb(err, new Task(this, json));

@@ -108,3 +104,3 @@ });

if (allowedKwargs.offset === undefined) allowedKwargs.offset = DEFAULT_OFFSET;
getrequest('tasks', this.apikey, params, (err, json) => {
getrequest('tasks', this.apiKey, params, (err, json) => {
json.docs = json.docs.map(json => new Task(this, json));

@@ -117,3 +113,3 @@ if (cb) cb(err, json);

validatePayload('categorization', params);
postrequest('task/categorize', this.apikey, params, (err, json) => {
postrequest('task/categorize', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -125,3 +121,3 @@ });

validatePayload('transcription', params);
postrequest('task/transcription', this.apikey, params, (err, json) => {
postrequest('task/transcription', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -133,3 +129,3 @@ });

validatePayload('phonecall', params);
postrequest('task/phonecall', this.apikey, params, (err, json) => {
postrequest('task/phonecall', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -141,3 +137,3 @@ });

validatePayload('comparison', params);
postrequest('task/comparison', this.apikey, params, (err, json) => {
postrequest('task/comparison', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -149,3 +145,3 @@ });

validatePayload('annotation', params);
postrequest('task/annotation', this.apikey, params, (err, json) => {
postrequest('task/annotation', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -157,3 +153,3 @@ });

validatePayload('datacollection', params);
postrequest('task/datacollection', this.apikey, params, (err, json) => {
postrequest('task/datacollection', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -165,3 +161,3 @@ });

validatePayload('audiotranscription', params);
postrequest('task/audiotranscription', this.apikey, params, (err, json) => {
postrequest('task/audiotranscription', this.apiKey, params, (err, json) => {
if(cb) cb(err, new Task(this, json));

@@ -204,3 +200,3 @@ });

function getrequest(endpoint, apikey, params, cb) {
function getrequest(endpoint, apiKey, params, cb) {
request.get({

@@ -211,3 +207,3 @@ url: SCALE_ENDPOINT + endpoint,

auth: {
user: apikey,
user: apiKey,
pass: '',

@@ -225,3 +221,3 @@ sendImmediately: true

function postrequest(endpoint, apikey, payload, cb) {
function postrequest(endpoint, apiKey, payload, cb) {
request.post({

@@ -231,3 +227,3 @@ url: SCALE_ENDPOINT + endpoint,

auth: {
user: apikey,
user: apiKey,
pass: '',

@@ -237,7 +233,11 @@ sendImmediately: true

}, function(error, response, body) {
var err = null;
if (error || response.statusCode != 200) {
err = new ScaleException(body['error'], response.statusCode);
try {
var err = null;
if (error || response.statusCode != 200) {
err = new ScaleException(body['error'], response.statusCode);
}
if (cb) cb(err, body);
} catch (e) {
if (cb) cb(e, body);
}
if (cb) cb(err, body);
});

@@ -244,0 +244,0 @@ }

{
"scripts": {
"test": "utils/test"
"test": "mocha test"
},

@@ -25,3 +25,3 @@ "dependencies": {

"description": "Official Node SDK for Scale API",
"version": "1.0.0",
"version": "2.0.0",
"main": "lib/scaleapi.js",

@@ -48,3 +48,3 @@ "directories": {

],
"author": "Scale Inc",
"author": "Scale Labs, Inc.",
"license": "MIT",

@@ -51,0 +51,0 @@ "bugs": {

# scaleapi-node
Official Node SDK for Scale API
Official Node.js SDK for Scale API
## Installation
`npm install scaleapi --save`
## Documentation
For most up-to-date and accurate documentation, please see our [API Reference](https://docs.scaleapi.com) page.

@@ -7,7 +7,7 @@ /* eslint-env mocha */

var expect = chai.expect;
var testApiKey = process.env.SCALE_TEST_API_KEY;
var testApiKey = process.env.SCALE_API_TEST_KEY;
if (!testApiKey) throw new Error('Please set the environment variable SCALE_API_TEST_KEY.');
var client = new scaleapi.ScaleClient({apikey: testApiKey});
var client = new scaleapi.ScaleClient(testApiKey);

@@ -251,3 +251,3 @@ describe('task creation', () => {

var taskids = tasks.map(task => task.id);
var retrievedTaskIds = res.map(task => task.id);
var retrievedTaskIds = res.docs.map(task => task.id);
expect(taskids).to.have.members(retrievedTaskIds);

@@ -254,0 +254,0 @@ done();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc