LocationsQuestionsAnswers.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. namespace Google\Service\MyBusinessQA\Resource;
  18. use Google\Service\MyBusinessQA\Answer;
  19. use Google\Service\MyBusinessQA\ListAnswersResponse;
  20. use Google\Service\MyBusinessQA\MybusinessqandaEmpty;
  21. use Google\Service\MyBusinessQA\UpsertAnswerRequest;
  22. /**
  23. * The "answers" collection of methods.
  24. * Typical usage is:
  25. * <code>
  26. * $mybusinessqandaService = new Google\Service\MyBusinessQA(...);
  27. * $answers = $mybusinessqandaService->answers;
  28. * </code>
  29. */
  30. class LocationsQuestionsAnswers extends \Google\Service\Resource
  31. {
  32. /**
  33. * Deletes the answer written by the current user to a question.
  34. * (answers.delete)
  35. *
  36. * @param string $name Required. The name of the question to delete an answer
  37. * for.
  38. * @param array $optParams Optional parameters.
  39. * @return MybusinessqandaEmpty
  40. */
  41. public function delete($name, $optParams = [])
  42. {
  43. $params = ['name' => $name];
  44. $params = array_merge($params, $optParams);
  45. return $this->call('delete', [$params], MybusinessqandaEmpty::class);
  46. }
  47. /**
  48. * Returns the paginated list of answers for a specified question.
  49. * (answers.listLocationsQuestionsAnswers)
  50. *
  51. * @param string $parent Required. The name of the question to fetch answers
  52. * for.
  53. * @param array $optParams Optional parameters.
  54. *
  55. * @opt_param string orderBy Optional. The order to return the answers. Valid
  56. * options include 'update_time desc' and 'upvote_count desc', which will return
  57. * the answers sorted descendingly by the requested field. The default sort
  58. * order is 'update_time desc'.
  59. * @opt_param int pageSize Optional. How many answers to fetch per page. The
  60. * default and maximum `page_size` values are 10.
  61. * @opt_param string pageToken Optional. If specified, the next page of answers
  62. * is retrieved.
  63. * @return ListAnswersResponse
  64. */
  65. public function listLocationsQuestionsAnswers($parent, $optParams = [])
  66. {
  67. $params = ['parent' => $parent];
  68. $params = array_merge($params, $optParams);
  69. return $this->call('list', [$params], ListAnswersResponse::class);
  70. }
  71. /**
  72. * Creates an answer or updates the existing answer written by the user for the
  73. * specified question. A user can only create one answer per question.
  74. * (answers.upsert)
  75. *
  76. * @param string $parent Required. The name of the question to write an answer
  77. * for.
  78. * @param UpsertAnswerRequest $postBody
  79. * @param array $optParams Optional parameters.
  80. * @return Answer
  81. */
  82. public function upsert($parent, UpsertAnswerRequest $postBody, $optParams = [])
  83. {
  84. $params = ['parent' => $parent, 'postBody' => $postBody];
  85. $params = array_merge($params, $optParams);
  86. return $this->call('upsert', [$params], Answer::class);
  87. }
  88. }
  89. // Adding a class alias for backwards compatibility with the previous class name.
  90. class_alias(LocationsQuestionsAnswers::class, 'Google_Service_MyBusinessQA_Resource_LocationsQuestionsAnswers');