Skip to content

Commit

Permalink
build: use rollup to build esm, cjs, and browser bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati authored Aug 30, 2019
2 parents 0e8ba7a + 2437eaf commit 58a7fa7
Show file tree
Hide file tree
Showing 27 changed files with 3,622 additions and 5,772 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"@babel/plugin-proposal-object-rest-spread",
"@babel/transform-async-to-generator"
]
}
}
1 change: 0 additions & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

50 changes: 39 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ npm install @typeform/api-client --save
### Initialize

1. Import client library

``` javascript
// If using ESM syntax
import { createClient } from '@typeform/api-client'
// If using CJS syntax
const { createClient } = require('@typeform/api-client')
```

2. Create an instance with your personal token

``` javascript
const typeformAPI = createClient({
token: '<your token>'
})
```

3. Use any of the methods available in the [reference](#reference)

``` javascript
// will retrieve all forms
typeformAPI
Expand All @@ -63,16 +69,19 @@ npm install @typeform/api-client --save

## Reference

#### `createClient({token})`
### `createClient({token})`

- Creates a new instance of Typeform's JS client
- Returns an instance with the methods described below

``` javascript
const typeformClient = createClient({
token: '<your token>'
})
```

Client returns the following properties:

- `forms`
- `images`
- `teams`
Expand All @@ -83,39 +92,48 @@ Client returns the following properties:

Each one of them encapsulates the operations related to it (like listing, updating, deleting the resource).

### Forms
### Forms

#### `forms.list({ page: 1, pageSize = 10, search = '', page })`

- Get a list of your typeforms
- Returns a list of typeforms with the payload [referenced here](https://developer.typeform.com/create/reference/retrieve-forms/).

#### `forms.get({ uid })`

- Get a typeform by UID
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/retrieve-form/).

#### `forms.create({ data = {} })`

- Create a typeform
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/create-form/).

#### `forms.update({ uid, data = {}, override = false })`

- Update a typeform by UID
- Returns a typeform with the payload [referenced here](https://developer.typeform.com/create/reference/update-form/).

#### `forms.delete({ uid })`

- Deletes a typeform by UID

#### `forms.messages.get({ uid })`

- Get custom messages of the typeform with the given UID

#### `forms.messages.update({ uid })`

- Updates custom messages of the typeform with the given UID

### Images

#### `images.list()`

- Get your images collection

#### `images.get({ id, size, backgroundSize, choiceSize })`

- Get custom image by ID
- `size`: default, thumbnail, mobile
- `backgroundSize`: default, thumbnail, mobile, tablet
Expand All @@ -129,42 +147,51 @@ Each one of them encapsulates the operations related to it (like listing, updati
- `fileName`: File name for the image

#### `images.delete({ id })`

- Deletes an image with the given ID

### Teams

#### `teams.get({ id })`

- Gets team information for the given ID

#### `teams.addMembers({ id, members })`

- Add members to a team for the given ID
- `members`: `string` or an `array` and should be the email for the user
- Adding multiple members at once is possible using an array of emails

#### `teams.removeMembers({ id, members })`

- Remove members to a team for the given ID
- `members`: `string` or an `array` and should be the email for the user
- Deleting multiple members at once is possible using an array of emails

### Themes

#### `themes.list({ page, pageSize })`

- Gets your themes collection
- `page`: default `1`
- `pageSize: default `10`
- `pageSize: default `10`

#### `themes.get({ id })`

- Gets a theme for the given ID

#### `themes.create({ background, colors, font, hasTransparentButton, name })`

- Creates a theme with the given configuration
- See more details of the payload in [the documentation](https://developer.typeform.com/create/reference/create-theme/)

#### `themes.update({ background, colors, font, hasTransparentButton, name })`

- Updates a theme with the given configuration
- See more details of the payload in [the documentation](https://developer.typeform.com/create/reference/update-theme/)

#### `themes.delete({ id })`

- Deletes the theme with the given ID

### Workspaces
Expand Down Expand Up @@ -275,7 +302,7 @@ Each one of them encapsulates the operations related to it (like listing, updati

## Examples

##### Update specific typeform property, as [referenced here](https://developer.typeform.com/create/reference/update-form-patch/)
### Update specific typeform property, as [referenced here](https://developer.typeform.com/create/reference/update-form-patch/)

``` javascript
typeformClient
Expand All @@ -291,11 +318,11 @@ Each one of them encapsulates the operations related to it (like listing, updati
]
})
.then(response => {
//...
//...
})
```

##### Update the whole typeform
### Update the whole typeform

``` javascript
typeformClient
Expand All @@ -311,14 +338,15 @@ Each one of them encapsulates the operations related to it (like listing, updati
}
})
.then(response => {
//...
//...
})
```

**Note:**
The theme property applies a `theme` to the form. If you don't specify a value for the 'theme' property, Typeform applies a new copy of the default theme to the form, **even if you already have a copy of the default theme applied to this form**.

##### Uploading an image
### Uploading an image

``` javascript
typeformClient
.images
Expand All @@ -333,7 +361,7 @@ The theme property applies a `theme` to the form. If you don't specify a value f

```

##### Getting the thumbnail of an image
### Getting the thumbnail of an image

``` javascript
typeformClient
Expand All @@ -345,7 +373,7 @@ The theme property applies a `theme` to the form. If you don't specify a value f

```

### Testing
## Testing

To run unit tests.

Expand All @@ -357,6 +385,6 @@ yarn test:unit

```

### Suggestions or feedback?
## Suggestions or feedback

Fill out this [conversation](https://bit.ly/2wmzCXi) 🙂
Loading

0 comments on commit 58a7fa7

Please sign in to comment.