createProduct method

Future<PayPalProduct> createProduct({
  1. required Prefer prefer,
  2. required String payPalRequestID,
  3. required String id,
  4. required String name,
  5. required String description,
  6. required String category,
})

Implementation

Future<PayPalProduct> createProduct({
  ///The preferred server response upon successful completion of the request. Value is:
  ///return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.
  ///return=representation. The server returns a complete resource representation, including the current state of the resource.
  required Prefer prefer,
  ///Contains a unique user-generated ID that the server stores for a period of time. Use this header to enforce idempotency on REST API POST calls. You can make these calls any number of times without concern that the server creates or completes an action on a resource more than once.
  required String payPalRequestID,
  ///The ID of the product. You can specify the SKU for the product. If you omit the ID, the system generates it. System-generated IDs have the PROD- prefix.
  ///Minimum length: 6.
  ///Maximum length: 50.
  required String id,
  ///The product name.
  ///Minimum length: 1.
  ///Maximum length: 127.
  required String name,
  ///The product description.
  ///Minimum length: 1.
  ///Maximum length: 256.
  required String description,
  ///The product type. Indicates whether the product is physical or tangible goods, or a service.
  //required ProductType productType,
  ///The product category.
  required String category,
  ///The image URL for the product.
  ///Minimum length: 1
  ///Maximum length: 2000.
  //required String image_url,
  ///The home page URL for the product.
  ///Minimum length: 1
  ///Maximum length: 2000.
  //required String home_url,
})async{
  Map<String,dynamic> parameters = {
    "id" : id,
    "name" : name,
    //Adding the properties below throws an error
    "description" : description,
    //"type" : _enumToString(productType),
    "category" : category,
    //"image_url" : image_url,
    //"home_url" : home_url,
  };
  String response = await SexyAPI(
    url: _url,
    path: "/v1/catalogs/products",
    parameters: {},
  ).post(
    headers: {
      "Authorization" : "Bearer ${accessToken.access_token}",
      "Content-Type" : "application/json",
      "Prefer" : "return=${_enumToString(prefer)}",
      "PayPal-Request-Id" : payPalRequestID,
    },
    body: jsonEncode(parameters),
  );
  return PayPalProduct.parse(_parseResponse(response));
}