Skip to content

Complete rewrite #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JF_APIKEY=Api key that is going to be used for tests.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"no-unused-vars": "off",
"@typescript-eslint/ban-types": "off" // https://github.com/microsoft/TypeScript/issues/21732
}
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules/
node_modules/
dist/
coverage/
.nyc_output/
.env
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!/dist/**/*
!/esm/**/*
*.tsbuildinfo
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 2,
"singleQuote": true,
"jsxBracketSameLine": true,
"trailingComma": "es5"
}
38 changes: 38 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: v1.0
name: '@Jotform/SDK'
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: Build & Test
task:
jobs:
- name: Build & Unit Tests
commands:
- checkout
- sem-version node 12
- cache restore
- npm install
- cache store
- npm run build --if-present
- echo JF_APIKEY=$JF_APIKEY >> .env
- npm test
secrets:
- name: JF_APIKEY
dependencies: []
- name: NPM Deploy
run:
when: tag =~ '.*'
dependencies:
- Build & Test
task:
secrets:
- name: NPM
jobs:
- name: Deploy
commands:
- echo //registry.npmjs.org/:_authToken=$NPM_SECRET >> .npmrc
- echo email=berkcan@vivaldi.net >> .npmrc
- echo always-auth=true >> .npmrc
- npm publish
339 changes: 0 additions & 339 deletions LICENSE

This file was deleted.

674 changes: 674 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

97 changes: 75 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,92 @@
jotform-api-nodejs
===============
[JotForm API](http://api.jotform.com/docs/) - NodeJS Client
<p align="center">
<img src="https://www.jotform.com/resources/assets/logo-nb/jotform-logo-transparent-400x100.png" alt="logo" height="70">
<br />
<a href='https://berkcan.semaphoreci.com/badges/jotform-nodejs-sdk/branches/master.svg'> <img src='https://berkcan.semaphoreci.com/badges/jotform-nodejs-sdk/branches/master.svg' alt='Build Status'></a>
</p>
<br />

# Jotform Node.js SDK

> Jotform's Node.js SDK.

- [x] First class TypeScript support.
- [x] Promise based.

#

### Installation

```sh
$ npm install jotform
```

### Documentation
#

### Usage

- Initialize the SDK.

You can find the docs for the API of this client at [http://api.jotform.com/docs/](http://api.jotform.com/docs)
```ts
import { Jotform } from 'jotform';

### Authentication
const JF = new Jotform();
```

- Authenticate with Jotform.

JotForm API requires API key for all user related calls. You can create your API Keys at [API section](http://www.jotform.com/myaccount/api) of My Account page.
```ts
JF.initializeSDK(
'your-api-key',
'Jotform Instance (US, EU or HIPAA - defaults to US)'
);
```

### Examples
- Simple examples.

```javascript
var jotform = require("jotform")
```ts
JF.user
.getUser()
.then((response: object) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
```

jotform.options({
debug: true,
apiKey: "YOUR_API_KEY"
});
```ts
const data = {
questions: {
'1': {
type: 'control_head',
text: 'Text 1',
order: '1',
name: 'Header1',
},
'2': {
type: 'control_head',
text: 'Text 2',
order: '2',
name: 'Header2',
},
},
};

jotform.getUser()
.then(function(r){
/* successful response after request */
})
.fail(function(e){
/* handle error */
}
JF.form
.addNewQuestionToForm(formId, data)
.then((response: object) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
```

See [Documentation](http://api.jotform.com) for full list of methods available.
- Detailed information of API: [https://api.jotform.com/docs](https://api.jotform.com/docs).
- Properties reference: [https://api.jotform.com/docs/properties/index.php](https://api.jotform.com/docs/properties/index.php)

#

### License

- This project is under the [GPLv3 license](LICENSE.md). Copyright (c) 2021 Jotform and it's contributors.
Loading