Skip to content

Commit 6e160c3

Browse files
author
Tony Bedford
authored
Merge pull request Vonage#82 from Nexmo/tony-reports-cs
Initial versions of Reports API v2 code snippets
2 parents 18973a3 + a1c2284 commit 6e160c3

24 files changed

+184
-21
lines changed

config.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ WEBHOOK_URL=${WEBHOOK_URL:-""}
8282
# MMS
8383
IMG_URL=${IMG_URL:-""}
8484

85-
# Reporting
86-
REPORT_PRODUCT=${REPORT_PRODUCT:-""}
87-
REPORT_ID=${REPORT_ID:-""}
88-
REPORT=${REPORT_URL:-""}
85+
# Reports v2 API
86+
ACCOUNT_ID=${ACCOUNT_ID:-""}
87+
DATE_START=${DATE_START:-""}
88+
DATE_END=${DATE_END:-""}
89+
REPORT_DIRECTION=${DIRECTION:-""}
90+
REPORT_PRODUCT=${PRODUCT:-""}
91+
REPORT_STATUS=${REPORT_STATUS:-""}
92+
ID=${ID:-""}
93+
REQUEST_ID=${REQUEST_ID:-""}
94+
FILE_ID=${FILE_ID:-""}
95+
TYPE=${TYPE:-""}
96+
INCLUDE_SUBACCOUNTS=${INCLUDE_SUBACCOUNTS:-""}
97+
INCLUDE_MESSAGE=${INCLUDE_MESSAGE:-""}
98+
STATUS=${STATUS:-""}
8999

90100
# Verify
91101
REQUEST_ID=${REQUEST_ID:-""}

reporting/check-report-status.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

reporting/create-report.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

reporting/download-report.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

reports/cancel-report.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -X DELETE -u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
6+
"https://api.nexmo.com/v2/reports/$REQUEST_ID"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -X POST "https://api.nexmo.com/v2/reports" \
6+
-H 'Content-Type: application/json; charset=utf-8' \
7+
-u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
8+
-d $'{
9+
"product": "CONVERSATIONS",
10+
"account_id": "'$ACCOUNT_ID'",
11+
"type": "'$TYPE'"
12+
}'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -G --data-urlencode date_start=$DATE_START --data-urlencode date_end=$DATE_END -u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
6+
"https://api.nexmo.com/v2/reports/records?account_id=$ACCOUNT_ID&product=CONVERSATIONS&type=$TYPE"

reports/create-async-report.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -X POST "https://api.nexmo.com/v2/reports" \
6+
-H 'Content-Type: application/json; charset=utf-8' \
7+
-u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
8+
-d $'{
9+
"product": "'$REPORT_PRODUCT'",
10+
"account_id": "'$ACCOUNT_ID'",
11+
"direction": "'$REPORT_DIRECTION'",
12+
"status": "'$STATUS'",
13+
"date_start": "'$DATE_START'",
14+
"date_end": "'$DATE_END'"
15+
}'

reports/get-report-status.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
6+
"https://api.nexmo.com/v2/reports/$REQUEST_ID"

reports/get-report.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
source "../config.sh"
4+
5+
curl -o report.zip -u "$NEXMO_API_KEY:$NEXMO_API_SECRET" \
6+
"https://api.nexmo.com/v3/media/$FILE_ID"

0 commit comments

Comments
 (0)