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\AndroidEnterprise\Resource;
19
20use Google\Service\AndroidEnterprise\AppRestrictionsSchema;
21use Google\Service\AndroidEnterprise\Product;
22use Google\Service\AndroidEnterprise\ProductPermissions;
23use Google\Service\AndroidEnterprise\ProductsApproveRequest;
24use Google\Service\AndroidEnterprise\ProductsGenerateApprovalUrlResponse;
25use Google\Service\AndroidEnterprise\ProductsListResponse;
26
27/**
28 * The "products" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $androidenterpriseService = new Google\Service\AndroidEnterprise(...);
32 *   $products = $androidenterpriseService->products;
33 *  </code>
34 */
35class Products extends \Google\Service\Resource
36{
37  /**
38   * Approves the specified product and the relevant app permissions, if any. The
39   * maximum number of products that you can approve per enterprise customer is
40   * 1,000. To learn how to use managed Google Play to design and create a store
41   * layout to display approved products to your users, see Store Layout Design.
42   * (products.approve)
43   *
44   * @param string $enterpriseId The ID of the enterprise.
45   * @param string $productId The ID of the product.
46   * @param ProductsApproveRequest $postBody
47   * @param array $optParams Optional parameters.
48   */
49  public function approve($enterpriseId, $productId, ProductsApproveRequest $postBody, $optParams = [])
50  {
51    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('approve', [$params]);
54  }
55  /**
56   * Generates a URL that can be rendered in an iframe to display the permissions
57   * (if any) of a product. An enterprise admin must view these permissions and
58   * accept them on behalf of their organization in order to approve that product.
59   * Admins should accept the displayed permissions by interacting with a separate
60   * UI element in the EMM console, which in turn should trigger the use of this
61   * URL as the approvalUrlInfo.approvalUrl property in a Products.approve call to
62   * approve the product. This URL can only be used to display permissions for up
63   * to 1 day. (products.generateApprovalUrl)
64   *
65   * @param string $enterpriseId The ID of the enterprise.
66   * @param string $productId The ID of the product.
67   * @param array $optParams Optional parameters.
68   *
69   * @opt_param string languageCode The BCP 47 language code used for permission
70   * names and descriptions in the returned iframe, for instance "en-US".
71   * @return ProductsGenerateApprovalUrlResponse
72   */
73  public function generateApprovalUrl($enterpriseId, $productId, $optParams = [])
74  {
75    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId];
76    $params = array_merge($params, $optParams);
77    return $this->call('generateApprovalUrl', [$params], ProductsGenerateApprovalUrlResponse::class);
78  }
79  /**
80   * Retrieves details of a product for display to an enterprise admin.
81   * (products.get)
82   *
83   * @param string $enterpriseId The ID of the enterprise.
84   * @param string $productId The ID of the product, e.g.
85   * "app:com.google.android.gm".
86   * @param array $optParams Optional parameters.
87   *
88   * @opt_param string language The BCP47 tag for the user's preferred language
89   * (e.g. "en-US", "de").
90   * @return Product
91   */
92  public function get($enterpriseId, $productId, $optParams = [])
93  {
94    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId];
95    $params = array_merge($params, $optParams);
96    return $this->call('get', [$params], Product::class);
97  }
98  /**
99   * Retrieves the schema that defines the configurable properties for this
100   * product. All products have a schema, but this schema may be empty if no
101   * managed configurations have been defined. This schema can be used to populate
102   * a UI that allows an admin to configure the product. To apply a managed
103   * configuration based on the schema obtained using this API, see Managed
104   * Configurations through Play. (products.getAppRestrictionsSchema)
105   *
106   * @param string $enterpriseId The ID of the enterprise.
107   * @param string $productId The ID of the product.
108   * @param array $optParams Optional parameters.
109   *
110   * @opt_param string language The BCP47 tag for the user's preferred language
111   * (e.g. "en-US", "de").
112   * @return AppRestrictionsSchema
113   */
114  public function getAppRestrictionsSchema($enterpriseId, $productId, $optParams = [])
115  {
116    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId];
117    $params = array_merge($params, $optParams);
118    return $this->call('getAppRestrictionsSchema', [$params], AppRestrictionsSchema::class);
119  }
120  /**
121   * Retrieves the Android app permissions required by this app.
122   * (products.getPermissions)
123   *
124   * @param string $enterpriseId The ID of the enterprise.
125   * @param string $productId The ID of the product.
126   * @param array $optParams Optional parameters.
127   * @return ProductPermissions
128   */
129  public function getPermissions($enterpriseId, $productId, $optParams = [])
130  {
131    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId];
132    $params = array_merge($params, $optParams);
133    return $this->call('getPermissions', [$params], ProductPermissions::class);
134  }
135  /**
136   * Finds approved products that match a query, or all approved products if there
137   * is no query. (products.listProducts)
138   *
139   * @param string $enterpriseId The ID of the enterprise.
140   * @param array $optParams Optional parameters.
141   *
142   * @opt_param bool approved Specifies whether to search among all products
143   * (false) or among only products that have been approved (true). Only "true" is
144   * supported, and should be specified.
145   * @opt_param string language The BCP47 tag for the user's preferred language
146   * (e.g. "en-US", "de"). Results are returned in the language best matching the
147   * preferred language.
148   * @opt_param string maxResults Defines how many results the list operation
149   * should return. The default number depends on the resource collection.
150   * @opt_param string query The search query as typed in the Google Play store
151   * search box. If omitted, all approved apps will be returned (using the
152   * pagination parameters), including apps that are not available in the store
153   * (e.g. unpublished apps).
154   * @opt_param string token Defines the token of the page to return, usually
155   * taken from TokenPagination. This can only be used if token paging is enabled.
156   * @return ProductsListResponse
157   */
158  public function listProducts($enterpriseId, $optParams = [])
159  {
160    $params = ['enterpriseId' => $enterpriseId];
161    $params = array_merge($params, $optParams);
162    return $this->call('list', [$params], ProductsListResponse::class);
163  }
164  /**
165   * Unapproves the specified product (and the relevant app permissions, if any)
166   * (products.unapprove)
167   *
168   * @param string $enterpriseId The ID of the enterprise.
169   * @param string $productId The ID of the product.
170   * @param array $optParams Optional parameters.
171   */
172  public function unapprove($enterpriseId, $productId, $optParams = [])
173  {
174    $params = ['enterpriseId' => $enterpriseId, 'productId' => $productId];
175    $params = array_merge($params, $optParams);
176    return $this->call('unapprove', [$params]);
177  }
178}
179
180// Adding a class alias for backwards compatibility with the previous class name.
181class_alias(Products::class, 'Google_Service_AndroidEnterprise_Resource_Products');
182