Skip to content

Dev oracle#22

Merged
UchihaIthachi merged 144 commits intomainfrom
dev_oracle
Jun 16, 2025
Merged

Dev oracle#22
UchihaIthachi merged 144 commits intomainfrom
dev_oracle

Conversation

@UchihaIthachi
Copy link
Member

No description provided.

senaMora and others added 30 commits March 11, 2025 14:50
…kila

initial commit for social media service
Modifies the API service to construct full image URLs for places,
rather than requiring the frontend to do so. This enhances API key
security by keeping the Google Maps API key on the backend.

Changes:
- Updated `api-service/models/places_model.go` to add a `PhotoURLs` field (type `[]string`) to the place result struct. This field will store the fully constructed photo URLs.
- Modified `api-service/services/maps/places_service.go`:
    - `TextSearch` and `NearbySearch` functions now unmarshal the Google API response into `models.PlacesResponse`.
    - These functions iterate over the photo references from the Google API, construct the full photo URL (including the API key), and populate the new `PhotoURLs` field.
    - Return types were changed to `*models.PlacesResponse`.
- `api-service/controllers/maps_controller.go` was confirmed to correctly handle the updated service response type due to Gin's flexible JSON marshalling.

Frontend Impact:
You should update the frontend to:
- Expect a `photo_urls: string[]` field in the location details.
- Use these URLs directly to display images.
- The existing `photos` array (with `photo_reference`) in frontend types may be redundant.
Implements a new API endpoint `/maps/place/:place_id` to fetch detailed
information for a specific place using its Google Place ID.

Changes:
- **Models (`api-service/models/places_model.go`):**
    - Defined a reusable top-level `Geometry` struct.
    - Added new structs for Place Details: `PlacePhoto`, `PlaceReview`,
      `OpeningHoursPeriodDetail`, `OpeningHoursPeriod`, `PlaceOpeningHours`,
      `PlaceDetailResult`, and `PlaceDetailResponse`.
    - `PlaceDetailResult` includes a `PhotoURLs []string` field for fully
      constructed image URLs, similar to the places search.

- **Service (`api-service/services/maps/places_service.go`):**
    - Modified `FindPlaceByID` to:
        - Return `*models.PlaceDetailResponse`.
        - Unmarshal the Google Places Details API response into the new structs.
        - Populate `PhotoURLs` from photo references.
        - Include a `fields` parameter in the Google API request to fetch
          a comprehensive set of details.
        - Improved error handling to return the parsed Google response
          even on API errors.

- **Controller (`api-service/controllers/maps_controller.go`):**
    - Added `PlaceDetailsController` to handle requests.
    - Extracts `place_id` from the URL path.
    - Calls `placesService.FindPlaceByID`.
    - Maps Google API statuses (OK, NOT_FOUND, INVALID_REQUEST, etc.)
      from the service response to appropriate HTTP status codes.

- **Routes (`api-service/routes/routes.go`):**
    - Added a new route `GET /maps/place/:place_id` linked to
      `PlaceDetailsController`.

- **Documentation (`api-service/api.md`):**
    - Added a new section documenting the `/maps/place/:place_id` endpoint,
      including its path, method, parameters, example request,
      and detailed response structure (with `PhotoURLs` and error codes).

This new endpoint allows the frontend to fetch rich details for a specific
place, enhancing your experience on place detail pages.
@UchihaIthachi UchihaIthachi merged commit 3ca6c8f into main Jun 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants