Skip to content

Update documentation for mailjet_apiv3_nodejs version v5 #37

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 2 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
44 changes: 44 additions & 0 deletions guides-sms/_export-sms_stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ https://api.mailjet.com/v4/sms/export \
-H 'Content-Type: application/json' \
-d '{"FromTS": 1033552800, "ToTS": 1033574400}'
```
```javascript
/**
* Create : Create a CSV export file with a list of SMS messages for a specific time period
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.post('sms', { version: 'v4' })
.action('export')
.request({
FromTS: 1033552800,
ToTS: 1033574400
})

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

A `POST` on the [`/sms/export`](/sms-api/v4/sms-export/) endpoint gives you the ability to request a CSV export file to be generated. With your request you are required to submit a specific timeframe using the `FromTS` and `ToTS` properties.

Expand Down Expand Up @@ -56,6 +79,27 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms/export/$ID
```
```javascript
/**
* View : Check the status of an export request and retrieve the download URL, if ready
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.action('export')
.id($ID)
.request()

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

Use `GET` on [`/sms/export/{RequestID}`](/sms-api/v4/sms-export/) to check the status of your export request, and to retrieve the download URL, once the export file is ready.

Expand Down
77 changes: 76 additions & 1 deletion guides-sms/_filtering-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ curl -s \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?Limit=100
```
```javascript
/**
* View : List of 100 SMS messages
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { Limit: 100 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```


You can limit the number of results by applying the <code>Limit</code> filter. The default value is 10 and the maximum value is 1000. `Limit=0` delivers the maximum amount of results - 1000.
Expand All @@ -39,6 +58,25 @@ curl -s \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?Offset=25000
```
```javascript
/**
* View : List of SMS messages with Offset, starting with the 25000th contact
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { Offset: 25000 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

You can use the <code>Offset</code> filter to retrieve a list starting from a certain offset.
<div></div>
Expand All @@ -50,6 +88,25 @@ curl -s \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?Limit=150\&Offset=25000
```
```javascript
/**
* View : List of SMS with Limit and Offset, retrieves a list of 150 SMS starting with the 25000th contact
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { Limit: 150, Offset: 25000 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

The <code>Offset</code> filter can be combined with the <code>Limit</code> filter.

Expand All @@ -64,7 +121,25 @@ curl -s \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?FromTS=1519862400\&ToTS=1520640000
```

```javascript
/**
* View : List of contacts sent between March 1st 2018 00:00 UTC and March 10th 2018 00:00 UTC
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { FromTS: 1519862400, ToTS: 1520640000 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

Use the `FromTS` and `ToTS` filters (Unix timestamp) to specify a time period, for which to retrieve the information you need.

Expand Down
20 changes: 20 additions & 0 deletions guides-sms/_getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ curl -X POST \
"Text": "Hello World!"
}'
```
```javascript
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.post('sms-send', { version: 'v4' })
.request({
From: "InfoSMS",
To: "+33600000000",
Text: "Hello World!"
})

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

Fill your sending information in the payload. Three properties are required:

Expand Down
23 changes: 23 additions & 0 deletions guides-sms/_send-sms-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ curl -X POST \
"From": "MJPilot"
}'
```
```javascript
/**
* Create : Send SMS Message to a selected recipient.
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.post('sms-send', { version: 'v4' })
.request({
From: "MJPilot",
To: "+33600000000",
Text: "Have a nice SMS flight with Mailjet !"
})

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

In the code sample you can see a `POST` request with an Authorization header that includes the token value.

Expand Down
97 changes: 97 additions & 0 deletions guides-sms/_sms-stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?FromTS=1033552800&ToTS=1033574400
```
```javascript
/**
* View : Retrieve a list of SMS messages sent during a specific time period
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { FromTS: 1033552800, ToTS: 1033574400 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

With `GET` on the [`/sms`](/sms-api/v4/sms/) endpoint you are able to view details for a list of existing messages - `Status`, `Cost`, `MessageID`, sender and recipient, `CreationTS` and `SentTS` timestamps etc.

Expand Down Expand Up @@ -70,6 +89,25 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?To=+33600000000
```
```javascript
/**
* View : Retrieve a list of SMS messages sent to a specific recipient
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { To: '+33600000000' })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

>API Response

Expand Down Expand Up @@ -128,6 +166,25 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms?StatusCode=1,2
```
```javascript
/**
* View : Retrieve a list of SMS messages that were successfully sent, or are being currently sent
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.request({}, { StatusCode: '1,2' })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

>API Response

Expand Down Expand Up @@ -208,6 +265,26 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms/744ecf8c-9fed-4ec9-acd0-9b326671f5df
```
```javascript
/**
* View : Retrieve a specific SMS Message
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.id('744ecf8c-9fed-4ec9-acd0-9b326671f5df') // your id
.request()

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

>API Response

Expand Down Expand Up @@ -247,6 +324,26 @@ curl -s -X GET \
-H "Authorization: Bearer $MJ_TOKEN" \
https://api.mailjet.com/v4/sms/count?FromTS=1033552800&ToTS=1033574400
```
```javascript
/**
* View : Retrieve the number of SMS messages that were processed within a specific timeframe
* */
const mailjet = require('node-mailjet')
.smsConnect(process.env.MJ_API_TOKEN)

const request = mailjet
.get('sms', { version: 'v4' })
.action('count')
.request({}, { FromTS: 1033552800, ToTS: 1033574400 })

request
.then((result) => {
console.log(result.body)
})
.catch((err) => {
console.log(err.statusCode)
})
```

>API Response

Expand Down
Loading