1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\MyBusinessAccountManagement\Resource;
19
20use Google\Service\MyBusinessAccountManagement\Account;
21use Google\Service\MyBusinessAccountManagement\ListAccountsResponse;
22
23/**
24 * The "accounts" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $mybusinessaccountmanagementService = new Google\Service\MyBusinessAccountManagement(...);
28 *   $accounts = $mybusinessaccountmanagementService->accounts;
29 *  </code>
30 */
31class Accounts extends \Google\Service\Resource
32{
33  /**
34   * Creates an account with the specified name and type under the given parent. -
35   * Personal accounts and Organizations cannot be created. - User Groups cannot
36   * be created with a Personal account as primary owner. - Location Groups cannot
37   * be created with a primary owner of a Personal account if the Personal account
38   * is in an Organization. - Location Groups cannot own Location Groups.
39   * (accounts.create)
40   *
41   * @param Account $postBody
42   * @param array $optParams Optional parameters.
43   * @return Account
44   */
45  public function create(Account $postBody, $optParams = [])
46  {
47    $params = ['postBody' => $postBody];
48    $params = array_merge($params, $optParams);
49    return $this->call('create', [$params], Account::class);
50  }
51  /**
52   * Gets the specified account. Returns `NOT_FOUND` if the account does not exist
53   * or if the caller does not have access rights to it. (accounts.get)
54   *
55   * @param string $name Required. The name of the account to fetch.
56   * @param array $optParams Optional parameters.
57   * @return Account
58   */
59  public function get($name, $optParams = [])
60  {
61    $params = ['name' => $name];
62    $params = array_merge($params, $optParams);
63    return $this->call('get', [$params], Account::class);
64  }
65  /**
66   * Lists all of the accounts for the authenticated user. This includes all
67   * accounts that the user owns, as well as any accounts for which the user has
68   * management rights. (accounts.listAccounts)
69   *
70   * @param array $optParams Optional parameters.
71   *
72   * @opt_param string filter Optional. A filter constraining the accounts to
73   * return. The response includes only entries that match the filter. If `filter`
74   * is empty, then no constraints are applied and all accounts (paginated) are
75   * retrieved for the requested account. For example, a request with the filter
76   * `type=USER_GROUP` will only return user groups. The `type` field is the only
77   * supported filter.
78   * @opt_param int pageSize Optional. How many accounts to fetch per page. The
79   * minimum supported page_size is 2. The default and maximum is 20.
80   * @opt_param string pageToken Optional. If specified, the next page of accounts
81   * is retrieved. The `pageToken` is returned when a call to `accounts.list`
82   * returns more results than can fit into the requested page size.
83   * @opt_param string parentAccount Optional. The resource name of the account
84   * for which the list of directly accessible accounts is to be retrieved. This
85   * only makes sense for Organizations and User Groups. If empty, will return
86   * `ListAccounts` for the authenticated user. `accounts/{account_id}`.
87   * @return ListAccountsResponse
88   */
89  public function listAccounts($optParams = [])
90  {
91    $params = [];
92    $params = array_merge($params, $optParams);
93    return $this->call('list', [$params], ListAccountsResponse::class);
94  }
95  /**
96   * Updates the specified business account. Personal accounts cannot be updated
97   * using this method. (accounts.patch)
98   *
99   * @param string $name Immutable. The resource name, in the format
100   * `accounts/{account_id}`.
101   * @param Account $postBody
102   * @param array $optParams Optional parameters.
103   *
104   * @opt_param string updateMask Required. The specific fields that should be
105   * updated. The only editable field is `accountName`.
106   * @opt_param bool validateOnly Optional. If true, the request is validated
107   * without actually updating the account.
108   * @return Account
109   */
110  public function patch($name, Account $postBody, $optParams = [])
111  {
112    $params = ['name' => $name, 'postBody' => $postBody];
113    $params = array_merge($params, $optParams);
114    return $this->call('patch', [$params], Account::class);
115  }
116}
117
118// Adding a class alias for backwards compatibility with the previous class name.
119class_alias(Accounts::class, 'Google_Service_MyBusinessAccountManagement_Resource_Accounts');
120