-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added RightmoveApiController for interacting
- Loading branch information
1 parent
400c2a4
commit 578c089
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Http; | ||
use Exception; | ||
|
||
class RightmoveApiController extends Controller | ||
{ | ||
protected $baseUri = 'https://api.rightmove.com'; | ||
|
||
public function fetchProperties() | ||
{ | ||
try { | ||
$response = Http::get("{$this->baseUri}/properties"); | ||
return $response->json(); | ||
} catch (Exception $e) { | ||
return response()->json(['error' => 'Failed to fetch properties.'], 500); | ||
} | ||
} | ||
|
||
public function createListing(Request $request) | ||
{ | ||
try { | ||
$response = Http::post("{$this->baseUri}/listings", $request->all()); | ||
return $response->json(); | ||
} catch (Exception $e) { | ||
return response()->json(['error' => 'Failed to create listing.'], 500); | ||
} | ||
} | ||
|
||
public function updateListing(Request $request, $listingId) | ||
{ | ||
try { | ||
$response = Http::put("{$this->baseUri}/listings/{$listingId}", $request->all()); | ||
return $response->json(); | ||
} catch (Exception $e) { | ||
return response()->json(['error' => 'Failed to update listing.'], 500); | ||
} | ||
} | ||
} |