{
  "openapi": "3.0.0",
  "info": {
    "version": "v2",
    "title": "Tire Reviews & Ratings",
    "description": "This API provides the latest ratings and reviews for Michelin 4-wheeler and motorbikes tyres, which provide useful insights and facilitate customer analysis",
    "contact": {
      "name": "API Support",
      "email": "difapiteam@michelin.com",
      "url": "https://indus.developer.michelin.com/en/contact"
    }
  },
  "servers": [
    {
      "url": "https://indus.api.michelin.com/tyre-reviews/v2",
      "description": "Indus"
    }
  ],
  "components": {
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://indus.api.michelin.com/idp/v1/internal/oauth/token/accesstoken?grant_type=client_credentials",
            "scopes": {
              "cxf-tyre-reviews-v2": "This scope grants access to read review data, including product reviews, ratings, and associated metadata."
            }
          }
        }
      }
    },
    "schemas": {
      "ReviewsResponse": {
        "type": "object",
        "properties": {
          "totalCount": {
            "type": "integer",
            "description": "Total number of reviews for the given locale. This is the total count of reviews that match the provided filters."
          },
          "reviews": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Review"
            }
          }
        },
        "required": ["totalCount", "reviews"]
      },
      "Review": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string",
            "description": "Product Id productLine-globalId example 4W-99."
          },
          "product_name": {
            "type": "string",
            "description": "Name of the product associated with the review in Capitalized format, e.g., 'DEFENDER 2'. If product_name is null, it will be set to an empty string."
          },
          "brand": {
            "type": "string",
            "description": "Brand of the product in Capitalized format, e.g., 'MICHELIN', 'BFG'. If brand is null, It will be set to an empty string. Example: for CSV it will be empty string."
          },
          "review_date": {
            "type": "string",
            "format": "date-time",
            "description": "Date when the review was created. This is in ISO 8601 format, e.g., '2023-10-01T12:00:00Z'."
          },
          "purchase_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Date when the product was purchased, when missing it will be set to null. This is in ISO 8601 format, e.g., '2023-09-15T12:00:00Z'."
          },
          "locale": {
            "type": "string",
            "description": "Locale of the review language_CountryCode, e.g., 'en_US'. This indicates the language and country of the review."
          },
          "incentive": {
            "type": "boolean",
            "description": "Indicates if the review was incentivized. This is a boolean value where true means the review was incentivized and false means it was not."
          },
          "provider": {
            "type": "string",
            "enum": ["AVIS_VERIFIES", "DRIVER_REVIEWS", "BAZAARVOICE", "CSV"],
            "description": "Provider of the review example: 'AVIS_VERIFIES','DRIVER_REVIEWS','BAZAARVOICE','CSV'. This indicates the source of the review data."
          },
          "is_original": {
            "type": "boolean",
            "description": "Indicates if the review is original or translated. This is a boolean value where true means the review is original and false means it is a translated version."
          },
          "rating": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 100,
            "description": "Rating given in the review, scale of 100."
          },
          "michelin_response": {
            "type": "boolean",
            "description": "Indicates if Michelin consumer care has responded to the review. This is a boolean value where true means Michelin consumer care has responded and false means they have not."
          }
        },
        "required": ["product_id", "product_name", "brand", "review_date", "locale", "incentive", "provider", "is_original", "rating", "michelin_response"]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message indicating the issue with the request"
          }
        },
        "required": ["error"]
      }
    }
  },
  "paths": {
    "/reviews": {
      "get": {
        "summary": "Get paginated reviews Information in JSON format",
        "description": "Returns a list of reviews in JSON format, with pagination support.",
        "parameters": [
          {
            "in": "query",
            "name": "locale",
            "required": true,
            "description": "Locale for the reviews, e.g., 'en_US'.<br>This parameter is required to filter reviews by language and country.",
            "schema": {
              "type": "string",
              "description": "Locale for the reviews, <br>e.g., 'en_US'",
              "example": "en_US"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "description": "Number of items to skip for pagination.",
            "schema": {
              "type": "integer",
              "default": 0,
              "minimum": 0
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "Number of items to return per page.<br>Maximum is 1000.<br>If higher than 1000, it will set at 1000.",
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "in": "query",
            "name": "brands",
            "required": false,
            "description": "Comma-separated list of brands to filter reviews, e.g., 'MICHELIN,BFG'. <br>Supported brands: MICHELIN, BFG, KLEBER.<br><br>By default, returns data for all brands if no brand is specified.",
            "schema": {
              "type": "string",
              "example": "MICHELIN,BFG,KLEBER"
            }
          },
          {
            "in": "query",
            "name": "providers",
            "required": false,
            "description": "Comma-separated list of providers to filter reviews, <br>e.g., 'AVIS_VERIFIES,DRIVER_REVIEWS,BAZAARVOICE,CSV'. <br>Supported providers: AVIS_VERIFIES, DRIVER_REVIEWS, BAZAARVOICE,CSV. <br><br>By default, returns data for all providers if no provider is specified.",
            "schema": {
              "type": "string",
              "example": "AVIS_VERIFIES,DRIVER_REVIEWS,BAZAARVOICE,CSV"
            }
          },
          {
            "in": "header",
            "name": "Authorization",
            "required": true,
            "description": "OAuth2 Bearer token for authentication. Format: 'Bearer {token}'",
            "schema": {
              "type": "string",
              "example": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
            }
          },
          {
            "name": "apikey",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "API key for authentication"
          }
        ],
        "responses": {
          "200": {
            "description": "A list of reviews in JSON format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewsResponse"
                },
                "example": {
                  "totalCount": 100,
                  "reviews": [
                    {
                      "product_id": "4W-504",
                      "product_name": "DEFENDER2",
                      "brand": "MICHELIN",
                      "review_date": "2023-10-01T12:00:00Z",
                      "purchase_date": "2023-09-15T12:00:00Z",
                      "locale": "en_US",
                      "incentive": false,
                      "provider": "CSV",
                      "is_original": true,
                      "rating": 4.5,
                      "michelin_response": true
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Missing or invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "missingLocale": {
                    "summary": "Missing locale parameter",
                    "value": {
                      "error": "Missing locale parameter"
                    }
                  },
                  "invalidBrands": {
                    "summary": "Invalid brands parameter",
                    "value": {
                      "error": "Invalid brands parameter. Supported brands: MICHELIN, BFG, KLEBER."
                    }
                  },
                  "invalidProviders": {
                    "summary": "Invalid providers parameter",
                    "value": {
                      "error": "Invalid providers parameter. Supported providers: AVIS_VERIFIES, DRIVER_REVIEWS, BAZAARVOICE, CSV."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing authentication token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidToken": {
                    "summary": "Invalid OAuth2 token",
                    "value": {
                      "error": "Invalid or expired OAuth2 token"
                    }
                  },
                  "missingToken": {
                    "summary": "Missing Authorization header",
                    "value": {
                      "error": "Authorization header is required"
                    }
                  },
                  "invalidFormat": {
                    "summary": "Invalid token format",
                    "value": {
                      "error": "Authorization header must be in format 'Bearer {token}'"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Insufficient permissions to access this resource"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error - An unexpected error occurred",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Internal server error"
                }
              }
            }
          }
        },
        "security": [
          {
            "OAuth2": ["cxf-tyre-reviews-v2"]
          }
        ]
      }
    }
  }
}
