Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 api methods on accounts.locations are missing #340

Closed
Radon8472 opened this issue Apr 28, 2021 · 12 comments
Closed

v4 api methods on accounts.locations are missing #340

Radon8472 opened this issue Apr 28, 2021 · 12 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@Radon8472
Copy link

Radon8472 commented Apr 28, 2021

I liked to use the method accounts.locations.reviews.list to load the reviews for my location.
So I tried first to list my locations with accounts.locations.list.

But I noticed that the Location-Client Ressource Object is currently not supporting this methods.

To be exact, it seems that only locations.transferLocation is supported, but all other methods from the api to v4 are missing.

So my support questions are:

  • when the missing methods for the location and review entpoints will be added to the services
  • is there currently a workarround to access the accounts.locations.reviews.list method without the methods in locations client ressource object?
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 29, 2021
@dwsupplee dwsupplee added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels May 3, 2021
@bgultekin
Copy link

We're having very similar issue. We can't find accounts.locations service resource inside the new repo. Should we keep using v4.9 service file together with this repository or is it going to be added here soon?

@Radon8472
Copy link
Author

Radon8472 commented May 11, 2021

I noticed, that there is no accounts.locations (to be exact, the location has only the "transferLocation" method in the current class and nothing else), no accounts.reviews ect. in this repo.
The reason seems to be, that the account class here is still at version 1, while e.g. accounts.locations was added in later version.

I think the version 1 account-class should either be replaced/updated, or a new class for accountsV4 should be added

@Radon8472
Copy link
Author

Radon8472 commented Apr 8, 2022

If we need to combine the two versions of the API, is it possible to do so with the google-api-php-client library ?

@aimee

Im our case, I extended the Google_Service_MyBusinessAccountManagement class to create a Google_Service_MyBusinessAccountManagementV4 class, that adds and implements the missing v4 methods we need.

But in total that was a quite complicated work, because you need Ressource Classes for the returned data too.
And it took a lot of time for me to understand how the classes work together.

Here is the Code of my implementation that extends the class to use 4v methods.

<?php
/*
 * Copyright 2014 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

/**
 * Service definition for Locations (v4). - (Copy from Calendar (v3) )
 * @see: https://github.com/googleapis/google-api-php-client-services/blob/master/src/Google/Service/Calendar.php
 *
 * <p>
 * Load and Manipulates Locations.</p>
 *
 * <p>
 * For more information about this service, see the API
 * <a href="https://developers.google.com/my-business/content/location-data#get_one_or_more_locations" target="_blank">Documentation</a>
 * </p>
 *
 */
class Google_Service_MyBusinessAccountManagementV4 extends Google_Service_MyBusinessAccountManagement
{
  public $locations;
  public $locations_reviews;

  /**
   * Constructs the internal representation of the Location service.
   *
   * @param Google_Client $client The client used to deliver requests.
   * @param string $rootUrl The root URL used for requests to the service.
   */
  public function __construct(Google_Client $client, $rootUrl = null)
  {
    parent::__construct($client);
    $this->rootUrl = $rootUrl ?: 'https://mybusiness.googleapis.com';
    $this->servicePath = 'v4/'; //v4/accounts/
    $this->batchPath = '';
    $this->version = 'v4';
    $this->serviceName = 'mybusinessaccount';

    $this->locations = new Google_Service_MyBusinessAccountManagementV4_Resource_Locations(
        $this,
        $this->serviceName,
        'locations',
        array(
          'methods' => array(
            'list' => array(
              'path' => '{+parent}/locations',
              'httpMethod' => 'GET',
              'parameters' => array(
                'parent' => array(
                  'location' => 'path',
                  'type' => 'string',
                  'required' => true,
                )
              ),
            ),

            // @see: https://developers.google.com/my-business/reference/rest/v4/accounts.locations/get?hl=de
            'get' => array(
              'path' => '{+name}',
              'httpMethod' => 'GET',
              'parameters' => array(
                'name' => array(
                  'location' => 'path',
                  'type' => 'string',
                  'required' => true,
                ),
              ),
            )
          )
        )
    );

    /**
     * @see: https://developers.google.com/my-business/reference/rest/v4/accounts.locations/list?hl=de
     */
    $this->locations_reviews = new Google_Service_MyBusinessAccountManagementV4_Resource_LocationsReviews(
      $this,
      $this->serviceName,
      'reviews',
      array(
        'methods' => array(
          'list' => array(
            'path' => '{+parent}/reviews',
            'httpMethod' => 'GET',
            'parameters' => array(
              'parent' => array(
                'location' => 'path',
                'type' => 'string',
                'required' => true,
              )
            ),
          )
        )
      )
    );

  }
}

