Skip to content

Commit d00ebac

Browse files
committed
add proper structure for code snippets
1 parent c311011 commit d00ebac

File tree

12 files changed

+162
-0
lines changed

12 files changed

+162
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type: standalone
2+
languages:
3+
- json
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"meta": {
3+
"next": "dW5kZWZpbmVkOjQwOTczNTgxNTg=",
4+
"previous": "null",
5+
"perPage": 49
6+
}
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: standalone
2+
languages:
3+
- js
4+
- php
5+
- sh
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const https = require('https')
2+
3+
const use_cursor = true;
4+
const perPage = 50;
5+
const options = {
6+
hostname: 'api.paystack.co',
7+
port: 443,
8+
path: `/transaction?use_cursor=${use_cursor}&perPage=${perPage}`,
9+
method: 'GET',
10+
headers: {
11+
Authorization: 'Bearer YOUR_SECRET_KEY'
12+
}
13+
}
14+
15+
https.request(options, res => {
16+
let data = ''
17+
18+
res.on('data', (chunk) => {
19+
data += chunk
20+
});
21+
22+
res.on('end', () => {
23+
console.log(JSON.parse(data))
24+
})
25+
}).on('error', error => {
26+
console.error(error)
27+
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
$use_cursor = true;
3+
$perPage = 50;
4+
$curl = curl_init();
5+
6+
curl_setopt_array($curl, array(
7+
CURLOPT_URL => "https://api.paystack.co/transaction?use_cursor=$use_cursor&perPage=$perPage",
8+
CURLOPT_RETURNTRANSFER => true,
9+
CURLOPT_ENCODING => "",
10+
CURLOPT_MAXREDIRS => 10,
11+
CURLOPT_TIMEOUT => 30,
12+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13+
CURLOPT_CUSTOMREQUEST => "GET",
14+
CURLOPT_HTTPHEADER => array(
15+
"Authorization: Bearer YOUR_SECRET_KEY",
16+
"Cache-Control: no-cache",
17+
),
18+
));
19+
20+
$response = curl_exec($curl);
21+
$err = curl_error($curl);
22+
23+
curl_close($curl);
24+
25+
if ($err) {
26+
echo "cURL Error #:" . $err;
27+
} else {
28+
echo $response;
29+
}
30+
?>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
use_cursor="true"
3+
perPage="50"
4+
url="https://api.paystack.co/transaction?use_cursor=$use_cursor&perPage=$perPage"
5+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
6+
7+
curl "$url" -H "$authorization" -X GET
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TODO: Work on handling multiple non-response JSON
2+
type: standalone
3+
languages:
4+
- json
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"meta": {
3+
"total": 7316,
4+
"total_volume": 397800,
5+
"skipped": 0,
6+
"perPage": 50,
7+
"page": 1,
8+
"pageCount": 147
9+
}
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: standalone
2+
languages:
3+
- js
4+
- php
5+
- sh
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const https = require('https')
2+
3+
const page = 1;
4+
const perPage = 50;
5+
const options = {
6+
hostname: 'api.paystack.co',
7+
port: 443,
8+
path: `/transaction?page=${page}&perPage=${perPage}`,
9+
method: 'GET',
10+
headers: {
11+
Authorization: 'Bearer SECRET_KEY'
12+
}
13+
}
14+
15+
https.request(options, res => {
16+
let data = ''
17+
18+
res.on('data', (chunk) => {
19+
data += chunk
20+
});
21+
22+
res.on('end', () => {
23+
console.log(JSON.parse(data))
24+
})
25+
}).on('error', error => {
26+
console.error(error)
27+
})

0 commit comments

Comments
 (0)