Table of Contents
This API allows to create, view, update, and delete downloads.
Download Properties #
Attribute | Type | Description |
download_id | integer | Unique identifier for the object. ( Read-Only ) |
download_title | string | Title of the Download. |
download_status | string | Status of the coupon. Only works if the status is published. |
download_author | integer | ID of the user. |
download_date | date | Created date of download. |
download_date_gmt | date | Created date of download in GTM. |
download_metas | array | Download meta data. |
Coupon_metas
Attribute | Type | Description |
download_featured_image | integer | ID of media to be used as featured image. |
download_media_id | string | ID of media for the download attachment. |
download_caption | string | Download Caption. |
Add Download #
This API helps to add new downloads.
POST
/wp-json/wptravel/v1/add-trip-download
curl --location 'https://example.com/wp-json/wptravel/v1/add-trip-download' \
--header 'Authorization: Basic <application-key>' \
--form 'download_title="Download"' \
--form 'download_featured_image="1"' \
--form 'download_media_id="1"' \
--form 'download_caption="Download"'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic <application-key>");
var formdata = new FormData();
formdata.append("download_title", "Download");
formdata.append("download_featured_image", "1");
formdata.append("download_media_id", "1");
formdata.append("download_caption", "Download");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://example.com/wp-json/wptravel/v1/add-trip-download", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Basic <application-key>'
];
$options = [
'multipart' => [
[
'name' => 'download_title',
'contents' => 'Download'
],
[
'name' => 'download_featured_image',
'contents' => '1'
],
[
'name' => 'download_media_id',
'contents' => '1'
],
[
'name' => 'download_caption',
'contents' => 'Download'
]
]];
$request = new Request('POST', 'https://example.com/wp-json/wptravel/v1/add-trip-download', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
Update Download #
This API helps to update downloads by ID.
POST
/wp-json/wptravel/v1/update-trip-download/38
curl --location 'https://example.com/wp-json/wptravel/v1/update-trip-download/38' \
--header 'Authorization: Basic <application-key>' \
--form 'download_title="asdasdasdasdsad"' \
--form 'download_featured_image="1"' \
--form 'download_media_id="1"' \
--form 'download_caption="Download"'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic <application-key>");
var formdata = new FormData();
formdata.append("download_title", "asdasdasdasdsad");
formdata.append("download_featured_image", "1");
formdata.append("download_media_id", "1");
formdata.append("download_caption", "Download");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://example.com/wp-json/wptravel/v1/update-trip-download/38", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Basic <application-key>'
];
$options = [
'multipart' => [
[
'name' => 'download_title',
'contents' => 'asdasdasdasdsad'
],
[
'name' => 'download_featured_image',
'contents' => '1'
],
[
'name' => 'download_media_id',
'contents' => '1'
],
[
'name' => 'download_caption',
'contents' => 'Download'
]
]];
$request = new Request('POST', 'https://example.com/wp-json/wptravel/v1/update-trip-download/38', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
Delete Download #
This API helps to delete downloads by ID.
DELETE
/wp-json/wptravel/v1/delete-trip-download/38
curl --location --request DELETE 'https://example.com/wp-json/wptravel/v1/delete-trip-download/39' \
--header 'Authorization: Basic <application-key>'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic <application-key>");
var requestOptions = {
method: 'DELETE',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://example.com/wp-json/wptravel/v1/delete-trip-download/39", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Basic <application-key>'
];
$request = new Request('DELETE', 'https://example.com/wp-json/wptravel/v1/delete-trip-download/39', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
Get Download #
This API helps to get a download by ID.
GET
/wp-json/wptravel/v1/get-trip-download/38
curl --location 'https://example.com/wp-json/wptravel/v1/get-trip-download/38'
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://example.com/wp-json/wptravel/v1/get-trip-download/38", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$client = new Client();
$request = new Request('GET', 'https://example.com/wp-json/wptravel/v1/get-trip-download/38');
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
JSON Response
{
"download_id": 38,
"download_title": "Test Download",
"download_status": "publish",
"download_author": "0",
"download_date": "2023-04-04 06:56:29",
"download_date_gmt": "2023-04-04 06:56:29",
"download_featured_image": "1",
"download_metas": {
"media_id": "1",
"caption": "asdasdasdsad"
}
}
Get All Downloads #
This API helps to get all Downloads.
GET
/wp-json/wptravel/v1/get-all-trip-download
curl --location 'https://example.com/wp-json/wptravel/v1/get-all-trip-download'
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://example.com/wp-json/wptravel/v1/get-all-trip-download", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$client = new Client();
$request = new Request('GET', 'https://example.com/wp-json/wptravel/v1/get-all-trip-download');
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
JSON Response
[
{
"download_id": 38,
"download_title": "test download",
"download_status": "publish",
"download_author": "0",
"download_date": "2023-04-04 06:56:29",
"download_date_gmt": "2023-04-04 06:56:29",
"download_featured_image": "",
"download_metas": {
"media_id": "",
"caption": "download"
}
},
{
"download_id": 10,
"download_title": "test download two",
"download_status": "publish",
"download_author": "1",
"download_date": "2023-03-31 07:40:27",
"download_date_gmt": "2023-03-31 07:40:27",
"download_featured_image": "179",
"download_metas": {
"media_id": "177",
"caption": "download two"
}
}
]