├── .gitignore ├── screen ├── tinker.PNG └── php-test.PNG ├── src ├── Meta │ ├── Meta.php │ └── Action.php ├── Response │ ├── WalletResponse.php │ ├── CustomerResponse.php │ ├── TransferResponse.php │ ├── BalanceResponse.php │ ├── DefaultResponse.php │ ├── LoginAuthResponse.php │ ├── LoginEmailResponse.php │ └── LoginPhoneResponse.php ├── helper │ └── function.php ├── ParseResponse.php ├── HTTP │ └── Curl.php └── GojekID.php ├── composer.json ├── LICENSE ├── tests └── GojekTest.php └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | index.php 3 | composer.lock 4 | -------------------------------------------------------------------------------- /screen/tinker.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maulana20/gojekid/HEAD/screen/tinker.PNG -------------------------------------------------------------------------------- /screen/php-test.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maulana20/gojekid/HEAD/screen/php-test.PNG -------------------------------------------------------------------------------- /src/Meta/Meta.php: -------------------------------------------------------------------------------- 1 | qrId = $res->data->qr_id; 11 | } 12 | 13 | public function getQrId() 14 | { 15 | return $this->qrId; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/CustomerResponse.php: -------------------------------------------------------------------------------- 1 | result = $res->customer; 11 | } 12 | 13 | public function getResult() 14 | { 15 | return $this->result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/TransferResponse.php: -------------------------------------------------------------------------------- 1 | ref = $res->data->transaction_ref; 11 | } 12 | 13 | public function getRef() 14 | { 15 | return $this->ref; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/BalanceResponse.php: -------------------------------------------------------------------------------- 1 | balance = $res->data->balance; 11 | } 12 | 13 | public function getBalance() 14 | { 15 | return $this->balance; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/DefaultResponse.php: -------------------------------------------------------------------------------- 1 | result = isset($res->data) ? $res->data : $res; 11 | } 12 | 13 | public function getResult() 14 | { 15 | return $this->result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/LoginAuthResponse.php: -------------------------------------------------------------------------------- 1 | authToken = $res->data->access_token; 11 | } 12 | 13 | public function getAuthToken() 14 | { 15 | return $this->authToken; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/LoginEmailResponse.php: -------------------------------------------------------------------------------- 1 | loginToken = $res->data->login_token; 11 | } 12 | 13 | public function getLoginToken() 14 | { 15 | return $this->loginToken; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Response/LoginPhoneResponse.php: -------------------------------------------------------------------------------- 1 | loginToken = $res->data->login_token; 11 | } 12 | 13 | public function getLoginToken() 14 | { 15 | return $this->loginToken; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maulana20/gojekid", 3 | "description": "Un-Official Gojek API Wrapper", 4 | "type": "library", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Maulana Saputra", 9 | "email": "maulanasaputra11091082@gmail.com" 10 | } 11 | ], 12 | "autoload": { 13 | "files": [ 14 | "src/helper/function.php" 15 | ], 16 | "psr-4" : { 17 | "Maulana20\\": "src" 18 | } 19 | }, 20 | "require": { 21 | "php": "^7.0" 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit": "^7" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/helper/function.php: -------------------------------------------------------------------------------- 1 | 'Maulana20\Response\LoginEmailResponse', 13 | GojekID::BASE_ENDPOINT . Action::loginPhone => 'Maulana20\Response\LoginPhoneResponse', 14 | GojekID::BASE_ENDPOINT . Action::loginAuth => 'Maulana20\Response\LoginAuthResponse', 15 | GojekID::BASE_ENDPOINT . Action::checkBalance => 'Maulana20\Response\BalanceResponse', 16 | GojekID::BASE_ENDPOINT . Action::getCustomer => 'Maulana20\Response\CustomerResponse', 17 | // Akun Pengguna GOPAY 18 | GojekID::BASE_ENDPOINT . Action::gopayTransfer => 'Maulana20\Response\TransferResponse', 19 | ]; 20 | 21 | public function __construct($res, $url) 22 | { 23 | $res_json = json_decode($res); 24 | 25 | // NOTE : ACTION => gojek/v2 26 | if (isset($res_json->status) && $res_json->status != 'OK') throw new ParseException($url . ' ' . $res_json->message); 27 | // NOTE : ACTION => default 28 | if (isset($res_json->success) && $res_json->success == false) throw new ParseException($url . ' ' . $res_json->errors[0]->code . ' => ' . $res_json->errors[0]->message); 29 | 30 | $parts = parse_url($url); 31 | 32 | if ($parts['path'] == '/wallet/qr-code') { 33 | $this->response = new \Maulana20\Response\WalletResponse($res_json); 34 | } else if ($parts['path'] == '/wallet/history') { 35 | $this->response = new \Maulana20\Response\DefaultResponse($res_json); 36 | } else { 37 | $this->response = (!empty($this->storeClass[$url])) ? new $this->storeClass[$url]($res_json) : new \Maulana20\Response\DefaultResponse($res_json); 38 | } 39 | } 40 | 41 | public function getResponse() 42 | { 43 | return $this->response; 44 | } 45 | } 46 | 47 | class ParseException extends \Exception 48 | {} 49 | -------------------------------------------------------------------------------- /src/HTTP/Curl.php: -------------------------------------------------------------------------------- 1 | $val) { array_push($result, $key . ': ' . $val); } 15 | 16 | return $result; 17 | } 18 | 19 | public function __construct() 20 | { 21 | $this->ch = curl_init(); 22 | } 23 | 24 | public function delete($url, $data, $headers) 25 | { 26 | $headers['Content-Type'] = 'application/json;charset=UTF-8'; 27 | 28 | curl_setopt($this->ch, CURLOPT_URL, $url); 29 | curl_setopt($this->ch, CURLOPT_POST, false); 30 | curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); 31 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); 32 | curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->_getHeaders($headers)); 33 | 34 | $result = curl_exec($this->ch); 35 | 36 | curl_close($this->ch); 37 | 38 | return new ParseResponse($result, $url); 39 | } 40 | 41 | public function get($url, $data, $headers) 42 | { 43 | $headers['Content-Type'] = 'application/json;charset=UTF-8'; 44 | 45 | curl_setopt($this->ch, CURLOPT_URL, $url); 46 | curl_setopt($this->ch, CURLOPT_POST, false); 47 | curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET'); 48 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); 49 | curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->_getHeaders($headers)); 50 | 51 | $result = curl_exec($this->ch); 52 | 53 | curl_close($this->ch); 54 | 55 | return new ParseResponse($result, $url); 56 | } 57 | 58 | public function post($url, $data, $headers) 59 | { 60 | $headers['Content-Type'] = 'application/json;charset=UTF-8'; 61 | 62 | curl_setopt($this->ch, CURLOPT_URL, $url); 63 | curl_setopt($this->ch, CURLOPT_POST, true); 64 | curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'POST'); 65 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); 66 | curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->_getHeaders($headers)); 67 | curl_setopt($this->ch, CURLOPT_POSTFIELDS, json_encode($data)); 68 | 69 | $result = curl_exec($this->ch); 70 | 71 | curl_close($this->ch); 72 | 73 | return new ParseResponse($result, $url); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tests/GojekTest.php: -------------------------------------------------------------------------------- 1 | gojek = new GojekID(); 30 | } 31 | 32 | public function tearDown() 33 | {} 34 | 35 | public function testMetaValue() 36 | { 37 | $this->assertSame('3.34.2', Meta::APP_VERSION); 38 | $this->assertNotSame('test', Meta::APP_VERSION); 39 | $this->assertIsString(Meta::APP_VERSION); 40 | 41 | $this->assertSame('Apple, iPhone 8', Meta::PHONE_MODEL); 42 | $this->assertNotSame('Android', Meta::PHONE_MODEL); 43 | 44 | $this->assertSame('iOS, 12.3.1', Meta::DEVICE_OS); 45 | $this->assertNotSame('Apple', Meta::DEVICE_OS); 46 | } 47 | 48 | public function testEndPointUrlValue() 49 | { 50 | // Akun Pengguna GOJEK 51 | $this->assertSame('https://api.gojekapi.com/v3/customers/login_with_phone', GojekID::BASE_ENDPOINT . Action::loginPhone); 52 | $this->assertSame('https://api.gojekapi.com/v3/customers/login_with_email', GojekID::BASE_ENDPOINT . Action::loginEmail); 53 | $this->assertNotEquals('https://api.gojekapi.com', GojekID::BASE_ENDPOINT); 54 | $this->assertSame('https://api.gojekapi.com/v3/customers/token', GojekID::BASE_ENDPOINT . Action::loginAuth); 55 | $this->assertSame('https://api.gojekapi.com/gojek/v2/customer', GojekID::BASE_ENDPOINT . Action::getCustomer); 56 | $this->assertSame('https://api.gojekapi.com/gojek/v2/customer/edit/v2', GojekID::BASE_ENDPOINT . Action::editAccount); 57 | $this->assertSame('https://api.gojekapi.com/wallet/profile', GojekID::BASE_ENDPOINT . Action::checkBalance); 58 | $this->assertSame('https://api.gojekapi.com/v3/auth/token', GojekID::BASE_ENDPOINT . Action::logout); 59 | // Akun Pengguna GOPAY 60 | $this->assertSame('https://api.gojekapi.com/v2/fund/transfer', GojekID::BASE_ENDPOINT . Action::gopayTransfer); 61 | $this->assertSame('https://api.gojekapi.com/wallet/profile/detailed', GojekID::BASE_ENDPOINT . Action::gopayDetail); 62 | } 63 | 64 | public function testLoginPhoneResponse() 65 | { 66 | $data = <<getLoginToken(); 73 | $this->assertEquals("e16e7cf0-7621-419d-9f67-36aa8b919f34", $loginToken); 74 | } 75 | 76 | public function testLoginEmailResponse() 77 | { 78 | $data = <<getLoginToken(); 85 | $this->assertEquals("e16e7cf0-7621-419d-9f67-36aa8b919f34", $loginToken); 86 | } 87 | 88 | public function testLoginAuthResponse() 89 | { 90 | $data = <<getAuthToken(); 97 | $this->assertEquals("d5579ff6-d194-473a-b3cf-0b903f5f7324", $authToken); 98 | } 99 | 100 | public function testBalanceResponse() 101 | { 102 | $data = <<getBalance(); 109 | $this->assertEquals("2500", $balance); 110 | } 111 | 112 | public function testWalletResponse() 113 | { 114 | $data = <<getQrId(); 121 | $this->assertEquals("3b62005b-8905-406d-9830-26c06c55b3ed", $QrId); 122 | } 123 | 124 | public function testTransferResponse() 125 | { 126 | $data = <<getRef(); 133 | $this->assertEquals("02137d45-31e4-4d70-b0a0-40ec73f451e4", $ref); 134 | } 135 | 136 | public function testCustomerResponse() 137 | { 138 | $data = <<getResult(); 145 | $this->assertEquals("maulana20", $result->name); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##
Un-Official Gojek API Wrapper
2 | Repository Berikut Ini Merupakan Porting Dari [GOJEK](https://github.com/ridwanfathin/gojek) Untuk PHP 3 | 4 | [Fitur Akun Pengguna GOJEK](#fitur-akun-pengguna-gojek) 5 | - [x] Login Dengan Nomor Handphone Untuk Mendapatkan `loginToken` 6 | - [x] Login Dengan Email Untuk Mendapatkan `loginToken` 7 | - [x] Login Dengan OTP Untuk Mendapatkan `authToken` 8 | - [x] Menampilkan Informasi Akun Pengguna 9 | - [x] Melakukan Perubahan Pada Akun 10 | - [x] Menampilkan Jumlah Saldo 11 | - [x] Logout 12 | 13 | [Fitur Akun Pengguna GOPAY](#fitur-akun-pengguna-gopay) 14 | - [x] Menampilkan Detail Data Informasi 15 | - [x] Menampilkan History Transaksi 16 | - [x] Mengambil Data Wallet Code `QrId` Untuk Method Transfer 17 | - [x] Transfer Ke Sesama GOPAY 18 | 19 | [Fitur Data Booking GOJEK](#fitur-data-booking-gojek) 20 | - [x] Menampilkan Booking History 21 | - [x] Menampilkan Booking Yang Masih Aktif 22 | - [x] Mengambil Data Booking Berdasarkan `orderNo` 23 | - [ ] Mengkalkulasi Pemakaian GOPAY Pada GOJEK 24 | 25 | [Fitur Data GOFOOD](#fitur-data-gofood) 26 | - [x] Menampilkan Data GOFOOD Bedasarkan Lokasi `latLong` 27 | - [x] Menampilkan Data GOFOOD Terdekat Berdasarkan Lokasi `latLong` Dan `limit` 28 | - [ ] Menampilkan Data Restaurant Bedasarkan `restaurantId` 29 | - [x] Menampilkan Data Restaurant Bedasarkan `category` 30 | 31 | [Fitur Data GOPOINTS](#fitur-data-gopoints) 32 | - [x] Menampilkan Jumlah Point 33 | - [x] Menampilkan Point Lanjutan 34 | - [x] Menebus Point 35 | 36 | [Fitur Data Area GORIDE GOCAR GOSEND GOMART](#fitur-data-area-goride-gocar-gosend-gomart) 37 | - [x] Menampilkan Data Area Berdasarkan Lokasi `latLong` 38 | - [x] Menampilkan Data Area Driver Terdekat GORIDE Berdasarkan Lokasi `latLong` 39 | - [x] Menampilkan Data Area Driver Terdekat GOCAR Berdasarkan Lokasi `latLong` 40 | - [x] Menampilkan Data Area Driver Terdekat GOSEND Berdasarkan Lokasi `latLong` 41 | - [ ] Menampilkan Data Area GOMART Terdekat Berdasarkan Lokasi `latLong` 42 | 43 | ### Dokumentasi 44 | 45 | #### Langkah Untuk Menjalankan GojekID 46 | ##### Ambil Paket Pada Composer 47 | ```php 48 | composer require maulana20/gojekid 49 | ``` 50 | ##### Jika Di Jalankan Dengan Laravel Tinker 51 | 52 | [![tinker](./screen/tinker.PNG)](./../../) 53 | 54 | ##### Jika Di Jalankan Dengan Native 55 | ```php 56 | require 'vendor/autoload.php'; 57 | use Maulana20\GojekID; 58 | 59 | $gojek = new GojekID(); 60 | ``` 61 | 62 | #### Fitur Akun Pengguna GOJEK 63 | ##### Login Dengan Nomor Handphone 64 | ```php 65 | $loginToken = $gojek->loginPhone('')->getLoginToken(); 66 | ``` 67 | ##### Login Dengan Email 68 | ```php 69 | $loginToken = $gojek->loginEmail('')->getLoginToken(); 70 | ``` 71 | ##### Login Pada GOJEK Untuk Mendapatkan Auth Token 72 | ```php 73 | $authToken = $gojek->loginAuth('', '')->getAuthToken(); 74 | ``` 75 | ##### Menampilkan Informasi Akun Pengguna 76 | ```php 77 | $gojek->setAuthToken(''); 78 | $result = $gojek->getCustomer()->getResult(); 79 | ``` 80 | ##### Melakukan Perubahan Pada Akun 81 | ```php 82 | $gojek->setAuthToken(''); 83 | $result = $gojek->editAccount('', '', '')->getResult(); 84 | ``` 85 | ##### Menampilkan Jumlah Saldo 86 | ```php 87 | $gojek->setAuthToken(''); 88 | $balance = $gojek->checkBalance()->getBalance(); 89 | ``` 90 | ##### Logout 91 | ```php 92 | $gojek->setAuthToken(''); 93 | $gojek->logout(); 94 | ``` 95 | 96 | #### Fitur Akun Pengguna GOPAY 97 | ##### Menampilkan Detail Data Informasi 98 | ```php 99 | $gojek->setAuthToken(''); 100 | $result = $gojek->gopayDetail()->getResult(); 101 | ``` 102 | ##### Menampilkan History Transaksi 103 | ```php 104 | $gojek->setAuthToken(''); 105 | $result = $gojek->gopayHistory('', '')->getResult(); 106 | ``` 107 | ##### Mengambil Data Wallet Code 108 | ```php 109 | $gojek->setAuthToken(''); 110 | $QrId = $gojek->checkWalletCode('')->getQrId(); 111 | ``` 112 | ##### Transfer Ke Sesama GOPAY 113 | ```php 114 | $gojek->setAuthToken(''); 115 | $ref = $gojek->gopayTransfer('', '', '', '')->getRef(); 116 | ``` 117 | 118 | #### Fitur Data Booking GOJEK 119 | ##### Menampilkan Booking History 120 | ```php 121 | $gojek->setAuthToken(''); 122 | $result = $gojek->bookingHistory('')->getResult(); 123 | ``` 124 | ##### Menampilkan Booking Yang Masih Aktif 125 | ```php 126 | $gojek->setAuthToken(''); 127 | $result = $gojek->bookingActive()->getResult(); 128 | ``` 129 | ##### Mengambil Data Booking Berdasarkan Nomor Pesanan 130 | ```php 131 | $gojek->setAuthToken(''); 132 | $result = $gojek->bookingByOrder('')->getResult(); 133 | ``` 134 | ##### Mengkalkulasi Pemakaian GOPAY Pada GOJEK 135 | ```php 136 | $gojek->setAuthToken(''); 137 | $result = $gojek->calculate()->getResult(); 138 | ``` 139 | 140 | #### Fitur Data GOFOOD 141 | ##### Menampilkan Data GOFOOD Bedasarkan Lokasi 142 | ```php 143 | $gojek->setAuthToken(''); 144 | $result = $gojek->gofoodHome('')->getResult(); 145 | ``` 146 | ##### Menampilkan Data GOFOOD Terdekat Berdasarkan Lokasi Dan Batas Jumlah 147 | ```php 148 | $gojek->setAuthToken(''); 149 | $result = $gojek->gofoodNearby('', '', '')->getResult(); 150 | ``` 151 | ##### Menampilkan Data Restaurant Bedasarkan restaurantId 152 | ```php 153 | $gojek->setAuthToken(''); 154 | $result = $gojek->gofoodRestaurantById('')->getResult(); 155 | ``` 156 | ##### Menampilkan Data Restaurant Bedasarkan Category 157 | ```php 158 | $gojek->setAuthToken(''); 159 | $result = $gojek->gofoodRestaurantByCategory('', '', '')->getResult(); 160 | ``` 161 | 162 | #### Fitur Data GOPOINTS 163 | ##### Menampilkan Jumlah Point 164 | ```php 165 | $gojek->setAuthToken(''); 166 | $result = $gojek->gopointBalance()->getResult(); 167 | ``` 168 | ##### Menampilkan Point Lanjutan 169 | ```php 170 | $gojek->setAuthToken(''); 171 | $result = $gojek->gopointNext()->getResult(); 172 | ``` 173 | ##### Menebus Point 174 | ```php 175 | $gojek->setAuthToken(''); 176 | $result = $gojek->gopointReedem('')->getResult(); 177 | ``` 178 | #### Fitur Data Area GORIDE GOCAR GOSEND GOMART 179 | ##### Menampilkan Data Area Berdasarkan Lokasi 180 | ```php 181 | $gojek->setAuthToken(''); 182 | $result = $gojek->areaLocation('')->getResult(); 183 | ``` 184 | ##### Menampilkan Data Area Driver Terdekat GORIDE Berdasarkan Lokasi 185 | ```php 186 | $gojek->setAuthToken(''); 187 | $result = $gojek->gorideNearby('')->getResult(); 188 | ``` 189 | ##### Menampilkan Data Area Driver Terdekat GOCAR Berdasarkan Lokasi 190 | ```php 191 | $gojek->setAuthToken(''); 192 | $result = $gojek->gocarNearby('')->getResult(); 193 | ``` 194 | ##### Menampilkan Data Area Driver Terdekat GOSEND Berdasarkan Lokasi 195 | ```php 196 | $gojek->setAuthToken(''); 197 | $result = $gojek->gosendNearby('')->getResult(); 198 | ``` 199 | ##### Menampilkan Data Area GOMART Terdekat Berdasarkan Lokasi 200 | ```php 201 | $gojek->setAuthToken(''); 202 | $result = $gojek->gomartNearby('')->getResult(); 203 | ``` 204 | 205 | ### Melakukan Testing Pada PHP Unit Tests 206 | 207 | [![php-test](./screen/php-test.PNG)](./../../) 208 | 209 | ### Author 210 | 211 | [Maulana Saputra](mailto:maulanasaputra11091082@gmail.com) 212 | -------------------------------------------------------------------------------- /src/GojekID.php: -------------------------------------------------------------------------------- 1 | Meta::APP_VERSION, 22 | 'X-Location' => Meta::LOCATION, 23 | 'X-PhoneModel' => Meta::PHONE_MODEL, 24 | 'X-DeviceOS' => Meta::DEVICE_OS, 25 | ]; 26 | 27 | public function __construct() 28 | { 29 | $this->headers['X-Uniqueid'] = gen_uuid(); 30 | } 31 | 32 | /** 33 | * Authorization Token 34 | * 35 | * @var String 36 | */ 37 | 38 | public function setAuthToken($authToken) 39 | { 40 | $this->authToken = $authToken; 41 | } 42 | 43 | /** 44 | * loginPhone 45 | * 46 | * @param String $mobilePhone 47 | * @return \Maulana20\Response\LoginPhoneResponse 48 | */ 49 | 50 | public function loginPhone($mobilePhone) 51 | { 52 | $ch = new Curl(); 53 | 54 | $data = [ 55 | 'phone' => $mobilePhone 56 | ]; 57 | 58 | return $ch->post(GojekID::BASE_ENDPOINT . Action::loginPhone, $data, $this->headers)->getResponse(); 59 | } 60 | 61 | /** 62 | * loginEmail 63 | * 64 | * @param String $email 65 | * @return \Maulana20\Response\EmailResponse 66 | */ 67 | 68 | public function loginEmail($email) 69 | { 70 | $ch = new Curl(); 71 | 72 | $data = [ 73 | 'email' => $email 74 | ]; 75 | 76 | return $ch->post(GojekID::BASE_ENDPOINT . Action::loginEmail, $data, $this->headers)->getResponse(); 77 | } 78 | 79 | /** 80 | * Login GOJEK 81 | * 82 | * @param String $loginToken 83 | * @param String $OTP 84 | * @return \Maulana20\Response\LoginGojekResponse 85 | */ 86 | 87 | public function loginAuth($loginToken, $OTP) 88 | { 89 | $ch = new Curl(); 90 | 91 | $data = [ 92 | 'scopes' => 'gojek:customer:transaction gojek:customer:readonly', 93 | 'grant_type' => 'password', 94 | 'login_token' => $loginToken, 95 | 'otp' => $OTP, 96 | 'client_id' => 'gojek:cons:android', 97 | 'client_secret' => '83415d06-ec4e-11e6-a41b-6c40088ab51e' 98 | ]; 99 | 100 | return $ch->post(GojekID::BASE_ENDPOINT . Action::loginAuth, $data, $this->headers)->getResponse(); 101 | } 102 | 103 | /** 104 | * Get Balance GOJEK 105 | * 106 | * @return \Maulana20\Response\BalanceResponse 107 | */ 108 | 109 | public function checkBalance() 110 | { 111 | $ch = new Curl(); 112 | 113 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 114 | 115 | $data = []; 116 | 117 | return $ch->get(GojekID::BASE_ENDPOINT . Action::checkBalance, $data, $this->headers)->getResponse(); 118 | } 119 | 120 | /** 121 | * Get Customer GOJEK 122 | * 123 | * @return \Maulana20\Response\DefaultResponse 124 | */ 125 | 126 | public function getCustomer() 127 | { 128 | $ch = new Curl(); 129 | 130 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 131 | 132 | $data = []; 133 | 134 | return $ch->get(GojekID::BASE_ENDPOINT . Action::getCustomer, $data, $this->headers)->getResponse(); 135 | } 136 | 137 | /** 138 | * Edit Akun Pengguna GOJEK 139 | * 140 | * @return \Maulana20\Response\DefaultResponse 141 | */ 142 | 143 | public function editAccount($mobilePhone, $email, $name) 144 | { 145 | $ch = new Curl(); 146 | 147 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 148 | 149 | $data = [ 150 | 'phone' => $mobilePhone, 151 | 'email' => $email, 152 | 'name' => $name, 153 | ]; 154 | 155 | return $ch->post(GojekID::BASE_ENDPOINT . Action::editAccount, $data, $this->headers)->getResponse(); 156 | } 157 | 158 | /** 159 | * Logout GOJEK 160 | * 161 | * @return \Maulana20\Response\DefaultResponse 162 | */ 163 | 164 | public function logout() 165 | { 166 | $ch = new Curl(); 167 | 168 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 169 | 170 | $data = []; 171 | 172 | return $ch->delete(GojekID::BASE_ENDPOINT . Action::logout, $data, $this->headers)->getResponse(); 173 | } 174 | 175 | /** 176 | * Get GOPAY Detail 177 | * 178 | * @return \Maulana20\Response\DefaultResponse 179 | */ 180 | 181 | public function gopayDetail() 182 | { 183 | $ch = new Curl(); 184 | 185 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 186 | 187 | $data = []; 188 | 189 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gopayDetail, $data, $this->headers)->getResponse(); 190 | } 191 | 192 | /** 193 | * Get GOPAY History 194 | * 195 | * @return \Maulana20\Response\DefaultResponse 196 | */ 197 | 198 | public function gopayHistory($page, $limit) 199 | { 200 | $ch = new Curl(); 201 | 202 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 203 | 204 | $data = []; 205 | 206 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gopayHistory . '?' . http_build_query([ 'page' => $page, 'limit' => $limit ]), $data, $this->headers)->getResponse(); 207 | } 208 | 209 | /** 210 | * Get Wallet Code 211 | * 212 | * @param String $mobilePhoneTo 213 | * @return \Maulana20\Response\WalletResponse 214 | */ 215 | 216 | public function checkWalletCode($mobilePhoneTo) 217 | { 218 | $ch = new Curl(); 219 | 220 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 221 | 222 | $data = []; 223 | 224 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gopayWalletCode . '?phone_number=%2B62' . ltrim($mobilePhoneTo, '0'), $data, $this->headers)->getResponse(); 225 | } 226 | 227 | /** 228 | * Transfer GOPAY 229 | * 230 | * @param String $QRID 231 | * @param String $PIN 232 | * @param Float $amount 233 | * @param String $description 234 | * @return \Maulana20\Response\WalletResponse 235 | */ 236 | 237 | public function gopayTransfer($QRID, $PIN, $amount, $description) 238 | { 239 | $ch = new Curl(); 240 | 241 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 242 | $this->headers['pin'] = $PIN; 243 | $this->headers['User-Agent'] = 'Gojek/3.34.1 (com.go-jek.ios; build:3701278; iOS 12.3.1) Alamofire/4.7.3'; 244 | 245 | $data = [ 246 | 'qr_id' => $QRID, 247 | 'amount' => $amount, 248 | 'description' => $description 249 | ]; 250 | 251 | return $ch->post(GojekID::BASE_ENDPOINT . Action::gopayTransfer, $data, $this->headers)->getResponse(); 252 | } 253 | 254 | /** 255 | * Get GOJEK History 256 | * 257 | * @param String $userId 258 | * @return \Maulana20\Response\DefaultResponse 259 | */ 260 | 261 | public function bookingHistory($userId) 262 | { 263 | $ch = new Curl(); 264 | 265 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 266 | 267 | $data = []; 268 | 269 | return $ch->get(GojekID::BASE_ENDPOINT . Action::bookingHistory . '/' . $userId, $data, $this->headers)->getResponse(); 270 | } 271 | 272 | /** 273 | * Get GOJEK Active Booking 274 | * 275 | * @return \Maulana20\Response\DefaultResponse 276 | */ 277 | 278 | public function bookingActive() 279 | { 280 | $ch = new Curl(); 281 | 282 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 283 | 284 | $data = []; 285 | 286 | return $ch->get(GojekID::BASE_ENDPOINT . Action::bookingActive, $data, $this->headers)->getResponse(); 287 | } 288 | 289 | /** 290 | * Get GOJEK By Order No 291 | * 292 | * @param String $orderNo 293 | * @return \Maulana20\Response\DefaultResponse 294 | */ 295 | 296 | public function bookingByOrder($orderNo) 297 | { 298 | $ch = new Curl(); 299 | 300 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 301 | 302 | $data = []; 303 | 304 | return $ch->get(GojekID::BASE_ENDPOINT . Action::bookingByOrder . '/' . $orderNo, $data, $this->headers)->getResponse(); 305 | } 306 | 307 | /** 308 | * Get GOJEK Calculate 309 | * 310 | * @return \Maulana20\Response\DefaultResponse 311 | */ 312 | 313 | public function calculate() 314 | { 315 | $ch = new Curl(); 316 | 317 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 318 | 319 | $data = []; 320 | 321 | return $ch->post(GojekID::BASE_ENDPOINT . Action::calculate . '/', $data, $this->headers)->getResponse(); 322 | } 323 | 324 | /** 325 | * Get GOFOOD Home 326 | * 327 | * @param String $latLong 328 | * @return \Maulana20\Response\DefaultResponse 329 | */ 330 | 331 | public function gofoodHome($latLong) 332 | { 333 | $ch = new Curl(); 334 | 335 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 336 | 337 | $data = []; 338 | 339 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gofoodHome . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 340 | } 341 | 342 | /** 343 | * Get GOFOOD Nearby 344 | * 345 | * @param String $latLong 346 | * @param String $page 347 | * @param String $limit 348 | * @return \Maulana20\Response\DefaultResponse 349 | */ 350 | 351 | public function gofoodNearby($latLong, $page, $limit) 352 | { 353 | $ch = new Curl(); 354 | 355 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 356 | 357 | $data = []; 358 | 359 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gofoodHome . '?' . http_build_query([ 'location' => $latLong, 'page' => $page, 'limit' => $limit ]), $data, $this->headers)->getResponse(); 360 | } 361 | 362 | /** 363 | * Get GOFOOD Restaurant By Id 364 | * 365 | * @param String $restaurantId 366 | * @return \Maulana20\Response\DefaultResponse 367 | */ 368 | 369 | public function gofoodRestaurantById($restaurantId) 370 | { 371 | $ch = new Curl(); 372 | 373 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 374 | 375 | $data = []; 376 | 377 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gofoodRestaurant . '/' . $restaurantId, $data, $this->headers)->getResponse(); 378 | } 379 | 380 | /** 381 | * Get GOFOOD Restaurant By Category 382 | * 383 | * @param String $category 384 | * @param String $page 385 | * @param String $limit 386 | * @return \Maulana20\Response\DefaultResponse 387 | */ 388 | 389 | public function gofoodRestaurantByCategory($category, $page, $limit) 390 | { 391 | $ch = new Curl(); 392 | 393 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 394 | 395 | $data = []; 396 | 397 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gofoodRestaurant . '?' . http_build_query([ 'category' => $category, 'page' => $page, 'limit' => $limit ]), $data, $this->headers)->getResponse(); 398 | } 399 | 400 | /** 401 | * Get Driver Location 402 | * 403 | * @param String $latLong 404 | * @return \Maulana20\Response\DefaultResponse 405 | */ 406 | 407 | public function areaLocation($latLong) 408 | { 409 | $ch = new Curl(); 410 | 411 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 412 | 413 | $data = []; 414 | 415 | return $ch->get(GojekID::BASE_ENDPOINT . Action::areaLocation . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 416 | } 417 | 418 | /** 419 | * Get GORIDE Location 420 | * 421 | * @param String $latLong 422 | * @return \Maulana20\Response\DefaultResponse 423 | */ 424 | 425 | public function gorideNearby($latLong) 426 | { 427 | $ch = new Curl(); 428 | 429 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 430 | 431 | $data = []; 432 | 433 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gorideNearby . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 434 | } 435 | 436 | /** 437 | * Get GOCAR Location 438 | * 439 | * @param String $latLong 440 | * @return \Maulana20\Response\DefaultResponse 441 | */ 442 | 443 | public function gocarNearby($latLong) 444 | { 445 | $ch = new Curl(); 446 | 447 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 448 | 449 | $data = []; 450 | 451 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gocarNearby . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 452 | } 453 | 454 | /** 455 | * Get GOSEND Location 456 | * 457 | * @param String $latLong 458 | * @return \Maulana20\Response\DefaultResponse 459 | */ 460 | 461 | public function gosendNearby($latLong) 462 | { 463 | $ch = new Curl(); 464 | 465 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 466 | 467 | $data = []; 468 | 469 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gosendNearby . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 470 | } 471 | 472 | /** 473 | * Get GOMART Location 474 | * 475 | * @param String $latLong 476 | * @return \Maulana20\Response\DefaultResponse 477 | */ 478 | 479 | public function gomartNearby($latLong) 480 | { 481 | $ch = new Curl(); 482 | 483 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 484 | 485 | $data = []; 486 | 487 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gomartNearby . '?' . http_build_query([ 'location' => $latLong ]), $data, $this->headers)->getResponse(); 488 | } 489 | 490 | /** 491 | * Get GOPOINTS Balance 492 | * 493 | * @return \Maulana20\Response\DefaultResponse 494 | */ 495 | 496 | public function gopointBalance() 497 | { 498 | $ch = new Curl(); 499 | 500 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 501 | 502 | $data = []; 503 | 504 | return $ch->get(GojekID::BASE_ENDPOINT . Action::gopointBalance, $data, $this->headers)->getResponse(); 505 | } 506 | 507 | /** 508 | * Get GOPOINTS Next Point 509 | * 510 | * @return \Maulana20\Response\DefaultResponse 511 | */ 512 | 513 | public function gopointNext() 514 | { 515 | $ch = new Curl(); 516 | 517 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 518 | 519 | $data = []; 520 | 521 | return $ch->post(GojekID::BASE_ENDPOINT . Action::gopointNext, $data, $this->headers)->getResponse(); 522 | } 523 | 524 | /** 525 | * Get GOPOINTS Reedem Point 526 | * 527 | * @return \Maulana20\Response\DefaultResponse 528 | */ 529 | 530 | public function gopointReedem($goPointsToken) 531 | { 532 | $ch = new Curl(); 533 | 534 | $this->headers['Authorization'] = 'Bearer ' . $this->authToken; 535 | 536 | $data = []; 537 | 538 | return $ch->post(GojekID::BASE_ENDPOINT . Action::gopointReedem . '?' . http_build_query([ 'points_token_id' => $goPointsToken ]), $data, $this->headers)->getResponse(); 539 | } 540 | } 541 | --------------------------------------------------------------------------------