/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.as

https://gitlab.com/akkhil2012/swagger-codegen · ActionScript · 276 lines · 120 code · 111 blank · 45 comment · 4 complexity · ba0ce405c1a0cdeb0fc8dda5b0d05fc9 MD5 · raw file

  1. package io.swagger.client.api {
  2. import io.swagger.common.ApiInvoker;
  3. import io.swagger.exception.ApiErrorCodes;
  4. import io.swagger.exception.ApiError;
  5. import io.swagger.common.ApiUserCredentials;
  6. import io.swagger.event.Response;
  7. import io.swagger.common.SwaggerApi;
  8. import io.swagger.client.model.Pet;
  9. import flash.filesystem.File;
  10. import mx.rpc.AsyncToken;
  11. import mx.utils.UIDUtil;
  12. import flash.utils.Dictionary;
  13. import flash.events.EventDispatcher;
  14. public class PetApi extends SwaggerApi {
  15. /**
  16. * Constructor for the PetApi api client
  17. * @param apiCredentials Wrapper object for tokens and hostName required towards authentication
  18. * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
  19. */
  20. public function PetApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
  21. super(apiCredentials, eventDispatcher);
  22. }
  23. public static const event_update_pet: String = "update_pet";
  24. public static const event_add_pet: String = "add_pet";
  25. public static const event_find_pets_by_status: String = "find_pets_by_status";
  26. public static const event_find_pets_by_tags: String = "find_pets_by_tags";
  27. public static const event_get_pet_by_id: String = "get_pet_by_id";
  28. public static const event_update_pet_with_form: String = "update_pet_with_form";
  29. public static const event_delete_pet: String = "delete_pet";
  30. public static const event_upload_file: String = "upload_file";
  31. /*
  32. * Returns void
  33. */
  34. public function update_pet (body: Pet): String {
  35. // create path and map variables
  36. var path: String = "/pet".replace(/{format}/g,"xml");
  37. // query params
  38. var queryParams: Dictionary = new Dictionary();
  39. var headerParams: Dictionary = new Dictionary();
  40. var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams);
  41. var requestId: String = getUniqueId();
  42. token.requestId = requestId;
  43. token.completionEventType = "update_pet";
  44. token.returnType = null ;
  45. return requestId;
  46. }
  47. /*
  48. * Returns void
  49. */
  50. public function add_pet (body: Pet): String {
  51. // create path and map variables
  52. var path: String = "/pet".replace(/{format}/g,"xml");
  53. // query params
  54. var queryParams: Dictionary = new Dictionary();
  55. var headerParams: Dictionary = new Dictionary();
  56. var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
  57. var requestId: String = getUniqueId();
  58. token.requestId = requestId;
  59. token.completionEventType = "add_pet";
  60. token.returnType = null ;
  61. return requestId;
  62. }
  63. /*
  64. * Returns Array
  65. */
  66. public function find_pets_by_status (status: Array = available): String {
  67. // create path and map variables
  68. var path: String = "/pet/findByStatus".replace(/{format}/g,"xml");
  69. // query params
  70. var queryParams: Dictionary = new Dictionary();
  71. var headerParams: Dictionary = new Dictionary();
  72. if("null" != String(status))
  73. queryParams["status"] = toPathValue(status);
  74. var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
  75. var requestId: String = getUniqueId();
  76. token.requestId = requestId;
  77. token.completionEventType = "find_pets_by_status";
  78. token.returnType = Array;
  79. return requestId;
  80. }
  81. /*
  82. * Returns Array
  83. */
  84. public function find_pets_by_tags (tags: Array): String {
  85. // create path and map variables
  86. var path: String = "/pet/findByTags".replace(/{format}/g,"xml");
  87. // query params
  88. var queryParams: Dictionary = new Dictionary();
  89. var headerParams: Dictionary = new Dictionary();
  90. if("null" != String(tags))
  91. queryParams["tags"] = toPathValue(tags);
  92. var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
  93. var requestId: String = getUniqueId();
  94. token.requestId = requestId;
  95. token.completionEventType = "find_pets_by_tags";
  96. token.returnType = Array;
  97. return requestId;
  98. }
  99. /*
  100. * Returns Pet
  101. */
  102. public function get_pet_by_id (petId: Number): String {
  103. // create path and map variables
  104. var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId));
  105. // query params
  106. var queryParams: Dictionary = new Dictionary();
  107. var headerParams: Dictionary = new Dictionary();
  108. var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
  109. var requestId: String = getUniqueId();
  110. token.requestId = requestId;
  111. token.completionEventType = "get_pet_by_id";
  112. token.returnType = Pet;
  113. return requestId;
  114. }
  115. /*
  116. * Returns void
  117. */
  118. public function update_pet_with_form (petId: String, name: String, status: String): String {
  119. // create path and map variables
  120. var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId));
  121. // query params
  122. var queryParams: Dictionary = new Dictionary();
  123. var headerParams: Dictionary = new Dictionary();
  124. var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, null, headerParams);
  125. var requestId: String = getUniqueId();
  126. token.requestId = requestId;
  127. token.completionEventType = "update_pet_with_form";
  128. token.returnType = null ;
  129. return requestId;
  130. }
  131. /*
  132. * Returns void
  133. */
  134. public function delete_pet (petId: Number, apiKey: String): String {
  135. // create path and map variables
  136. var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId));
  137. // query params
  138. var queryParams: Dictionary = new Dictionary();
  139. var headerParams: Dictionary = new Dictionary();
  140. headerParams["apiKey"] = toPathValue(apiKey);
  141. var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams);
  142. var requestId: String = getUniqueId();
  143. token.requestId = requestId;
  144. token.completionEventType = "delete_pet";
  145. token.returnType = null ;
  146. return requestId;
  147. }
  148. /*
  149. * Returns void
  150. */
  151. public function upload_file (petId: Number, additionalMetadata: String, file: File): String {
  152. // create path and map variables
  153. var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId));
  154. // query params
  155. var queryParams: Dictionary = new Dictionary();
  156. var headerParams: Dictionary = new Dictionary();
  157. var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, null, headerParams);
  158. var requestId: String = getUniqueId();
  159. token.requestId = requestId;
  160. token.completionEventType = "upload_file";
  161. token.returnType = null ;
  162. return requestId;
  163. }
  164. }
  165. }