create method

Future<IHometown> create(
  1. IHometown hometown
)
override

Implementation

Future<IHometown> create(
  IHometown hometown,
) async {
  final builder = RequestBuilder();
  builder.body = hometown;
  if (hometown == null) {
    throw BadRequestException.singleField(
      "hometown",
      "Missing required request parameter",
      keyword: "required",
    );
  }

  // create path and map variables
  // create path and map variables
  builder.path = "/sunny/0.0.1/fact/hometown";
  List<String> contentTypes = [];
  String contentType =
      contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
  builder.contentType = contentType;
  builder.basePath = apiClient.basePaths["facts"];
  builder.method = HttpMethod.POST;

  final response = await apiClient.invokeRequest(builder);
  final value = json.decode(response.body);
  return IHometown.fromJson(value);
}