My Business V4 and notifications support
Closed this issue ยท 19 comments
As far as I can tell these items are not supported (I link to v4, but v3 also has them):
https://developers.google.com/my-business/reference/rest/v4/accounts/getNotifications
https://developers.google.com/my-business/reference/rest/v4/accounts/updateNotifications
It looks like the My Business API is not listed in the standard list of APIs. That's okay:
gem install google-api-client
generate-api gen lib --url=https://developers.google.com/my-business/samples/mybusiness_google_rest_v4.json
# It might complain about a missing api_names_out.yaml
touch /full/path/to/lib/ruby/gems/*/gems/google-api-client-*/api_names_out.yaml
generate-api gen lib --url=https://developers.google.com/my-business/samples/mybusiness_google_rest_v4.json
The lib directory will be created in your current working directory. You may find it desirable to specify the generated
directory in the google-api-client gem directory.
see
https://developers.google.com/my-business/samples/
https://github.com/google/google-api-ruby-client#generating-apis
Well, even though it may not be listed you guys do support "my business", just it seems a feature is missing. I can try the generator but isn't that what whom ever added my business to this repo did?
It's not listed because it's private and you have to register in a form to get access
@mattwhisenhunt Are you interested in updating support for MyBusiness v4?
Or do you not want it included? Would be nice to not have to create my own fork for using it.
Edit
Realised I can generate the api in my project instead, but could indeed be useful to have it included.
I agree, it is still a Google API, and should be included here. With all features. You already support v3, so I don't see why not add v4 and check that it included all relevant calls. Especially when it's so easy to do so.
When can be expect v4 support for My Business API?
@mattwhisenhunt Attempting your guide.
Added to my Gemfile
gem 'google-api-client', "~> 0.24.2"
Execute:
bundle install
generate-api gen lib --url=https://developers.google.com/my-business/samples/mybusiness_google_rest_v4.json
Errors: Thor is required. Please install the gem with development dependencies.
So I execute: gem install --dev thor
Try again, same error.
Any idea why?
I think the thor executable needs to be in your path.
@mattwhisenhunt I thought to check that I could execute thor as well, so I had run:
ubuntu@ubuntu-xenial:~/myproj/api$ thor
Commands:
thor help [COMMAND] # Describe available commands or one specific command
thor install NAME # Install an optionally named Thor file into your system commands
thor installed # List the installed Thor modules and commands
thor list [SEARCH] # List the available thor commands (--substring means .*SEARCH)
thor uninstall NAME # Uninstall a named Thor module
thor update NAME # Update a Thor file from its original location
thor version # Show Thor version
Seems to be accessible to me? (And these kinds of issues, as well as the fact that you can no-longer just checkout a gem when deploying to live and such, is exactly why these libraries should be added to this repo)
It's in my path because I have rvm properly configured.
Also note, both generate-api and thor are in the same gemset:
ubuntu@ubuntu-xenial:~/myproject/api$ which thor
/home/ubuntu/.rvm/gems/ruby-2.4.1@myproject/bin/thor
ubuntu@ubuntu-xenial:~/myproject/api$ which generate-api
/home/ubuntu/.rvm/gems/ruby-2.4.1@myproject/bin/generate-api
To clarify, what you should do for this is either as follows:
gem install google-api-client
gem install --dev thor
Or if you're using it in a gemfile and what not, your gemfile should have this in your gemfile
gem 'google-api-client', "~> 0.24.2"
group :development do
gem 'thor'
end
Either way, you then move on to here:
Run this:
generate-api gen lib --url=https://developers.google.com/my-business/samples/mybusiness_google_rest_v4.json
You'll probably get an error about failing to open a api_names_out.yaml file, copy the file path for that file, and run: touch /path-to-gems-copied-before/gems/google-api-client-0.24.2/api_names_out.yaml
Now, rerun the command: generate-api gen lib --url=https://developers.google.com/my-business/samples/mybusiness_google_rest_v4.json
Keep in mind, when deploying this to a live server, you'll need to ensure the generated api's are present there, and additionally handle for updates that may occur as it can't be versioned in your Gemfile like most dependencies. Which @mattwhisenhunt is another reason this should be versioned in this project.
Hi @csga5000, At this moment I need to use one of the Google My Business API V4 functionalities, like authentication, list accounts, locations, reviews, etc, because I couldn't do it with V3
Does 0.24.2
version supports this ? And does it have any documentation ?
Thanks in advance
@andru1989 No version of this package (google-api-ruby-client) supports My Business v4, and the current version does not support v3 either.
My instructions above tell you how you can use a gem to generate a ruby code for interacting with my business v4.
The code is pretty easy to look at, once you run the generate-api command you can then look in lib/google/apis/mybusiness_v4 at the 3 files it created.
classes.rb
representations.rb
service.rb
service.rb
Has all the functions you call, for example if you search that file for "list_accounts" you you can use the comments as documentation:
# Lists all of the accounts for the authenticated user. This includes all
# accounts that the user owns, as well as any accounts for which the user
# has management rights.
# @param [String] filter
# A filter constraining the accounts to return. The response includes
# only entries that match the filter. If `filter` is empty, then no
# constraints are applied and all accounts (paginated) are retrieved for
# the requested account.
# For example, a request with the filter `type=USER_GROUP` will only return
# user groups.
# @param [String] name
# The resource name of the account for which the list of directly accessible
# accounts is to be retrieved. This only makes sense for Organizations and
# User Groups. If empty, will return `ListAccounts` for the authenticated user.
# @param [Fixnum] page_size
# How many accounts to fetch per page. Default is 500,
# minimum is 2, and maximum page size is 500.
# @param [String] page_token
# If specified, the next page of accounts is retrieved. The `pageToken` is
# returned when a call to `accounts.list` returns more results than can fit
# into the requested page size.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::MybusinessV4::ListAccountsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::MybusinessV4::ListAccountsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_accounts(filter: nil, name: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
If you want to see details of a model like what fields are contained, you can look in classes.rb. For example, that call returns a ListAccountsResponse. If you want to know what fields are on that class search classes.rb for ListAccountsResponse.
@lcpriest
Well google no longer even lists v3 in their documentation: https://developers.google.com/my-business/reference/rest/
And that commit was autogenerated, so I assume it was removed due to deprecation.
The devs of this ruby library seem opposed to adding built in support because "it is not listed in the standard list of apis". Why that matters, I'm not certain, the real puzzler is if that's the "rule", then why was there ever v3.
Apologies for the uncertainty here. You can take this as the authoritative response from the internal Google team that now maintains this library.
This library covers the public APIs that are listed in the Google API discovery service, but intentionally does not include libraries not in that list. There are various reasons why an API would not be in that list, and would not be covered by this library. For example, an API might not be generally available, but accessible only to certain enabled partners. That is the case for this API, Google My Business. We omit those from the library to avoid confusion, as well as to prevent the library from getting too large by including the long tail of APIs that are available only to a very small number of customers. We also might omit APIs that require certain specialized handling or access features not available in this library's mechanisms.
At this point, Google My Business V4 is not part of the standard distribution of this library. As earlier commenters have mentioned, you can use this library to generate your own client classes for the API. (And we just committed a fix for the api_names_out.yaml
issue, so that should no longer be a problem in the next release.) As for why V3 was present in this library earlier, unfortunately I don't know. It might have simply been a policy change in how the My Business team decided to handle clients.
Finally, apologies for the delayed response here. My team only recently inherited maintenance of this library, and we're just now trying to catch up on the backlog of questions and requests. The good news is that we do now have a dedicated team working on it (including actual experienced Ruby developers! ๐) so we should be able to provide better support moving forward.
@skarmakar Not sure if you still have issues but I managed to find the right URL, https://developers.google.com/static/my-business/samples/mybusiness_google_rest_v4p9.json, that allowed me to generate the lib and eventually getting it to work.
@fraasssee awesome! I shall check this. Thanks for the help!