Skip to content

approveapi/approveapi-swagger-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

approveapi-swagger-js

ApproveapiSwaggerJs - JavaScript client for approveapi-swagger-js The simple API to request a user's approval on anything via email + sms. This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1
  • Package version: 1
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install approveapi-swagger-js --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your approveapi-swagger-js from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('approveapi-swagger-js') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/approveapi-swagger-js then install it via:

    npm install YOUR_USERNAME/approveapi-swagger-js --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var ApproveapiSwaggerJs = require('approveapi-swagger-js');

var defaultClient = ApproveapiSwaggerJs.ApiClient.instance;

// Configure HTTP basic authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.username = 'YOUR USERNAME'
apiKey.password = 'YOUR PASSWORD'

var api = new ApproveapiSwaggerJs.ApproveApi()

var user = "user_example"; // {String} The user to send the approval request to. Can be either an email address or a phone number.

var body = "body_example"; // {String} The body of the approval request to show the user.

var opts = { 
  'title': "title_example", // {String} The title of an approval request. Defaults to an empty string.
  'approve_text': "approve_text_example", // {String} The approve action text. Defaults to 'Approve'.
  'reject_text': "reject_text_example", // {String} The reject action text. Defaults to 'Reject'.
  'long_poll': true // {Boolean} If true, the request waits (long-polls) until the user responds to the prompt or more than 10 minutes pass. Defaults to false.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.createPrompt(user, body, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://virtserver.swaggerhub.com/rejberg/ApproveAPI/1

Class Method HTTP request Description
ApproveapiSwaggerJs.ApproveApi createPrompt POST /prompt Sending a prompt
ApproveapiSwaggerJs.ApproveApi getPrompt GET /prompt/{id} Retrieve a prompt
ApproveapiSwaggerJs.ApproveApi getPromptStatus GET /prompt/{id}/status Check prompt status

Documentation for Models

Documentation for Authorization

apiKey

  • Type: HTTP basic authentication

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published