# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

openapi: 3.0.2
info:
  description: API for managing Currency resources.
  version: 1.0.0
  title: Orders API
servers:
  - url: "{SERVER_URL}/v1/orderservices"
security:
  - ApiKeyAuth: []
paths:
  /orders:
    post:
      summary: Create a new order
      description: Submit a new order to the boutique shop
      requestBody:
        description: Order payload
        required: true
        content:
          application/json:
            example:
              user_id: your_user_id
              email: your_email@example.com
              currency: USD
              items:
                - id: 6E92ZMYYFZ
                  quantity: 2
              address:
                street: 1600 Pennsylvania Avenue NW
                city: Washington
                state: DC
                country: US
                zip: 20500
              credit_card:
                number: '4263982640269299'
                cvv: 837
                exp_year: 2023
                exp_month: 2

            schema:
              $ref: '#/components/schemas/hipstershop.OrderRequest'
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: apikey
      in: query
  schemas:
    hipstershop.OrderRequest:
      properties:
        user_id:
          type: string
        email:
          type: string
        currency:
          type: string
        address:
          "$ref": "#/components/schemas/hipstershop.OrderAddress"
          additionalProperties: false
        items:
          items:
            "$ref": "#/components/schemas/hipstershop.OrderRequestItem"
          type: array
        credit_card:
          "$ref": "#/components/schemas/hipstershop.OrderCC"
          additionalProperties: false
      additionalProperties: false
      type: object
      title: Order Request
    hipstershop.OrderAddress:
      properties:
        street:
          type: string
        city:
          type: string
        state:
          type: string
        country:
          type: string
        zip:
          type: integer
      additionalProperties: false
      type: object
      title: Order Address
    hipstershop.OrderCC:
      properties:
        number:
          type: string
        cvv:
          type: integer
        exp_year:
          type: integer
        exp_month:
          type: integer
      additionalProperties: false
      type: object
      title: Order CC
    hipstershop.OrderRequestItem:
      properties:
        id:
          type: string
        quantity:
          type: integer
      additionalProperties: false
      type: object
      title: Order Request Item
    OrderResponse:
      properties:
        id:
          type: string
        shipping_id:
          type: string
        shipping_cost:
          type: number
        shipping_address:
          "$ref": "#/components/schemas/hipstershop.OrderAddress"
          additionalProperties: false
        items:
          items:
            "$ref": "#/components/schemas/hipstershop.OrderResponseItem"
          type: array
      additionalProperties: false
      type: object
      title: Order Response
    hipstershop.OrderResponseItem:
      properties:
        id:
          type: string
        quantity:
          type: integer
        cost:
          type: number
      additionalProperties: false
      type: object
      title: Order Response Item