gplsek / fitmoostore

fitmostore
GNU General Public License v2.0
0 stars 0 forks source link

Update create and edit product to accept request in single call #14

Closed gplsek closed 10 years ago

gplsek commented 10 years ago

========CREATE NODE WITH PRODUCTS===== POST http://fitmoostore.loc/fit_store/product Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=3uGXAkrT7aL28bMIrsDVbOIS54_CwuNQMpHWDpXN4os X-CSRF-Token: xDNmQZ7VfNhOLw1gfNH_8MNbh3H4uZf6zQIvmSAvVT4 Content-Type: application/json { "title": "Product!!!!", "sku": "pdsfdsfreat!!!!!e", "node": "true", <--- SAME AS BEFORE "description": "descripti!!!Aon", "type": "shoes", "products": [ { "title": "!!!!!!!!", "sku": "prs!!!!fte", "commerce_price_amount": "1000", "commerce_price_currency_code": "USD", "type": "shoes", "size": "10", <---- no need "field_size" just "size" "commerce_stock": "10", "image":imageurl } ] }

-- response -- { "type":"shoes", "title":"Product!!!!", "sku":"pdsfdsfreat!!!!!e", "uid":"9", "status":1, "promote":1, "sticky":1, "language":"und", "body":{ "und":[ { "value":"descripti!!!Aon" } ] }, "field_product":{ "und":[ { "product_id":"1149" } ] }, "created":1397467516, "changed":1397467516, "timestamp":1397467516, "log":"", "nid":"1054", "comment":0, "tnid":0, "translate":0, "vid":"1054" }

---- UPDATE NODE AND PRODUCTS----- PUT http://fitmoostore.loc/fit_store/product/1054 (NODE_ID) Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=3uGXAkrT7aL28bMIrsDVbOIS54_CwuNQMpHWDpXN4os X-CSRF-Token: xDNmQZ7VfNhOLw1gfNH_8MNbh3H4uZf6zQIvmSAvVT4 Content-Type: application/json { "title": "Product!!!!EDITED", "sku": "pdsfdsfreat!!!!!eEDITED", "node": "true", <---SAME AS BEFORE "description": "descripti!!!AonEDITED", "type": "shoes", "products": { "1149": { "title": "!!!!!!!!EDITED", "sku": "prs!!!!fteEDITED", "commerce_price_amount": "100", "commerce_price_currency_code": "USD", "type": "shoes", "size": "11", <---JUST "SIZE" "commerce_stock": "10" } } } -- response -- { "node_product":{ "vid":"1054", "uid":"9", "title":"Product!!!!EDITED", "status":"1", "comment":"0", "promote":"1", "sticky":"1", "nid":"1054", "type":"shoes", "language":"und", "created":"1397467516", "changed":1397467805, "tnid":"0", "translate":"0", "revision_timestamp":"1397467667", "revision_uid":"9", "body":{ "und":[ { "value":"descripti!!!AonEDITED", "summary":null, "format":null, "safe_value":"descripti!!!AonEDITED", "safe_summary":"" } ] }, "field_gender":[

  ],
  "field_brand":[

  ],
  "field_product":{
     "und":[
        {
           "product_id":"1149"
        }
     ]
  },
  "rdf_mapping":{
     "rdftype":[
        "sioc:Item",
        "foaf:Document"
     ],
     "title":{
        "predicates":[
           "dc:title"
        ]
     },
     "created":{
        "predicates":[
           "dc:date",
           "dc:created"
        ],
        "datatype":"xsd:dateTime",
        "callback":"date_iso8601"
     },
     "changed":{
        "predicates":[
           "dc:modified"
        ],
        "datatype":"xsd:dateTime",
        "callback":"date_iso8601"
     },
     "body":{
        "predicates":[
           "content:encoded"
        ]
     },
     "uid":{
        "predicates":[
           "sioc:has_creator"
        ],
        "type":"rel"
     },
     "name":{
        "predicates":[
           "foaf:name"
        ]
     },
     "comment_count":{
        "predicates":[
           "sioc:num_replies"
        ],
        "datatype":"xsd:integer"
     },
     "last_activity":{
        "predicates":[
           "sioc:last_activity_date"
        ],
        "datatype":"xsd:dateTime",
        "callback":"date_iso8601"
     }
  },
  "cid":0,
  "last_comment_timestamp":"1397467516",
  "last_comment_name":"",
  "last_comment_uid":"9",
  "comment_count":0,
  "name":"test",
  "picture":"0",
  "data":"b:0;",
  "sku":"pdsfdsfreat!!!!!eEDITED",
  "timestamp":1397467805

}, "items":[ { "sku":"prs!!!!fteEDITED", "title":"!!!!!!!!EDITED", "revision_uid":"9", "status":"1", "log":"", "revision_timestamp":1397467805, "data":false, "product_id":"1149", "type":"shoes", "language":"", "uid":"9", "created":"1397467516", "changed":1397467805, "commerce_price":{ "und":[ { "amount":"1000", "currency_code":"USD", "data":{ "components":[

                 ]
              }
           }
        ]
     },
     "field_shoe_size":{
        "und":[
           {
              "tid":"10"
           }
        ]
     },
     "commerce_stock":{
        "und":[
           {
              "value":10
           }
        ]
     },
     "field_image":[

     ],
     "rdf_mapping":[

     ],
     "old_revision_id":"1172",
     "revision_id":"1173",
     "attribute_fields":[
        "field_shoe_size"
     ],
     "commerce_price_formatted":"$10.00",
     "field_image_url":""
  }

] }

