Ejemplo n.º 1
0
        /// <summary>
        /// 通过 product_id 或 parent_sku 更新商品
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="product"></param>
        /// <param name="sessionType"></param>
        /// <returns></returns>
        public static async Task <ProductResultBase> ProductUpdateAsync(string clientId, string accessToken, Wl.Wish.Entities.Request.ProductToUpdate product, SessionType sessionType = SessionType.Prod)
        {
            return(await ApiHandlerWrapper.TryCommonApiAsync(token =>
            {
                var url =
                    string.Format("{0}/api/v2/product/update",
                                  sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot);

                var result = Wl.Wish.CommonAPIs.CommonJsonSend.SendAsync <ProductResultBase>(token, url, product, CommonJsonSendType.POST);
                return result;
            }, clientId, accessToken, sessionType));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建商品
        ///
        /// 原始文档
        /// https://www.merchant.wish.com/documentation/api/v2#create-product
        ///
        /// 商品参数
        /// name
        /// description
        /// tags
        /// sku
        /// inventory
        /// price
        /// shipping
        /// main_image
        /// color optional
        /// size optional
        /// msrp optional
        /// shipping_time optional
        /// parent_sku optional
        /// brand optional
        /// landing_page_url optional
        /// upc optional
        /// extra_images optional
        ///
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="product"></param>
        /// <param name="sessionType">Prod 正式环境,Sandbox 沙盒环境</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static ProductResult ProductCreate(string clientId, string accessToken, Wl.Wish.Entities.Request.Product product, SessionType sessionType = SessionType.Prod, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWrapper.TryCommonApi(token =>
            {
                var url =
                    string.Format("{0}/api/v2/product/add",
                                  sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot);

                var result = CommonJsonSend.Send <ProductResult>(token, url, product, CommonJsonSendType.POST, timeOut);
                return result;
            }, clientId, accessToken, sessionType));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 通过 parent_sku 获得商品
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="productId"></param>
        /// <param name="sessionType"></param>
        /// <returns></returns>
        public static async Task <ProductResult> ProductRetrieveViaSkuAsync(string clientId, string accessToken, string parentSku, SessionType sessionType = SessionType.Prod)
        {
            return(await ApiHandlerWrapper.TryCommonApiAsync(token =>
            {
                var url =
                    string.Format("{0}/api/v2/product?parent_sku={1}&access_token={2}",
                                  sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot,
                                  parentSku,
                                  token);

                var result = Wl.Wish.CommonAPIs.CommonJsonSend.SendAsync <ProductResult>(null, url, null, CommonJsonSendType.GET);
                return result;
            }, clientId, accessToken, sessionType));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 按product_id来获取产品
        ///
        /// 原始文档
        ///
        /// https://www.merchant.wish.com/documentation/api/v2#get-product
        ///
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="productId"></param>
        /// <param name="sessionType"></param>
        /// <returns></returns>
        public static ProductResult ProductRetrieveViaId(string clientId, string accessToken, string productId, SessionType sessionType = SessionType.Prod)
        {
            return(ApiHandlerWrapper.TryCommonApi(token =>
            {
                var url =
                    string.Format("{0}/api/v2/product?id={1}&access_token={2}",
                                  sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot,
                                  productId,
                                  token);

                var result = CommonJsonSend.Send <ProductResult>(null, url, null, CommonJsonSendType.GET);
                return result;
            }, clientId, accessToken, sessionType));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 商品上架(异步,通过 parent_sku)
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="parentSku"></param>
 /// <param name="sessionType"></param>
 /// <returns></returns>
 public static async Task <ProductResultBase> ProductEnableViaParentSkuAsync(string clientId, string accessToken, string parentSku, SessionType sessionType = SessionType.Prod)
 {
     return(await ApiHandlerWrapper.TryCommonApiAsync(token =>
     {
         var url =
             string.Format("{0}/api/v2/product/enable",
                           sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot);
         var data = new
         {
             parent_sku = parentSku
         };
         var result = Wl.Wish.CommonAPIs.CommonJsonSend.SendAsync <ProductResultBase>(token, url, data, CommonJsonSendType.POST);
         return result;
     }, clientId, accessToken, sessionType));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 商品下架 (通过 product_id,parent_sku)
 ///
 /// 原始文档
 ///
 /// https://www.merchant.wish.com/documentation/api/v2#disable-product
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="productId"></param>
 /// <param name="sessionType"></param>
 /// <returns></returns>
 public static ProductResultBase ProductDisableViaId(string clientId, string accessToken, string productId, SessionType sessionType = SessionType.Prod)
 {
     return(ApiHandlerWrapper.TryCommonApi(token =>
     {
         var url =
             string.Format("{0}/api/v2/product/disable",
                           sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot);
         var data = new
         {
             id = productId
         };
         var result = CommonJsonSend.Send <ProductResultBase>(token, url, data, CommonJsonSendType.POST);
         return result;
     }, clientId, accessToken, sessionType));
 }