Depending on which ressources you need from the v4 api, you must copy and modify the V1 classes in this repo to create your own v4 ressource-classes

@Wamibee
Copy link

Wamibee commented Apr 8, 2022

Thanks, @Radon8472, for your answer !

Sorry if I deleted my previous comment : as I posted it one year after the initial issue was opened, I thought the issue was outdated.

As a temporary solution, we simply decided to store the information received by the V1 API (Location name and the Account name in particular, for each store linked to our GMB account) to still be able to use the V4 API calls on a separate script, without instantiating the two versions of the library. It allows us to make calls like this : $reviews->listAccountsLocationsReviews($account_name. "/". $location_name );

I don't know if our solution will be viable for long, and I find it lacking modularity. Your solution of extending the class is way more handy. We will definitely be using it in future development, thank you 😁 !

@bgultekin
Copy link

@Radon8472 I might be missing something 🤔 but shouldn't you try to use v1 as v4 will be deprecated soon?

@Radon8472
Copy link
Author

Radon8472 commented Apr 8, 2022

@Radon8472 I might be missing something 🤔 but shouldn't you try to use v1 as v4 will be deprecated soon?

@bgultekin I checked the infos and maybe you are right, but the informations are very confusing.
As I understand, it sounds that API V4 will be shutdown, and the replacement is api V1 ?????

It seems a bit strange that a lowwer version replaces a higher one, on one side.

But the major point that is very strange:
There are still no methods accounts.locations V1 that allows to get or list locations like in accounts.locations.list V4.

So the big question is:
If V1 should be the future, how can we List/get Locations in this account in the future without using the V4 api?

@Wamibee
Copy link

Wamibee commented Apr 8, 2022

@Radon8472 The V4 of the Google My Business API is replaced partially by other APIs like the "My Business Business Information API v1" which can give you a list of the locations. You can get the list of locations with something like this :

// Parameters of the request
$queryParamsLocation = [
  "pageSize" => 10, // page length, 100 max, 10 by default
  'readMask' => "name,title" // informations about the store you need
];

// Lists all the locations based on an account name 
$locationRequest = $locations->listAccountsLocations($account->name, $queryParamsLocation);
$accountLocations = $locationRequest->getLocations();

You can get the account->name with the request $my_business_service->accounts_locations;, with $my_business_service being an instance of Google_Service_MyBusinessBusinessInformation, which is a class dedicated to the My Business Business Information API v1 in this library.

In this case, you don't need to use the v4 API to get locations. I hope I understood your question correctly, all of this stuff is confusing.

@Radon8472
Copy link
Author

Radon8472 commented Apr 8, 2022

Ahhhh, okay I understand...

So calling Google\Service\MyBusinessBusinessInformation\Location->listAccountsLocations should do the job in the future.

Thank you for this help 👍

[EDIT] I checked the code for resulting Location, and unfortunally it does not contain a reference to the reviews of this Location :(

@bgultekin
Copy link

@Radon8472 accounts.locations.reviews is not deprecated yet. Probably that's why there is no new endpoint for it for now. You can see it here https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews .

@PeterWooster
Copy link

PeterWooster commented Sep 5, 2022

I'm having a similar problem finding the patch method described for HTTP in https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations/patch in the PHP V1 API. If it exists, where is the documentation or what is the syntax. I found the python version at https://googleapis.github.io/google-api-python-client/docs/dyn/mybusinessbusinessinformation_v1.locations.html#patch

@stokic
Copy link

stokic commented Nov 18, 2022

Seems like /v4/locations/$id/reviews is no longer working ie. I get 404 but there is no v1 version of this or am I missing something? :/

@bshaffer
Copy link
Contributor

The old client was removed by the API team. I've published a standalone client which can be installed via composer that covers the old v4.9 endpoints: https://github.com/bshaffer/google-mybusiness-php-client. Essentially, the 4.9 API was deprecated but a few endpoints remained. But the client library was removed for download, so the only way to access those remaining endpoints (AFAIK) is to use the client I've added. But those new endpoints will be deprecated soon, so this is just a stopgap.

See #580 for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

8 participants