From d319f977334804837de367385fbc352f2545bee3 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 10 Sep 2019 10:46:37 +0100 Subject: [PATCH 01/16] Remove now unexisting endpoints zones, states and countries --- swagger.yaml | 210 +-------------------------------------------------- 1 file changed, 2 insertions(+), 208 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 18feed30fe..976961652a 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -10,16 +10,10 @@ tags: description: Product endpoints - name: product variants description: Product variant endpoints - - name: zones - description: Zone endpoints - - name: states - description: State endpoints - name: taxonomies description: Taxonomy endpoints - name: taxons description: Taxon endpoints - - name: countries - description: Country endpoints - name: cookies_consent description: Cookies_Consent endpoints - name: orders @@ -305,151 +299,7 @@ paths: responses: '204': description: successful deletion - - /zones: - get: - description: Gets all Zones. - tags: - - zones - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: object - properties: - count: - type: integer - current_page: - type: integer - pages: - type: integer - zones: - type: array - items: - $ref: '#/components/schemas/Zone' - post: - description: Posts a new Zone. - tags: - - zones - parameters: - - in: path - name: zone_object - schema: - type: object - properties: - zone: - $ref: '#/components/schemas/Zone' - required: true - description: JSON object representing the Zone to be posted. Only attributes listed in the Zone required_attributes object are required (obtainable via GET /zones/new). - responses: - '201': - description: successful post - content: - application/json: - schema: - $ref: '#/components/schemas/Zone' - - /zones/{zone_id}: - get: - description: Gets a Zone by ID. - tags: - - zones - parameters: - - in: path - name: zone_id - schema: - type: integer - required: true - description: Numeric ID of the Zone. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Zone' - put: - description: Updates the Zone with the given ID. - tags: - - zones - parameters: - - in: path - name: zone_id - schema: - type: integer - required: true - description: Numeric ID of the Zone. - - in: path - name: zone_object - schema: - type: object - properties: - zone: - $ref: '#/components/schemas/Zone' - required: true - description: JSON object representing the Zone attributes to be overwritten. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Zone' - delete: - description: Deletes the Zone with the given ID. - tags: - - zones - parameters: - - in: path - name: zone_id - schema: - type: integer - required: true - description: Numeric ID of the Zone. - responses: - '204': - description: successful deletion - - /states: - get: - description: Gets all States. - tags: - - states - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: object - properties: - states: - type: array - items: - $ref: '#/components/schemas/State' - - /states/{state_id}: - get: - description: Get a State with the given ID. - tags: - - states - parameters: - - in: path - name: state_id - schema: - type: integer - required: true - description: Numeric ID of the State. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/State' - + /taxonomies: get: description: Gets all Taxonomies. @@ -733,51 +583,7 @@ paths: responses: '204': description: successful deletion - - /countries: - get: - description: Gets all Countries. - tags: - - countries - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: object - properties: - count: - type: string - current_page: - type: integer - countries: - type: array - items: - $ref: '#/components/schemas/Country' - pages: - type: integer - - /countries/{country_id}: - get: - description: Gets the country with the given ID. - tags: - - countries - parameters: - - in: path - name: country_id - schema: - type: integer - required: true - description: Numeric ID of the Country. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Country' - + /cookies/consent: get: description: Gets the client's Cookies_Consent status. @@ -937,18 +743,6 @@ components: type: object images: type: object - Zone: - type: object - properties: - id: - type: integer - description: - type: string - zone_members: - type: array - items: {} - name: - type: string Taxonomy: type: object properties: From a2e6b84db2de0eabfa64dc95f00ecd0b47c9b26b Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 10 Sep 2019 17:19:25 +0100 Subject: [PATCH 02/16] List the actual actions available in the api/products endpoint --- swagger.yaml | 100 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 24 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 976961652a..e1ba780792 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -18,9 +18,9 @@ tags: description: Cookies_Consent endpoints - name: orders description: Order endpoints - + paths: - /products: + /products/bulk_products: get: description: Gets all Products. tags: @@ -33,18 +33,36 @@ paths: schema: type: object properties: - count: - type: integer - total_count: - type: integer + pagination: + $ref: '#/components/schemas/Pagination' pages: type: integer products: type: array items: $ref: '#/components/schemas/Product' - current_page: + /products/overridable: + get: + description: Gets all Products. + tags: + - products + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + properties: + pagination: + $ref: '#/components/schemas/Pagination' + pages: type: integer + products: + type: array + items: + $ref: '#/components/schemas/Product' + /products: post: description: Posts a new Product. tags: @@ -58,7 +76,7 @@ paths: product: $ref: '#/components/schemas/Product' required: true - description: JSON object representing the Product to be posted. Only attributes listed in the Product required_attributes object are required (obtainable via GET /products/new). + description: JSON object representing the Product to be posted. responses: '201': description: successful post @@ -66,20 +84,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Product' - - /products/new: - get: - description: Gets an object consisting of an array of all Product attributes and an array of required attributes to create a new Product object. - tags: - - products - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/New' - + /products/{product_id}: get: description: Gets a Product by ID. @@ -140,7 +145,43 @@ paths: responses: '204': description: successful deletion - + + /products/{product_id}/clone: + post: + description: Clones a Product by ID. + tags: + - products + parameters: + - in: path + name: product_id + schema: + type: integer + required: true + description: Numeric ID of the Product to clone. + responses: + '201': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Product' + + /products/{product_id}/soft_delete: + delete: + description: Soft deletes the Product with the given ID. + tags: + - products + parameters: + - in: path + name: product_id + schema: + type: integer + required: true + description: Numeric ID of the Product. + responses: + '204': + description: successful deletion + /products/{product_id}/variants: get: description: Gets all Variants of the given Product. @@ -299,7 +340,7 @@ paths: responses: '204': description: successful deletion - + /taxonomies: get: description: Gets all Taxonomies. @@ -667,6 +708,17 @@ components: name: api_key in: header schemas: + Pagination: + type: object + properties: + results: + type: integer + pages: + type: integer + page: + type: integer + per_page: + type: integer Product: type: object properties: From 0dede396176e47760192c02dc2afe25905663280 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 11 Sep 2019 11:15:55 +0100 Subject: [PATCH 03/16] Make list of /products/{product_id}/variants endpoints correct according to current code --- swagger.yaml | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index e1ba780792..a658344f75 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -241,27 +241,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Variant' - - /products/{product_id}/variants/new: - get: - description: Gets an object consisting of an array of all Variant attributes and an array of required attributes to create a new Variant object. - tags: - - product variants - parameters: - - in: path - name: product_id - schema: - type: integer - required: true - description: Numeric ID of the Product. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/New' - + /products/{product_id}/variants/{variant_id}: get: description: Gets a Variant by ID. @@ -341,6 +321,28 @@ paths: '204': description: successful deletion + /products/{product_id}/variants/{variant_id}/soft_delete: + delete: + description: Soft-deletes the Variant with the given ID. + tags: + - product variants + parameters: + - in: path + name: product_id + schema: + type: integer + required: true + description: Numeric ID of the Product. + - in: path + name: variant_id + schema: + type: integer + required: true + description: Numeric ID of the Variant. + responses: + '204': + description: successful deletion + /taxonomies: get: description: Gets all Taxonomies. From 5634f4af187dd2a1c5b9720c10f0dc3b886f3b6f Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 11 Sep 2019 11:24:56 +0100 Subject: [PATCH 04/16] Move orders endpoints above in the file as they are the most important endpoints --- swagger.yaml | 87 ++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index a658344f75..58c00d039d 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -10,14 +10,14 @@ tags: description: Product endpoints - name: product variants description: Product variant endpoints + - name: orders + description: Order endpoints - name: taxonomies description: Taxonomy endpoints - name: taxons description: Taxon endpoints - name: cookies_consent description: Cookies_Consent endpoints - - name: orders - description: Order endpoints paths: /products/bulk_products: @@ -343,6 +343,46 @@ paths: '204': description: successful deletion + /orders: + get: + description: Gets all Orders. + tags: + - orders + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + properties: + orders: + type: array + items: + $ref: '#/components/schemas/Order_Concise' + pagination: + type: string + + /orders/{order_number}: + get: + description: Gets the Order with the given number. + tags: + - orders + parameters: + - in: path + name: order_number + schema: + type: string + required: true + description: Alphanumeric string identifier for the Order. + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Order_Verbose' + /taxonomies: get: description: Gets all Taxonomies. @@ -661,48 +701,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Cookies_Consent' - - /orders: - get: - description: Gets all Orders. - tags: - - orders - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: object - properties: - orders: - type: array - items: - $ref: '#/components/schemas/Order_Concise' - pagination: - type: string - - /orders/{order_number}: - get: - description: Gets the Order with the given number. - tags: - - orders - parameters: - - in: path - name: order_number - schema: - type: string - required: true - description: Alphanumeric string identifier for the Order. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Order_Verbose' - - + components: securitySchemes: api_key: From 0e4b5ad9ecbac5bd53da7310cd71a4b066d9ec79 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 11 Sep 2019 11:33:33 +0100 Subject: [PATCH 05/16] Remove now gone orders/{order_number} endpoint and its models, may be readded in the near future but the models may be different as these docs refer to the now gone spree_api order rabl representation --- swagger.yaml | 215 +-------------------------------------------------- 1 file changed, 1 insertion(+), 214 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 58c00d039d..17498a3e5e 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -363,26 +363,6 @@ paths: pagination: type: string - /orders/{order_number}: - get: - description: Gets the Order with the given number. - tags: - - orders - parameters: - - in: path - name: order_number - schema: - type: string - required: true - description: Alphanumeric string identifier for the Order. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Order_Verbose' - /taxonomies: get: description: Gets all Taxonomies. @@ -826,30 +806,6 @@ components: type: integer parent_id: type: integer - State: - type: object - properties: - name: - type: string - abbr: - type: string - id: - type: integer - country_id: - type: integer - Country: - type: object - properties: - count: - type: integer - current_page: - type: integer - pages: - type: string - countries: - type: array - items: - type: string Cookies_Consent: type: object properties: @@ -909,173 +865,4 @@ components: type: object properties: id: - type: integer - Order_Verbose: - type: object - properties: - id: - type: integer - number: - type: string - item_total: - type: string - total: - type: string - state: - type: string - adjustment_total: - type: string - user_id: - type: integer - created_at: - type: string - updated_at: - type: string - completed_at: - type: string - payment_total: - type: string - shipment_state: - type: string - payment_state: - type: string - email: - type: string - special_instructions: - type: string - bill_address: - $ref: '#/components/schemas/Address' - ship_address: - $ref: '#/components/schemas/Address' - line_items: - type: array - items: - $ref: '#/components/schemas/Product' - payments: - type: array - items: - $ref: '#/components/schemas/Payment' - shipments: - type: array - items: - $ref: '#/components/schemas/Shipment' - adjustments: - type: array - items: - $ref: '#/components/schemas/Adjustment' - credit_cards: - type: array - items: {} - - Address: - type: object - properties: - id: - type: integer - firstname: - type: string - lastname: - type: string - address1: - type: string - address2: - type: string - city: - type: string - zipcode: - type: string - phone: - type: string - company: - type: string - alternative_phone: - type: string - country_id: - type: integer - state_id: - type: integer - state_name: - type: string - country: - $ref: '#/components/schemas/Country' - state: - $ref: '#/components/schemas/State' - Payment: - type: object - properties: - id: - type: integer - amount: - type: string - state: - type: string - payment_method_id: - type: integer - payment_method: - $ref: '#/components/schemas/Payment_Method' - Payment_Method: - type: object - properties: - id: - type: integer - name: - type: string - environment: - type: string - Shipment: - type: object - properties: - id: - type: integer - tracking: - type: string - number: - type: string - cost: - type: string - shipped_at: - type: string - state: - type: string - order_id: - type: string - shipping_method: - $ref: '#/components/schemas/Shipping_Method' - Shipping_Method: - type: object - properties: - name: - type: string - zone_id: - type: integer - shipping_category_id: - type: string - Adjustment: - type: object - properties: - id: - type: integer - source_type: - type: string - source_id: - type: integer - adjustable_type: - type: string - adjustable_id: - type: integer - originator_type: - type: string - originator_id: - type: integer - amount: - type: string - label: - type: string - mandatory: - type: boolean - eligible: - type: boolean - created_at: - type: string - updated_at: - type: string \ No newline at end of file + type: integer \ No newline at end of file From 664be47ac3d4f789bb500461359000ef17c9a339 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 13:08:39 +0100 Subject: [PATCH 06/16] Add endpoints for /orders/shipments --- swagger.yaml | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/swagger.yaml b/swagger.yaml index 17498a3e5e..cfcb3b13b1 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -12,6 +12,8 @@ tags: description: Product variant endpoints - name: orders description: Order endpoints + - name: shipments + description: Order shipments endpoints - name: taxonomies description: Taxonomy endpoints - name: taxons @@ -363,6 +365,178 @@ paths: pagination: type: string + /orders/{order_number}/shipments.json: + post: + description: Creates a new Shipment and adds given variant. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: variant_id + schema: + type: integer + required: true + description: Numeric ID of the Variant to be added to the shipment. + - in: path + name: quantity + schema: + type: integer + required: true + description: Quantity of the variant to be added to the shipment. + - in: path + name: stock_location_id + schema: + type: integer + required: true + description: Stock location ID to be used to source the variant (for each OFN there's only one valid ID to be used here). + responses: + '201': + description: Shipment successfully created + /orders/{order_number}/shipments/{shipment_number}.json: + put: + description: Updates shipment. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: shipment_number + schema: + type: integer + required: true + description: Number (not id) of the Shipment being changed. + - in: path + name: shipment_object + schema: + type: object + properties: + product: + $ref: '#/components/schemas/Shipment' + required: true + description: JSON object representing the Shipmeent attributes to be overwritten. + responses: + '200': + description: Successful operation. + /orders/{order_number}/shipments/{shipment_number}/add.json: + put: + description: Adds a variant quantity to the given shipment. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: shipment_number + schema: + type: integer + required: true + description: Number (not id) of the Shipment being changed. + - in: path + name: variant_id + schema: + type: integer + required: true + description: Numeric ID of the Variant to be added to the shipment. + - in: path + name: quantity + schema: + type: integer + required: true + description: Quantity of the variant to be added to the shipment. + responses: + '200': + description: Variant quantity successfully added. + /orders/{order_number}/shipments/{shipment_number}/remove.json: + delete: + description: Removes a variant from the given shipment. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: shipment_number + schema: + type: integer + required: true + description: Number (not id) of the Shipment being changed. + - in: path + name: variant_id + schema: + type: integer + required: true + description: Numeric ID of the Variant to be removed from the shipment. + - in: path + name: quantity + schema: + type: integer + required: true + description: Quantity of the variant to be removed from the shipment. + responses: + '200': + description: Variant quantity successfully rmeoved. + /orders/{order_number}/shipments/{shipment_number}/ready.json: + delete: + description: Moves the shipment to the ready state. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: shipment_number + schema: + type: integer + required: true + description: Number (not id) of the Shipment being changed. + responses: + '200': + description: Successful workflow change. + /orders/{order_number}/shipments/{shipment_number}/ship.json: + delete: + description: Moves the shipment to the shipped state. + tags: + - shipments + parameters: + - in: path + name: order_number + schema: + type: integer + required: true + description: Number (not id) of the Order being changed. + - in: path + name: shipment_number + schema: + type: integer + required: true + description: Number (not id) of the Shipment being changed. + responses: + '200': + description: Successful workflow change. + /taxonomies: get: description: Gets all Taxonomies. @@ -776,6 +950,13 @@ components: type: object images: type: object + + Shipment: + type: object + properties: + selected_shipping_rate_id: + type: integer + Taxonomy: type: object properties: From 889a3e6d9d635ba50f8d8e4761e1b67e7b108759 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 13:15:40 +0100 Subject: [PATCH 07/16] Improve file layout and move Order model to correct place --- swagger.yaml | 98 +++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index cfcb3b13b1..3d670d9fcd 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -43,6 +43,7 @@ paths: type: array items: $ref: '#/components/schemas/Product' + /products/overridable: get: description: Gets all Products. @@ -64,6 +65,7 @@ paths: type: array items: $ref: '#/components/schemas/Product' + /products: post: description: Posts a new Product. @@ -398,6 +400,7 @@ paths: responses: '201': description: Shipment successfully created + /orders/{order_number}/shipments/{shipment_number}.json: put: description: Updates shipment. @@ -428,6 +431,7 @@ paths: responses: '200': description: Successful operation. + /orders/{order_number}/shipments/{shipment_number}/add.json: put: description: Adds a variant quantity to the given shipment. @@ -461,6 +465,7 @@ paths: responses: '200': description: Variant quantity successfully added. + /orders/{order_number}/shipments/{shipment_number}/remove.json: delete: description: Removes a variant from the given shipment. @@ -494,6 +499,7 @@ paths: responses: '200': description: Variant quantity successfully rmeoved. + /orders/{order_number}/shipments/{shipment_number}/ready.json: delete: description: Moves the shipment to the ready state. @@ -515,6 +521,7 @@ paths: responses: '200': description: Successful workflow change. + /orders/{order_number}/shipments/{shipment_number}/ship.json: delete: description: Moves the shipment to the shipped state. @@ -907,6 +914,7 @@ components: type: object product_properties: type: object + New: type: object properties: @@ -951,49 +959,6 @@ components: images: type: object - Shipment: - type: object - properties: - selected_shipping_rate_id: - type: integer - - Taxonomy: - type: object - properties: - root: - type: object - id: - type: integer - name: - type: string - Taxon: - type: object - properties: - name: - type: string - taxonomy_id: - type: integer - position: - type: integer - permalink: - type: string - taxons: - type: array - items: - $ref: '#/components/schemas/Taxon' - pretty_name: - type: string - id: - type: integer - parent_id: - type: integer - Cookies_Consent: - type: object - properties: - cookies_consent: - type: boolean - example: - cookies_consent: false Order_Concise: type: object properties: @@ -1046,4 +1011,49 @@ components: type: object properties: id: - type: integer \ No newline at end of file + type: integer + + Shipment: + type: object + properties: + selected_shipping_rate_id: + type: integer + + Taxonomy: + type: object + properties: + root: + type: object + id: + type: integer + name: + type: string + Taxon: + type: object + properties: + name: + type: string + taxonomy_id: + type: integer + position: + type: integer + permalink: + type: string + taxons: + type: array + items: + $ref: '#/components/schemas/Taxon' + pretty_name: + type: string + id: + type: integer + parent_id: + type: integer + + Cookies_Consent: + type: object + properties: + cookies_consent: + type: boolean + example: + cookies_consent: false \ No newline at end of file From 6e677fecce5e173955179a96a0862407834d60a0 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 13:19:43 +0100 Subject: [PATCH 08/16] Remove now inexistent endpoints /new --- swagger.yaml | 55 +++++----------------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 3d670d9fcd..198c012e60 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -237,7 +237,7 @@ paths: variant: $ref: '#/components/schemas/Variant' required: true - description: JSON object representing the Variant to be posted. Only attributes listed in the Variant required_attributes object are required (obtainable via GET /products/{product_id}/variants/new). + description: JSON object representing the Variant to be posted. responses: '201': description: successful post @@ -580,7 +580,7 @@ paths: taxonomy: $ref: '#/components/schemas/Taxonomy' required: true - description: JSON object representing the Taxonomy to be posted. Only attributes listed in the Taxonomy required_attributes object are required (obtainable via GET /taxonomies/new). + description: JSON object representing the Taxonomy to be posted. responses: '201': description: successful post @@ -588,20 +588,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Taxonomy' - - /taxonomies/new: - get: - description: Gets an object consisting of an array of all Taxonomy attributes and an array of required attributes to create a new Taxonomy object. - tags: - - taxonomies - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/New' - + /taxonomies/{taxonomy_id}: get: description: Gets a Taxonomy by ID. @@ -718,7 +705,7 @@ paths: taxon: $ref: '#/components/schemas/Taxon' required: true - description: JSON object representing the Taxon to be posted. Only attributes listed in the Taxon required_attributes object are required (obtainable via GET /taxonomies/{taxonomy_id}/taxons/new). + description: JSON object representing the Taxon to be posted. responses: '201': description: successful post @@ -728,27 +715,7 @@ paths: type: array items: $ref: '#/components/schemas/Taxon' - - /taxonomies/{taxonomy_id}/taxons/new: - get: - description: Gets an object consisting of an array of all Taxon attributes and an array of required attributes to create a new Taxon object in a given Taxonomy. - tags: - - taxons - parameters: - - in: path - name: taxonomy_id - schema: - type: integer - required: true - description: Numeric ID of the Taxonomy. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/New' - + /taxonomies/{taxonomy_id}/taxons/{taxon_id}: get: description: Gets a Taxon by ID from the Taxonomy at the given Taxonomy ID. @@ -915,18 +882,6 @@ components: product_properties: type: object - New: - type: object - properties: - required_attributes: - type: array - items: - type: string - attributes: - type: array - items: - type: string - Variant: type: object properties: From afa8f97627a8d825dcac4a3892384269ccca9e08 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 13:42:40 +0100 Subject: [PATCH 09/16] Add post and put on enterprises and fix details in shipments endpoints --- swagger.yaml | 70 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 198c012e60..386cff735b 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -14,6 +14,8 @@ tags: description: Order endpoints - name: shipments description: Order shipments endpoints + - name: enterprises + description: Enterprises endpoints - name: taxonomies description: Taxonomy endpoints - name: taxons @@ -400,6 +402,10 @@ paths: responses: '201': description: Shipment successfully created + content: + application/json: + schema: + $ref: '#/components/schemas/Shipment' /orders/{order_number}/shipments/{shipment_number}.json: put: @@ -431,6 +437,10 @@ paths: responses: '200': description: Successful operation. + content: + application/json: + schema: + $ref: '#/components/schemas/Shipment' /orders/{order_number}/shipments/{shipment_number}/add.json: put: @@ -467,7 +477,7 @@ paths: description: Variant quantity successfully added. /orders/{order_number}/shipments/{shipment_number}/remove.json: - delete: + put: description: Removes a variant from the given shipment. tags: - shipments @@ -501,7 +511,7 @@ paths: description: Variant quantity successfully rmeoved. /orders/{order_number}/shipments/{shipment_number}/ready.json: - delete: + put: description: Moves the shipment to the ready state. tags: - shipments @@ -523,7 +533,7 @@ paths: description: Successful workflow change. /orders/{order_number}/shipments/{shipment_number}/ship.json: - delete: + put: description: Moves the shipment to the shipped state. tags: - shipments @@ -544,6 +554,50 @@ paths: '200': description: Successful workflow change. + /enterprises: + post: + description: Creates a new Enterprise. + tags: + - enterprises + parameters: + - in: path + name: enterprise_object + schema: + type: object + properties: + variant: + $ref: '#/components/schemas/Enterprise' + required: true + description: JSON object representing the Enterprise attributes to be created. + responses: + '201': + description: Enterprise successfully created + content: + application/json: + schema: + $ref: '#/components/schemas/Enterprise' + put: + description: Updates an Enterprise. + tags: + - enterprises + parameters: + - in: path + name: enterprise_object + schema: + type: object + properties: + variant: + $ref: '#/components/schemas/Enterprise' + required: true + description: JSON object representing the Enterprise to be overwritten. + responses: + '200': + description: Enterprise successfully updated + content: + application/json: + schema: + $ref: '#/components/schemas/Enterprise' + /taxonomies: get: description: Gets all Taxonomies. @@ -974,6 +1028,16 @@ components: selected_shipping_rate_id: type: integer + Enterprise: + type: object + properties: + id: + type: integer + name: + type: string + owner_id: + type: integer + Taxonomy: type: object properties: From 74e49787f43f96f51a7f222cd0536b79b6f284fe Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 15:16:35 +0100 Subject: [PATCH 10/16] Add the remaining missing enterprises endpoints --- swagger.yaml | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/swagger.yaml b/swagger.yaml index 386cff735b..25fff5dbc5 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -598,6 +598,106 @@ paths: schema: $ref: '#/components/schemas/Enterprise' + /enterprises/{enterprise_id}/shopfront: + get: + description: Fetch Enterprise shopfront details (products not included). + tags: + - enterprises + parameters: + - in: path + name: enterprise_id + schema: + type: integer + required: true + description: ID of the enterprise. + responses: + '200': + description: Enterprise shopfront details + content: + application/json: + schema: + $ref: '#/components/schemas/EnterpriseShopfront' + + /enterprises/{enterprise_id}/update_image: + post: + description: Update enterprise images, promo and logo. + tags: + - enterprises + parameters: + - in: path + name: enterprise_id + schema: + type: integer + required: true + description: ID of the enterprise. + - in: path + name: logo + schema: + type: string + format: binary + required: true + description: Binary of the logo image. + - in: path + name: promo + schema: + type: string + format: binary + required: true + description: Binary of the promo image. + responses: + '200': + description: Image successfully uploaded. URL to the uploaded image + content: + application/json: + schema: + type: string + + /enterprises/{enterprise_permalink}/logo.json: + delete: + description: Delete enterprise logo image. + tags: + - enterprises + parameters: + - in: path + name: enterprise_permalink + schema: + type: string + required: true + description: Permalink of the enterprise. + responses: + '200': + description: Image successfully deleted. Json object representing the enterprise + content: + application/json: + schema: + type: object + properties: + variant: + $ref: '#/components/schemas/Enterprise' + + /enterprises/{enterprise_permalink}/promo_image.json: + delete: + description: Delete enterprise promo image. + tags: + - enterprises + parameters: + - in: path + name: enterprise_permalink + schema: + type: string + required: true + description: Permalink of the enterprise. + responses: + '200': + description: Image successfully deleted. Json object representing the enterprise + content: + application/json: + schema: + type: object + properties: + variant: + $ref: '#/components/schemas/Enterprise' + /taxonomies: get: description: Gets all Taxonomies. @@ -605,7 +705,7 @@ paths: - taxonomies responses: '200': - description: successful operation + description: Successful operation. content: application/json: schema: @@ -1038,6 +1138,16 @@ components: owner_id: type: integer + EnterpriseShopfront: + type: object + properties: + id: + type: integer + name: + type: string + owner_id: + type: integer + Taxonomy: type: object properties: From 743cb3b33a6f107f3322c21147fd325c9a733d21 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 18:02:06 +0100 Subject: [PATCH 11/16] Add update product image endpoint and delete enterprise fees endpoint --- swagger.yaml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/swagger.yaml b/swagger.yaml index 25fff5dbc5..958c5d1c68 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -10,6 +10,8 @@ tags: description: Product endpoints - name: product variants description: Product variant endpoints + - name: product images + description: Product images endpoints - name: orders description: Order endpoints - name: shipments @@ -349,6 +351,32 @@ paths: '204': description: successful deletion + /product_images/{product_id}: + post: + description: Creates or updates product image. + tags: + - product images + parameters: + - in: path + name: product_id + schema: + type: integer + required: true + description: Numeric ID of the Product. + responses: + '201': + description: Product image added + content: + application/json: + schema: + $ref: '#/components/schemas/ProductImage' + '200': + description: Product image updated + content: + application/json: + schema: + $ref: '#/components/schemas/ProductImage' + /orders: get: description: Gets all Orders. @@ -698,6 +726,22 @@ paths: variant: $ref: '#/components/schemas/Enterprise' + /enterprise_fees/{enterprise_fee_id}: + delete: + description: Deletes enterprise fee. + tags: + - enterprises + parameters: + - in: path + name: enterprise_fee_id + schema: + type: integer + required: true + description: ID of the enterprise fee to delete. + responses: + '204': + description: Enterprise fee successfully deleted. + /taxonomies: get: description: Gets all Taxonomies. @@ -1068,6 +1112,22 @@ components: images: type: object + ProductImage: + type: object + properties: + id: + type: integer + alt: + type: string + thumb_url: + type: string + small_url: + type: string + image_url: + type: string + large_url: + type: string + Order_Concise: type: object properties: From 902e51e580b5277cf2b0f5cc57d089ddec9318f9 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 19:11:53 +0100 Subject: [PATCH 12/16] Add api/customers endpoints --- swagger.yaml | 70 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 958c5d1c68..1c22e1d8b7 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -698,10 +698,7 @@ paths: content: application/json: schema: - type: object - properties: - variant: - $ref: '#/components/schemas/Enterprise' + $ref: '#/components/schemas/Enterprise' /enterprises/{enterprise_permalink}/promo_image.json: delete: @@ -721,10 +718,48 @@ paths: content: application/json: schema: - type: object - properties: - variant: - $ref: '#/components/schemas/Enterprise' + $ref: '#/components/schemas/Enterprise' + + /customers.json: + get: + description: List of customer objects for the current user (a customer connects a user with an enterprise) + tags: + - users + responses: + '200': + description: List of Customer objects + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Customer' + + /customers/{customer_id}.json: + put: + description: Updates customer object of current user (a customer connects a user with an enterprise) + tags: + - users + parameters: + - in: path + name: customer_id + schema: + type: integer + required: true + description: ID of the customer object to update. + - in: path + name: customer_object + schema: + $ref: '#/components/schemas/Customer' + required: true + description: Customer object to be saved. + responses: + '200': + description: Customer object saved. + content: + application/json: + schema: + $ref: '#/components/schemas/Customer' /enterprise_fees/{enterprise_fee_id}: delete: @@ -741,7 +776,7 @@ paths: responses: '204': description: Enterprise fee successfully deleted. - + /taxonomies: get: description: Gets all Taxonomies. @@ -1208,6 +1243,22 @@ components: owner_id: type: integer + Customer: + type: object + properties: + id: + type: integer + enterprise_id: + type: integer + name: + type: string + code: + type: string + email: + type: string + allow_charges: + type: boolean + Taxonomy: type: object properties: @@ -1217,6 +1268,7 @@ components: type: integer name: type: string + Taxon: type: object properties: From 3d32987227e382e4057f38650f301126bebe38e4 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 12 Sep 2019 19:52:13 +0100 Subject: [PATCH 13/16] Fix taxonomies to represent the endpoints in OFN --- swagger.yaml | 230 +++++++++++++++------------------------------------ 1 file changed, 68 insertions(+), 162 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 1c22e1d8b7..43967a31ce 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -19,9 +19,7 @@ tags: - name: enterprises description: Enterprises endpoints - name: taxonomies - description: Taxonomy endpoints - - name: taxons - description: Taxon endpoints + description: Taxonomies endpoints - name: cookies_consent description: Cookies_Consent endpoints @@ -776,133 +774,12 @@ paths: responses: '204': description: Enterprise fee successfully deleted. - - /taxonomies: - get: - description: Gets all Taxonomies. - tags: - - taxonomies - responses: - '200': - description: Successful operation. - content: - application/json: - schema: - type: object - properties: - count: - type: integer - current_page: - type: integer - taxonomies: - type: array - items: - $ref: '#/components/schemas/Taxonomy' - pages: - type: integer - post: - description: Posts a new Taxonomy. - tags: - - taxonomies - parameters: - - in: path - name: taxonomy_object - schema: - type: object - properties: - taxonomy: - $ref: '#/components/schemas/Taxonomy' - required: true - description: JSON object representing the Taxonomy to be posted. - responses: - '201': - description: successful post - content: - application/json: - schema: - $ref: '#/components/schemas/Taxonomy' - /taxonomies/{taxonomy_id}: - get: - description: Gets a Taxonomy by ID. - tags: - - taxonomies - parameters: - - in: path - name: taxonomy_id - schema: - type: integer - required: true - description: Numeric ID of the Taxonomy. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Taxonomy' - put: - description: Updates the Taxonomy with the given ID. - tags: - - taxonomies - parameters: - - in: path - name: taxonomy_id - schema: - type: integer - required: true - description: Numeric ID of the Taxonomy. - - in: path - name: taxonomy_object - schema: - type: object - properties: - taxonomy: - $ref: '#/components/schemas/Taxonomy' - required: true - description: JSON object representing the Taxonomy attributes to be overwritten. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Taxonomy' - delete: - description: Deletes the Taxonomy with the given ID. - tags: - - taxonomies - parameters: - - in: path - name: taxonomy_id - schema: - type: integer - required: true - description: Numeric ID of the Taxonomy. - responses: - '204': - description: successful deletion - - /taxons: - get: - description: Gets all Taxons. - tags: - - taxons - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Taxon' - /taxonomies/{taxonomy_id}/taxons/: get: description: Gets all Taxons belonging to a given Taxonomy. tags: - - taxons + - taxonomies parameters: - in: path name: taxonomy_id @@ -922,7 +799,7 @@ paths: post: description: Posts a new Taxon to a given Taxonomy. tags: - - taxons + - taxonomies parameters: - in: path name: taxonomy_id @@ -950,34 +827,10 @@ paths: $ref: '#/components/schemas/Taxon' /taxonomies/{taxonomy_id}/taxons/{taxon_id}: - get: - description: Gets a Taxon by ID from the Taxonomy at the given Taxonomy ID. - tags: - - taxons - parameters: - - in: path - name: taxonomy_id - schema: - type: integer - required: true - description: Numeric ID of the Taxonomy. - - in: path - name: taxon_id - schema: - type: integer - required: true - description: Numeric ID of the Taxon. - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Taxon' put: description: Updates the Taxon with the given Taxon ID in the Taxonomy with the given Taxonomy ID. tags: - - taxons + - taxonomies parameters: - in: path name: taxonomy_id @@ -1010,7 +863,7 @@ paths: delete: description: Deletes the Taxon with the given Taxon ID from the Taxonomy with the given Taxonomy ID. tags: - - taxons + - taxonomies parameters: - in: path name: taxonomy_id @@ -1028,6 +881,52 @@ paths: '204': description: successful deletion + /taxonomies/{taxonomy_id}/jstree: + get: + description: Gets a Taxonomy by ID with a jstree representation. + tags: + - taxonomies + parameters: + - in: path + name: taxonomy_id + schema: + type: integer + required: true + description: Numeric ID of the Taxonomy. + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/TaxonJstree' + + /taxonomies/{taxonomy_id}/taxons/{taxon_id}/jstree: + get: + description: Gest a given Taxon from given Taxonomy ID in the jstree representation. + tags: + - taxonomies + parameters: + - in: path + name: taxonomy_id + schema: + type: integer + required: true + description: Numeric ID of the Taxonomy. + - in: path + name: taxon_id + schema: + type: integer + required: true + description: Numeric ID of the Taxon. + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/TaxonJstree' + /cookies/consent: get: description: Gets the client's Cookies_Consent status. @@ -1259,16 +1158,6 @@ components: allow_charges: type: boolean - Taxonomy: - type: object - properties: - root: - type: object - id: - type: integer - name: - type: string - Taxon: type: object properties: @@ -1290,6 +1179,23 @@ components: type: integer parent_id: type: integer + icon: + type: string + + TaxonJstree: + type: object + properties: + data: + type: string + state: + type: string + attr: + type: object + properties: + id: + type: integer + name: + type: string Cookies_Consent: type: object From b8b107dd2d7221e0398c6024e050f274393f161f Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 13 Sep 2019 14:27:39 +0100 Subject: [PATCH 14/16] Fix api_key header name --- swagger.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/swagger.yaml b/swagger.yaml index 43967a31ce..d72f13c699 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -23,6 +23,9 @@ tags: - name: cookies_consent description: Cookies_Consent endpoints +security: + - api_key: [] + paths: /products/bulk_products: get: @@ -966,7 +969,7 @@ components: securitySchemes: api_key: type: apiKey - name: api_key + name: X-Spree-Token in: header schemas: Pagination: From c66a659e8ee9dfcacda4289d5b7746034e24d2b6 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 13 Sep 2019 14:55:18 +0100 Subject: [PATCH 15/16] Fix /products payloads: product, variants and variant overrides --- swagger.yaml | 106 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index d72f13c699..93a189206b 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -990,64 +990,108 @@ components: type: integer name: type: string - description: + sku: type: string price: type: string available_on: type: string - permalink: + permalink_live: type: string - count_on_hand: + on_hand: type: integer - meta_description: + variant_unit: type: string - meta_keywords: + variant_unit_scale: type: string - taxon_ids: - type: object + variant_unit_name: + type: string + tax_category_id: + type: integer + import_date: + type: string + image_url: + type: string + thumb_url: + type: string + producer_id: + type: integer + category_id: + type: integer + master: + $ref: '#/components/schemas/Variant' variants: - oneOf: - - type: array - items: - $ref: '#/components/schemas/Variant' - - $ref: '#/components/schemas/Variant' - option_types: - type: object - product_properties: - type: object + type: array + items: + $ref: '#/components/schemas/Variant' Variant: type: object properties: - id: + id: type: integer - name: + name: type: string - count_on_hand: + on_hand: type: integer - sku: + sku: type: string price: type: string - weight: + producer_name: type: string - height: + import_date: type: string - width: + options_text: type: string - depth: + unit_value: + type: integer + unit_description: type: string - is_master: + unit_to_display: type: string - cost_price: + display_as: type: string - permalink: + display_name: type: string - option_values: - type: object - images: - type: object + name_to_display: + type: string + on_demand: + type: boolean + in_stock: + type: boolean + image: + type: string + variant_overrides: + type: array + items: + $ref: '#/components/schemas/VariantOverride' + + VariantOverride: + type: object + properties: + id: + type: integer + count_on_hand: + type: integer + default_stock: + type: integer + hub_id: + type: integer + import_date: + type: string + on_demand: + type: boolean + permission_revoked_at: + type: string + price: + type: string + resettable: + type: boolean + sku: + type: string + variant_id: + type: integer ProductImage: type: object From caebcdf1848296e2114174057e0ff0996faf4b95 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 13 Sep 2019 15:33:54 +0100 Subject: [PATCH 16/16] Add correct schemas for EnterpriseShopfront and Variant (not Api::Admin::VariantSerializer but Api::VariantSerializer) --- swagger.yaml | 156 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 150 insertions(+), 6 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 93a189206b..ba79384739 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -1019,13 +1019,13 @@ components: category_id: type: integer master: - $ref: '#/components/schemas/Variant' + $ref: '#/components/schemas/AdminVariant' variants: type: array items: - $ref: '#/components/schemas/Variant' + $ref: '#/components/schemas/AdminVariant' - Variant: + AdminVariant: type: object properties: id: @@ -1065,9 +1065,9 @@ components: variant_overrides: type: array items: - $ref: '#/components/schemas/VariantOverride' + $ref: '#/components/schemas/AdminVariantOverride' - VariantOverride: + AdminVariantOverride: type: object properties: id: @@ -1093,6 +1093,46 @@ components: variant_id: type: integer + Variant: + type: object + properties: + id: + type: integer + on_hand: + type: integer + sku: + type: string + price: + type: string + product_name: + type: string + is_master: + type: boolean + options_text: + type: string + unit_value: + type: integer + unit_description: + type: string + unit_to_display: + type: string + display_as: + type: string + display_name: + type: string + name_to_display: + type: string + on_demand: + type: boolean + fees: + type: object + price_with_fees: + type: string + tag_list: + type: array + items: + type: string + ProductImage: type: object properties: @@ -1186,7 +1226,111 @@ components: type: integer name: type: string - owner_id: + description: + type: string + latitude: + type: integer + longitude: + type: integer + long_description: + type: string + website: + type: string + instagram: + type: string + linkedin: + type: string + twitter: + type: string + facebook: + type: string + is_primary_producer: + type: boolean + is_distributor: + type: boolean + phone: + type: string + visible: + type: boolean + email_address: + type: string + hash: + type: string + logo: + type: string + promo_image: + type: string + path: + type: string + category: + type: string + active: + type: boolean + producers: + type: array + items: + $ref: '#/components/schemas/EnterpriseThin' + orders_close_at: + type: string + hubs: + type: array + items: + $ref: '#/components/schemas/EnterpriseThin' + taxons: + type: array + items: + type: string + supplied_taxons: + type: array + items: + type: string + pickup: + type: boolean + delivery: + type: boolean + address: + type: array + items: + $ref: '#/components/schemas/Address' + + EnterpriseThin: + type: object + properties: + id: + type: integer + name: + type: string + active: + type: boolean + path: + type: string + address: + $ref: '#/components/schemas/Address' + + Address: + type: object + properties: + id: + type: integer + zipcode: + type: string + city: + type: string + state_name: + type: string + state_id: + type: integer + phone: + type: string + firstname: + type: string + lastname: + type: string + address1: + type: string + address2: + type: string + country_id: type: integer Customer: