Skip to content

Commit

Permalink
Merge branch 'master' into add-url-param-to-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
olexandr-mazepa authored Jan 26, 2024
2 parents 360b867 + dead251 commit 58f4224
Show file tree
Hide file tree
Showing 78 changed files with 1,585 additions and 488 deletions.
76 changes: 52 additions & 24 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,62 @@ on:
- main

jobs:
on-pull-request:
name: test
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
lint:
name: lint
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/hydrogen
- uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Print node version
run: node -v
- name: Install dependencies
run: npm ci

- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
test:
name: Test
strategy:
matrix:
node-version: [18.x, 20.x]
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run linter
run: npm run lint
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run build
run: npm run build
- name: Print node version
run: node -v

- name: Run tests
run: npm test
- name: Install dependencies
run: npm ci

- name: Show expected changes in the changelog file
run: npm run release:test
- name: Run build
run: npm run build

- name: Run tests
run: npm test

- name: Show expected changes in the changelog file
run: npm run release:test
changelog:
name: Changelog check
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Print node version
run: node -v
- name: Install dependencies
run: npm ci
- name: Show expected changes in the changelog file
run: npm run release:test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build

./test.js
.coverage/
.nvmrc
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [10.0.1](https://github.com/mailgun/mailgun.js/compare/v10.0.0...v10.0.1) (2024-01-26)


### Bug Fixes

* Update vulnerable version of lodash.set ([cf6c8e9](https://github.com/mailgun/mailgun.js/commits/cf6c8e96a9e6bdb2dd1682ee703ee29c4024da6f))

## [10.0.0](https://github.com/mailgun/mailgun.js/compare/v9.4.1...v10.0.0) (2024-01-18)


### Bug Fixes

* Run npm audit fix ([dee7b00](https://github.com/mailgun/mailgun.js/commits/dee7b00060aafeec579294ce2b6a83a17ce5dae7))


### Breaking changes

* Update minimaly supported version of Node.js ([5121d8a](https://github.com/mailgun/mailgun.js/commits/5121d8ac9817081d33c5dbf2db0eedef634eb627))


### Other changes

* Update CI to decrease linter noise ([f89bbf1](https://github.com/mailgun/mailgun.js/commits/f89bbf189f1d6d2071c650b03bd69b2e69147d5d))

### [9.4.1](https://github.com/mailgun/mailgun.js/compare/v9.4.0...v9.4.1) (2024-01-04)


### Bug Fixes

* Filename is not respected for attachments with type string ([7e2cd18](https://github.com/mailgun/mailgun.js/commits/7e2cd18dd273053bcc7067070080afba5e38730f))
* Update condition in tests ([72ecbaa](https://github.com/mailgun/mailgun.js/commits/72ecbaa0c98c080e7f06029ad25d8552c8a80d7e))


### Other changes

* Update CI to run on multiple node versions ([b0e9ae0](https://github.com/mailgun/mailgun.js/commits/b0e9ae08840ab53e33c03d985971ea4a4db139ae))

## [9.4.0](https://github.com/mailgun/mailgun.js/compare/v9.3.0...v9.4.0) (2023-12-13)


### Features

* Add subaccounts ([3ca1d56](https://github.com/mailgun/mailgun.js/commits/3ca1d56955f7651bcba758c75cdbee3be48d5748))


### Bug Fixes

* **deps-dev:** bump @babel/traverse from 7.22.5 to 7.23.2 ([53f3e8f](https://github.com/mailgun/mailgun.js/commits/53f3e8fd673857b75ab0844bb1e04e016dad6ed5))
* **deps:** bump axios from 1.3.3 to 1.6.0 ([729032d](https://github.com/mailgun/mailgun.js/commits/729032d7a19ec307255c401bd698f5e7835925fb))


### Other changes

* Update the formatting, merge headers to avoid overriding ([6e46eca](https://github.com/mailgun/mailgun.js/commits/6e46ecac1742660673931a99735988e4ffb046ce))

## [9.3.0](https://github.com/mailgun/mailgun.js/compare/v9.2.1...v9.3.0) (2023-09-18)


Expand Down
131 changes: 128 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __Table of Contents__
- [Install](#install)
- [Setup Client](#setup-client)
- [Available Imports](#imports)
- [Using Subaccounts](#using-subaccounts)
- [Types imports](#types-imports)
- [Interfaces and Enums imports](#interfaces-and-enums-imports)
- [Generated docs](#generated-docs)
Expand All @@ -27,7 +28,7 @@ __Table of Contents__

## Install

- Requires node.js >= 12.x
- Requires node.js >= 18.x

Install mailgun.js with:

Expand Down Expand Up @@ -58,6 +59,17 @@ Once the package is installed, you can import the library using `import` or `req
const mailgun = new Mailgun(FormData);
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
```
### Using Subaccounts
Primary accounts can make API calls on behalf of their subaccounts. [API documentation](https://documentation.mailgun.com/en/latest/subaccounts.html#subaccounts)
```js
import * as FormData from 'form-data';
import Mailgun from 'mailgun.js';
const mailgun = new Mailgun(FormData);
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
mg.setSubaccount('subaccount-id');
// then, if you need to reset it back to the primary account:
mg.resetSubaccount();
```
### Types imports
Starting from version **9.0.0.** Types can be includes as named import:
```TS
Expand Down Expand Up @@ -154,6 +166,12 @@ The following service methods are available to instantiated clients. The example
- [createMembers](#createmembers)
- [updateMember](#updatemember)
- [destroyMember](#destroymember)
- [subaccounts](#subaccounts)
- [list](#list-6)
- [get](#get-8)
- [create](#create-7)
- [enable](#enable)
- [disable](#disable)
- [Navigation thru lists](#navigation-thru-lists)
- [Browser Demo](#browser-demo)
- [Development](#development)
Expand Down Expand Up @@ -2046,6 +2064,115 @@ A client to manage members within a specific mailing list.
message: 'Mailing list member has been deleted'
}
```
### Subaccounts

A client to manage subaccounts.

- #### list

`mg.subaccounts.list(query)` - [api docs](https://documentation.mailgun.com/en/latest/subaccounts.html)

Example:

```js
mg.subaccounts.list()
.then(subaccounts => console.log(subaccounts)) // logs array of subaccounts
.catch(err => console.error(err)); // logs any error
```

Promise returns: array of Subaccounts instances

```JS
[
{ id: "XYZ", name: "test.subaccount1", status: "open" },
{ id: "YYY", name: "test.subaccount2", status: "open" }
]
```

Query data may have next properties:

| Property | Description |
|:---------|:-----------------------------------------------------------------------|
| limit | Maximum number of records to return. (10 by default) |
| skip | Number of records to skip. (0 by default) |
| sort | "asc" or "desc". |
| enabled | Returns all enabled/disabled subaccounts. (Defaults to all if omitted) |

- #### get

`mg.subaccounts.get(subaccount_id)`

Example:

```JS
mg.subaccounts.get('123')
.then(subaccount => console.log(subaccount)) // logs subaccount object
.catch(err => console.error(err)); // logs any error
```

Promise returns: Subaccount instance

```JS
{ id: "123", name: "test.subaccount1", status: "open" }
```

- #### create

`mg.subaccounts.create(name)`

Example:

```js
mg.subaccounts.create('foobar')
.then(msg => console.log(msg)) // logs response data
.catch(err => console.error(err)); // logs any error
```

Promise returns: Subaccount instance

```JS
{ id: "123", name: "foobar", status: "open" }
```

Create method accepts data object with next properties:

| Parameter | Description |
|-------------|-----------------------------------------------------------|
| name | Name of the subaccount being created (ex. 'mysubaccount') |

- #### enable

`mg.subaccounts.enable(subaccount_id)`

Example:

```js
mg.subaccounts.enable('123')
.then(msg => console.log(msg)) // logs response data
.catch(err => console.error(err)); // logs any error
```
Promise returns: Subaccount instance

```JS
{ id: "123", name: "foobar", status: "open" }
```

- #### disable

`mg.subaccounts.disable(subaccount_id)`

Example:

```js
mg.subaccounts.disable('123')
.then(msg => console.log(msg)) // logs response data
.catch(err => console.error(err)); // logs any error
```
Promise returns: Subaccount instance

```JS
{ id: "123", name: "foobar", status: "disabled" }
```

## Navigation thru lists
Most of the methods that return items in a list support pagination.
Expand Down Expand Up @@ -2213,7 +2340,6 @@ A client to manage members within a specific mailing list.
);
```


## Browser Demo

![image](https://cloud.githubusercontent.com/assets/399776/10718632/e8fe56e4-7b34-11e5-84c8-cfcfde978711.png)
Expand Down Expand Up @@ -2290,4 +2416,3 @@ git pull
Next, run ```npm run release```.

After that, `cd ./dist` and then run ```npm login``` and ```npm publish``` to publish changes on npm.

55 changes: 55 additions & 0 deletions dist/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [10.0.1](https://github.com/mailgun/mailgun.js/compare/v10.0.0...v10.0.1) (2024-01-26)


### Bug Fixes

* Update vulnerable version of lodash.set ([cf6c8e9](https://github.com/mailgun/mailgun.js/commits/cf6c8e96a9e6bdb2dd1682ee703ee29c4024da6f))

## [10.0.0](https://github.com/mailgun/mailgun.js/compare/v9.4.1...v10.0.0) (2024-01-18)


### Bug Fixes

* Run npm audit fix ([dee7b00](https://github.com/mailgun/mailgun.js/commits/dee7b00060aafeec579294ce2b6a83a17ce5dae7))


### Breaking changes

* Update minimaly supported version of Node.js ([5121d8a](https://github.com/mailgun/mailgun.js/commits/5121d8ac9817081d33c5dbf2db0eedef634eb627))


### Other changes

* Update CI to decrease linter noise ([f89bbf1](https://github.com/mailgun/mailgun.js/commits/f89bbf189f1d6d2071c650b03bd69b2e69147d5d))

### [9.4.1](https://github.com/mailgun/mailgun.js/compare/v9.4.0...v9.4.1) (2024-01-04)


### Bug Fixes

* Filename is not respected for attachments with type string ([7e2cd18](https://github.com/mailgun/mailgun.js/commits/7e2cd18dd273053bcc7067070080afba5e38730f))
* Update condition in tests ([72ecbaa](https://github.com/mailgun/mailgun.js/commits/72ecbaa0c98c080e7f06029ad25d8552c8a80d7e))


### Other changes

* Update CI to run on multiple node versions ([b0e9ae0](https://github.com/mailgun/mailgun.js/commits/b0e9ae08840ab53e33c03d985971ea4a4db139ae))

## [9.4.0](https://github.com/mailgun/mailgun.js/compare/v9.3.0...v9.4.0) (2023-12-13)


### Features

* Add subaccounts ([3ca1d56](https://github.com/mailgun/mailgun.js/commits/3ca1d56955f7651bcba758c75cdbee3be48d5748))


### Bug Fixes

* **deps-dev:** bump @babel/traverse from 7.22.5 to 7.23.2 ([53f3e8f](https://github.com/mailgun/mailgun.js/commits/53f3e8fd673857b75ab0844bb1e04e016dad6ed5))
* **deps:** bump axios from 1.3.3 to 1.6.0 ([729032d](https://github.com/mailgun/mailgun.js/commits/729032d7a19ec307255c401bd698f5e7835925fb))


### Other changes

* Update the formatting, merge headers to avoid overriding ([6e46eca](https://github.com/mailgun/mailgun.js/commits/6e46ecac1742660673931a99735988e4ffb046ce))

## [9.3.0](https://github.com/mailgun/mailgun.js/compare/v9.2.1...v9.3.0) (2023-09-18)


Expand Down
Loading

0 comments on commit 58f4224

Please sign in to comment.