ProductImage - 友好速搭 -- 开发文档

友好速搭

开放 API
使用说明 获取授权 全部 API 特殊 API 开放功能

ProductImage

ProductImage

#实体关系 ProductImage 为 Product 的橱窗图片,用于商品列表和商品详情页面呈现,一个 Product 可以包含多个 ProductImage。

ProductImage 相关API

GET /products/#{id}/images获取 Product 所有 ProductImageGET /products/#{id}/images/count获取 Product 所有 ProductImage 的数量GET /products/#{id}/images/#{id}获取 Product 的单个 ProductImagePOST /products/#{id}/images创建 ProductImagePUT /products/#{id}/images/#{id}更新 ProductImageDELETE /products/#{id}/images/#{id}删除 ProductImage

ProductImage 属性

    • id
    •   { "id" : 148002 }
      
      Number 类型,ProductImage 唯一整型标识。
    • product_id
    •   { "product_id" : 10254}
      
      Number 类型,ProductImage 所属 Product 的唯一整型标识。
    • created_at
    •   { "created_at" : "2014-02-15T15:12:21+08:00" }
      
      Datetime 类型,ProductImage 的创建时间。
    • updated_at
    •   { "updated_at" : "2014-02-15T15:12:21+08:00" }
      
      Datetime 类型,ProductImage 的上一次更新时间。
    • file_name
    •   { "file_name" : "商品图片-10023.png" }
      
      String 类型,ProductImage 的文件名。
    • src
    •   { "src" : "http://asset.ibanquan.com/image/55111114e13823461a000005/s.png?v=1427181844" }
      
      String 类型,ProductImage 的访问路径。
    • position
    •   { "position" : 2}
      
      Number 类型,ProductImage 在商品橱窗图片中显示的位置排序。
    • variant_ids
    •   { "variant_ids" : [963] }
      
      Array 类型,ProductImage 被关联的 ProductVariant。

GET /products/#{id}/images

获取 Product 所有 ProductImage

    • fields
    • 需要查询的字段
    • 获取 Product 所有 ProductImage
    • GET /products/12032/images
    • {
          "images": [
              {
                  "alt": "",
                  "created_at": "2015-03-24T15:24:04.267+08:00",
                  "file_name": "商品图片1.png",
                  "id": 155870,
                  "position": 2,
                  "product_id": 12032,
                  "src": "http://asset.ibanquan.com/image/55111114e13823461a000005/s.png?v=1427181844",
                  "updated_at": "2015-03-24T15:24:04.267+08:00",
                  "variant_ids": []
              },
              {
                  "alt": "",
                  "created_at": "2015-03-24T15:24:07.792+08:00",
                  "file_name": "商品图片2.jpg",
                  "id": 155871,
                  "position": 1,
                  "product_id": 12032,
                  "src": "http://asset.ibanquan.com/image/55111117e138230b0a000006/s.jpg?v=1427181847",
                  "updated_at": "2015-03-24T15:24:07.792+08:00",
                  "variant_ids": [963]
              }
          ]
      }
      

GET /products/#{id}/images/count

获取 Product 所有 ProductImage 的数量

    • 获取商品所有 ProductImage 的数量
    • GET /products/12032/images/count
    • {
          "count": 2
      }
      

GET /products/#{id}/images/#{id}

获取 Product 的单个 ProductImage

    • fields
    • 需要查询的字段
    • 获取 Product 的单个 ProductImage
    • GET /products/12032/images/155871
    • {
          "image":{
              "alt": "",
              "created_at": "2015-03-24T15:24:07.792+08:00",
              "file_name": "商品图片2.jpg",
              "id": 155871,
              "position": 1,
              "product_id": 12032,
              "src": "http://asset.ibanquan.com/image/55111117e138230b0a000006/s.jpg?v=1427181847",
              "updated_at": "2015-03-24T15:24:07.792+08:00",
              "variant_ids": [963]
          }
      }
      

POST /products/#{id}/images

创建 ProductImage

    • image[attachment]
    • 图片的 base64 数据
    • image[file_name]
    • 图片文件名
    • 创建 ProductImage
    • POST /products/12560/images
      {
          "image": {
              "file_name": "商品图片-10098.jpg",
              "attachment": "data:image/gif;base64,R0lGODlhAQABAID/AP///wAAACwAAAAAAQABAAACAkQBADs="
          }
      }
      
    • {
          "image": {
              "alt": "",
              "created_at": "2015-03-24T16:53:58.337+08:00",
              "file_name": "商品图片-10098.jpg",
              "id": 156896,
              "position": 3,
              "product_id": 12560,
              "src": "http://asset.ibanquan.com/image/551126266387e479ae000002/s.jpg?1427187238",
              "updated_at": "2015-03-24T16:53:58.337+08:00",
              "variant_ids": []
          }
      }
      

PUT /products/#{id}/images/#{id}

更新 ProductImage

    • image[alt]
    • 图片的 alt 属性
    • image[file_name]
    • 图片文件名
    • 更新 ProductImage
    • PUT /products/12560/images/156896
      {
          "image": {
              "alt": "自定义描述",
              "file_name": "商品图片-98.jpg"
          }
      }
      
    • {
          "image": {
              "alt": "自定义描述",
              "created_at": "2015-03-24T16:53:58.337+08:00",
              "file_name": "商品图片-98.jpg",
              "id": 156896,
              "position": 3,
              "product_id": 12560,
              "src": "http://asset.ibanquan.com/image/551126266387e479ae000002/s.jpg?1427187238",
              "updated_at": "2015-03-24T16:53:58.337+08:00",
              "variant_ids": []
          }
      }
      

DELETE /products/#{id}/images/#{id}

删除 ProductImage

    • 删除 ProductImage
    • DELETE /products/12560/images/156896
    • {}
      
免费领取15天试用
立即注册
联系客服
微信咨询
微信二维码

领取免费试用资格

姓名 *

电话 *

公司名称

所在地区

意向产品

提交

提交成功

你好, XXX女士/先生 ,你的需求已提交成功,后续会有专门的客户经理与你电话联系。谢谢!