pet.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // @ts-ignore
  2. /* eslint-disable */
  3. import { request } from 'umi';
  4. /** Update an existing pet PUT /pet */
  5. export async function updatePet(body: API.Pet, options?: { [key: string]: any }) {
  6. return request<any>('/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: API.Pet, options?: { [key: string]: any }) {
  17. return request<any>('/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(
  28. params: {
  29. // query
  30. /** Status values that need to be considered for filter */
  31. status: 'available' | 'pending' | 'sold'[];
  32. },
  33. options?: { [key: string]: any },
  34. ) {
  35. return request<API.Pet[]>('/pet/findByStatus', {
  36. method: 'GET',
  37. params: {
  38. ...params,
  39. },
  40. ...(options || {}),
  41. });
  42. }
  43. /** Finds Pets by tags Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
  44. export async function findPetsByTags(
  45. params: {
  46. // query
  47. /** Tags to filter by */
  48. tags: string[];
  49. },
  50. options?: { [key: string]: any },
  51. ) {
  52. return request<API.Pet[]>('/pet/findByTags', {
  53. method: 'GET',
  54. params: {
  55. ...params,
  56. },
  57. ...(options || {}),
  58. });
  59. }
  60. /** Find pet by ID Returns a single pet GET /pet/${param0} */
  61. export async function getPetById(
  62. params: {
  63. // path
  64. /** ID of pet to return */
  65. petId: number;
  66. },
  67. options?: { [key: string]: any },
  68. ) {
  69. const { petId: param0 } = params;
  70. return request<API.Pet>(`/pet/${param0}`, {
  71. method: 'GET',
  72. params: { ...params },
  73. ...(options || {}),
  74. });
  75. }
  76. /** Updates a pet in the store with form data POST /pet/${param0} */
  77. export async function updatePetWithForm(
  78. params: {
  79. // path
  80. /** ID of pet that needs to be updated */
  81. petId: number;
  82. },
  83. body: { name?: string; status?: string },
  84. options?: { [key: string]: any },
  85. ) {
  86. const { petId: param0 } = params;
  87. const formData = new FormData();
  88. Object.keys(body).forEach((ele) => {
  89. const item = (body as any)[ele];
  90. if (item !== undefined && item !== null) {
  91. formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
  92. }
  93. });
  94. return request<any>(`/pet/${param0}`, {
  95. method: 'POST',
  96. headers: {
  97. 'Content-Type': 'application/x-www-form-urlencoded',
  98. },
  99. params: { ...params },
  100. data: formData,
  101. ...(options || {}),
  102. });
  103. }
  104. /** Deletes a pet DELETE /pet/${param0} */
  105. export async function deletePet(
  106. params: {
  107. // header
  108. api_key?: string;
  109. // path
  110. /** Pet id to delete */
  111. petId: number;
  112. },
  113. options?: { [key: string]: any },
  114. ) {
  115. const { petId: param0 } = params;
  116. return request<any>(`/pet/${param0}`, {
  117. method: 'DELETE',
  118. params: { ...params },
  119. ...(options || {}),
  120. });
  121. }
  122. /** uploads an image POST /pet/${param0}/uploadImage */
  123. export async function uploadFile(
  124. params: {
  125. // path
  126. /** ID of pet to update */
  127. petId: number;
  128. },
  129. body: { additionalMetadata?: string; file?: string },
  130. options?: { [key: string]: any },
  131. ) {
  132. const { petId: param0 } = params;
  133. const formData = new FormData();
  134. Object.keys(body).forEach((ele) => {
  135. const item = (body as any)[ele];
  136. if (item !== undefined && item !== null) {
  137. formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
  138. }
  139. });
  140. return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
  141. method: 'POST',
  142. headers: {
  143. 'Content-Type': 'multipart/form-data',
  144. },
  145. params: { ...params },
  146. data: formData,
  147. ...(options || {}),
  148. });
  149. }