----- UPDATE PRODUCT (NOT NODE PRODUCT) ---- PUT http://fitmoostore.loc/fit_store/product/1149 (PRODUCT_ID) Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=3uGXAkrT7aL28bMIrsDVbOIS54_CwuNQMpHWDpXN4os X-CSRF-Token: xDNmQZ7VfNhOLw1gfNH_8MNbh3H4uZf6zQIvmSAvVT4 Content-Type: application/json { "title": "!!!!!!!!EDIT111ED", "sku": "prs!!!!fteED1111ITED", "commerce_price_amount": "1000", "commerce_price_currency_code": "USD", "type": "shoes", "size": "12", "commerce_stock": "10" } --RESPONSE-- { "sku":"prs!!!!fteED1111ITED", "title":"!!!!!!!!EDIT111ED", "revision_uid":"9", "status":"1", "log":"", "revision_timestamp":1397467988, "data":false, "product_id":"1149", "type":"shoes", "language":"", "uid":"9", "created":"1397467516", "changed":1397467988, "commerce_price":{ "amount":"1000", "currency_code":"USD", "data":{ "components":[

     ]
  }

}, "field_shoe_size":"12", "commerce_stock":10, "field_image":null, "rdf_mapping":[

], "old_revision_id":"1173", "revision_id":"1174", "attribute_fields":[ "field_shoe_size" ], "commerce_price_formatted":"$10.00", "field_image_url":"" }

---- GET PRODUCT (NOT NODE PRODUCT)--- GET http://fitmoostore.loc/fit_store/product/1054 (PRODUCT_ID) Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=3uGXAkrT7aL28bMIrsDVbOIS54_CwuNQMpHWDpXN4os X-CSRF-Token: xDNmQZ7VfNhOLw1gfNH_8MNbh3H4uZf6zQIvmSAvVT4 --RESPONSE-- { "revision_id":"1072", "sku":"Clothing_ae9d5ec0e74f5f7e8f1736bd8a702b", "title":"test", "revision_uid":"86", "status":"1", "log":"", "revision_timestamp":"1395041334", "data":false, "product_id":"1054", "type":"shoes", "language":"", "uid":"86", "created":"1395041334", "changed":"1395041334", "commerce_price":{ "amount":"12", "currency_code":"USD", "data":{ "components":[

     ]
  }

}, "field_shoe_size":"10", "commerce_stock":"121.00", "field_image":null, "rdf_mapping":[

], "attribute_fields":[ "field_shoe_size" ], "commerce_price_formatted":"$0.12", "field_image_url":"", "field_shoe_size_entities":{ "10":{ "tid":"10", "vid":"3", "name":"6", "description":"", "format":"filtered_html", "weight":"0", "vocabulary_machine_name":"shoe_size", "rdf_mapping":{ "rdftype":[ "skos:Concept" ], "name":{ "predicates":[ "rdfs:label", "skos:prefLabel" ] }, "description":{ "predicates":[ "skos:definition" ] }, "vid":{ "predicates":[ "skos:inScheme" ], "type":"rel" }, "parent":{ "predicates":[ "skos:broader" ], "type":"rel" } } } } }