-
Notifications
You must be signed in to change notification settings - Fork 4
/
country.php
123 lines (107 loc) · 3.82 KB
/
country.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
include_once 'layout/head.php';
include_once 'layout/header.php';
include_once 'endpoints/getToken.php';
$ch = curl_init();
$iso = isset($_GET['iso'])?$_GET['iso']:null;
curl_setopt($ch, CURLOPT_URL, "https://topups.reloadly.com/countries/".$iso);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type:application/json",
"Authorization: Bearer ".$tokenResponse->access_token
));
$response = curl_exec($ch);
curl_close($ch);
$country = json_decode($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://topups.reloadly.com/operators/countries/".$iso);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type:application/json",
"Authorization: Bearer ".$tokenResponse->access_token
));
$response = curl_exec($ch);
curl_close($ch);
$operatorsResponse = json_decode($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://topups.reloadly.com/promotions/country-codes/".$iso);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type:application/json",
"Authorization: Bearer ".$tokenResponse->access_token
));
$response = curl_exec($ch);
curl_close($ch);
$promotionsResponse = json_decode($response);
?>
<main role="main" class="flex-shrink-0">
<div class="container pt-5 mt-5">
<div class="col">
<div class="mb-2 row justify-content-center">
<h2>Country Description</h2>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>isoName :</td>
<td><?=$country->isoName?></td>
</tr>
<tr>
<td>name : </td>
<td><?=$country->name?></td>
</tr>
<tr>
<td>currencyCode : </td>
<td><?=$country->currencyCode?></td>
</tr>
<tr>
<td>currencyName : </td>
<td><?=$country->currencyName?></td>
</tr>
<tr>
<td>currencySymbol : </td>
<td><?=$country->currencySymbol?></td>
</tr>
<tr>
<td>flag : </td>
<td><img src="<?=$country->flag?>" width="20px"></td>
</tr>
<tr>
<td>callingCodes : </td>
<td>
<?php foreach ($country->callingCodes as $code) echo $code.' '; ?>
</td>
</tr>
</tbody>
</table>
<div class="my-2 row justify-content-center">
<h2>Operators</h2>
</div>
<div class="row">
<?php foreach($operatorsResponse as $operator) { ?>
<a href="operator.php?id=<?=$operator->operatorId?>" class="col-4"><?=$operator->name?> [ <?=$operator->destinationCurrencyCode?> ]</a>
<? } ?>
</div>
<div class="my-2 row justify-content-center">
<h2>Promotions</h2>
</div>
<div class="row">
<?php foreach($promotionsResponse as $promotion) { ?>
<a href="promotion.php?id=<?=$promotion->promotionId?>" class="col-12"><?=$promotion->title?></a>
<? } ?>
</div>
</div>
</div>
</main>
<?php
include_once 'layout/footer.php';
?>