pet.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // @ts-ignore
  2. /* eslint-disable */
  3. import { request } from 'umi';
  4. /** Update an existing pet PUT /pet */
  5. export async function updatePet (body, options) {
  6. return request('/pet', {
  7. method: 'PUT',
  8. headers: {
  9. 'Content-Type': 'application/json',
  10. },
  11. data: body,
  12. ...(options || {}),
  13. });
  14. }
  15. /** Add a new pet to the store POST /pet */
  16. export async function addPet (body, options) {
  17. return request('/pet', {
  18. method: 'POST',
  19. headers: {
  20. 'Content-Type': 'application/json',
  21. },
  22. data: body,
  23. ...(options || {}),
  24. });
  25. }
  26. /** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
  27. export async function findPetsByStatus (params, options) {
  28. return request('/pet/findByStatus', {
  29. method: 'GET',
  30. params: { ...params },
  31. ...(options || {}),
  32. });
  33. }
  34. /** Finds Pets by tags Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
  35. export async function findPetsByTags (params, options) {
  36. return request('/pet/findByTags', {
  37. method: 'GET',
  38. params: { ...params },
  39. ...(options || {}),
  40. });
  41. }
  42. /** Find pet by ID Returns a single pet GET /pet/${param0} */
  43. export async function getPetById (params, options) {
  44. const { petId: param0 } = params;
  45. return request(`/pet/${param0}`, {
  46. method: 'GET',
  47. params: { ...params },
  48. ...(options || {}),
  49. });
  50. }
  51. /** Updates a pet in the store with form data POST /pet/${param0} */
  52. export async function updatePetWithForm (params, body, options) {
  53. const { petId: param0 } = params;
  54. const formData = new FormData();
  55. Object.keys(body).forEach((ele) => {
  56. const item = body[ele];
  57. if (item !== undefined && item !== null) {
  58. formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
  59. }
  60. });
  61. return request(`/pet/${param0}`, {
  62. method: 'POST',
  63. headers: {
  64. 'Content-Type': 'application/x-www-form-urlencoded',
  65. },
  66. params: { ...params },
  67. data: formData,
  68. ...(options || {}),
  69. });
  70. }
  71. /** Deletes a pet DELETE /pet/${param0} */
  72. export async function deletePet (params, options) {
  73. const { petId: param0 } = params;
  74. return request(`/pet/${param0}`, {
  75. method: 'DELETE',
  76. params: { ...params },
  77. ...(options || {}),
  78. });
  79. }
  80. /** uploads an image POST /pet/${param0}/uploadImage */
  81. export async function uploadFile (params, body, options) {
  82. const { petId: param0 } = params;
  83. const formData = new FormData();
  84. Object.keys(body).forEach((ele) => {
  85. const item = body[ele];
  86. if (item !== undefined && item !== null) {
  87. formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
  88. }
  89. });
  90. return request(`/pet/${param0}/uploadImage`, {
  91. method: 'POST',
  92. headers: {
  93. 'Content-Type': 'multipart/form-data',
  94. },
  95. params: { ...params },
  96. data: formData,
  97. ...(options || {}),
  98. });
  99. }