Skip to content

Commit

Permalink
feat: Added RightmoveApiController for interacting
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 11, 2024
1 parent 400c2a4 commit 578c089
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app/Http/Controllers/RightmoveApiController.php
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);
}
}
}

0 comments on commit 578c089

Please sign in to comment.