当前位置: 首页>>代码示例>>Python>>正文


Python Meli.put方法代码示例

本文整理汇总了Python中melisdk.meli.Meli.put方法的典型用法代码示例。如果您正苦于以下问题:Python Meli.put方法的具体用法?Python Meli.put怎么用?Python Meli.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在melisdk.meli.Meli的用法示例。


在下文中一共展示了Meli.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: product_meli_delete

# 需要导入模块: from melisdk.meli import Meli [as 别名]
# 或者: from melisdk.meli.Meli import put [as 别名]
    def product_meli_delete( self, cr, uid, ids, context=None ):

        user_obj = self.pool.get('res.users').browse(cr, uid, uid)
        company = user_obj.company_id
        product_obj = self.pool.get('product.product')
        product = product_obj.browse(cr, uid, ids[0])

        if product.meli_status!='closed':
            self.product_meli_status_close( cr, uid, ids, context )

        CLIENT_ID = company.mercadolibre_client_id
        CLIENT_SECRET = company.mercadolibre_secret_key
        ACCESS_TOKEN = company.mercadolibre_access_token
        REFRESH_TOKEN = company.mercadolibre_refresh_token

        meli = Meli(client_id=CLIENT_ID,client_secret=CLIENT_SECRET, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)

        response = meli.put("/items/"+product.meli_id, { 'deleted': 'true' }, {'access_token':meli.access_token})

        #print "product_meli_delete: " + response.content
        rjson = response.json()
        ML_status = rjson["status"]
        if "error" in rjson:
            ML_status = rjson["error"]
        if "sub_status" in rjson:
            if len(rjson["sub_status"]) and rjson["sub_status"][0]=='deleted':
                product.write({ 'meli_id': '' })

        return {}
开发者ID:lertech,项目名称:meli_oerp,代码行数:31,代码来源:product.py

示例2: product_meli_status_active

# 需要导入模块: from melisdk.meli import Meli [as 别名]
# 或者: from melisdk.meli.Meli import put [as 别名]
    def product_meli_status_active( self, cr, uid, ids, context=None ):
        user_obj = self.pool.get('res.users').browse(cr, uid, uid)
        company = user_obj.company_id
        product_obj = self.pool.get('product.product')
        product = product_obj.browse(cr, uid, ids[0])

        CLIENT_ID = company.mercadolibre_client_id
        CLIENT_SECRET = company.mercadolibre_secret_key
        ACCESS_TOKEN = company.mercadolibre_access_token
        REFRESH_TOKEN = company.mercadolibre_refresh_token

        meli = Meli(client_id=CLIENT_ID,client_secret=CLIENT_SECRET, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)

        response = meli.put("/items/"+product.meli_id, { 'status': 'active' }, {'access_token':meli.access_token})

        #print "product_meli_status_active: " + response.content

        return {}
开发者ID:lertech,项目名称:meli_oerp,代码行数:20,代码来源:product.py

示例3: product_post

# 需要导入模块: from melisdk.meli import Meli [as 别名]
# 或者: from melisdk.meli.Meli import put [as 别名]

#.........这里部分代码省略.........
                    #"listing_type_id": product.meli_listing_type,
                    #"buying_mode": product.meli_buying_mode or '',
                    "price": product.meli_price or '0',
                    #"currency_id": product.meli_currency,
                    #"condition": product.meli_condition or '',
                    "available_quantity": product.meli_available_quantity or '0',
                    "warranty": product.meli_warranty or '',
                    "pictures": [],
                    #"pictures": [ { 'source': product.meli_imagen_logo} ] ,
                    "video_id": product.meli_video or '',
                }

            #publicando multiples imagenes
            multi_images_ids = {}
            if (product.images):
                # print 'website_multi_images presente:   ', product.images
                #recorrer las imagenes y publicarlas
                multi_images_ids = product.product_meli_upload_multi_images()

            #asignando imagen de logo (por source)
            if product.meli_imagen_logo:
                if product.meli_imagen_id:
                    if 'pictures' in body.keys():
                        body["pictures"]+= [ { 'id': product.meli_imagen_id } ]
                    else:
                        body["pictures"] = [ { 'id': product.meli_imagen_id } ]

                        if (multi_images_ids):
                            if 'pictures' in body.keys():
                                body["pictures"]+= multi_images_ids
                            else:
                                body["pictures"] = multi_images_ids

                    if 'pictures' in body.keys():
                        body["pictures"]+= [ { 'source': product.meli_imagen_logo} ]
                    else:
                        body["pictures"]+= [ { 'source': product.meli_imagen_logo} ]
                else:
                    imagen_producto = ""
                    if (product.meli_description!="" and product.meli_description!=False and product.meli_imagen_link!=""):
                        imgtag = "<img style='width: 420px; height: auto;' src='%s'/>" % ( product.meli_imagen_link )
                        result = product.meli_description.replace( "[IMAGEN_PRODUCTO]", imgtag )
                        if (result):
                            _logger.info( "result: %s" % (result) )
                            product.meli_description = result
                        else:
                            result = product.meli_description



            else:
                return warningobj.info(cr, uid, title='MELI WARNING', message="Debe completar el campo 'Imagen_Logo' con el url: http://www.nuevohorizonte-sa.com.ar/images/logo1.png", message_html="")

            #check fields
            if product.meli_description==False:
                return warningobj.info(cr, uid, title='MELI WARNING', message="Debe completar el campo 'description' (en html)", message_html="")

            #put for editing, post for creating
            if product.meli_id:
                response = meli.put("/items/"+product.meli_id, body, {'access_token':meli.access_token})
            else:
                assign_img = True and product.meli_imagen_id
                response = meli.post("/items", body, {'access_token':meli.access_token})

            #check response
            # print response.content
            rjson = response.json()

            #check error
            if "error" in rjson:
                #print "Error received: %s " % rjson["error"]
                error_msg = 'MELI: mensaje de error:  %s , mensaje: %s, status: %s, cause: %s ' % (rjson["error"], rjson["message"], rjson["status"], rjson["cause"])
                _logger.error(error_msg)

                missing_fields = error_msg

                #expired token
                if "message" in rjson and (rjson["message"]=='invalid_token' or rjson["message"]=="expired_token"):
                    meli = Meli(client_id=CLIENT_ID,client_secret=CLIENT_SECRET)
                    url_login_meli = meli.auth_url(redirect_URI=REDIRECT_URI)
                    #print "url_login_meli:", url_login_meli
                    #raise osv.except_osv( _('MELI WARNING'), _('INVALID TOKEN or EXPIRED TOKEN (must login, go to Edit Company and login):  error: %s, message: %s, status: %s') % ( rjson["error"], rjson["message"],rjson["status"],))
                    return warningobj.info(cr, uid, title='MELI WARNING', message="Debe iniciar sesión en MELI.  ", message_html="")
                else:
                     #Any other errors
                    return warningobj.info(cr, uid, title='MELI WARNING', message="Completar todos los campos!  ", message_html="<br><br>"+missing_fields )

            #last modifications if response is OK
            if "id" in rjson:
                product.write( { 'meli_id': rjson["id"]} )

            posting_fields = {'posting_date': str(datetime.now()),'meli_id':rjson['id'],'product_id':product.id,'name': 'Post: ' + product.meli_title }

            posting_id = self.pool.get('mercadolibre.posting').search(cr,uid,[('meli_id','=',rjson['id'])])

            if not posting_id:
	            posting_id = self.pool.get('mercadolibre.posting').create(cr,uid,(posting_fields))


        return {}
开发者ID:ctmil,项目名称:meli_oerp,代码行数:104,代码来源:product_post.py

示例4: product_post

# 需要导入模块: from melisdk.meli import Meli [as 别名]
# 或者: from melisdk.meli.Meli import put [as 别名]

#.........这里部分代码省略.........

                if multi_images_ids:
                    if "pictures" in body.keys():
                        body["pictures"] += multi_images_ids
                    else:
                        body["pictures"] = multi_images_ids

                if "pictures" in body.keys():
                    body["pictures"] += [{"source": product.meli_imagen_logo}]
                else:
                    body["pictures"] += [{"source": product.meli_imagen_logo}]

            else:
                return warningobj.info(
                    cr,
                    uid,
                    title="MELI WARNING",
                    message="Debe completar el campo 'Imagen_Logo' con el url: http://www.nuevohorizonte-sa.com.ar/images/logo1.png",
                    message_html="",
                )

            # check fields
            if product.meli_description == False:
                return warningobj.info(
                    cr,
                    uid,
                    title="MELI WARNING",
                    message="Debe completar el campo 'description' (en html)",
                    message_html="",
                )

            # put for editing, post for creating
            if product.meli_id:
                response = meli.put("/items/" + product.meli_id, body, {"access_token": meli.access_token})
            else:
                assign_img = True and product.meli_imagen_id
                response = meli.post("/items", body, {"access_token": meli.access_token})

            # check response
            # print response.content
            rjson = response.json()

            # check error
            if "error" in rjson:
                # print "Error received: %s " % rjson["error"]
                error_msg = "MELI: mensaje de error:  %s , mensaje: %s, status: %s, cause: %s " % (
                    rjson["error"],
                    rjson["message"],
                    rjson["status"],
                    rjson["cause"],
                )
                _logger.error(error_msg)

                missing_fields = error_msg

                # expired token
                if "message" in rjson and (rjson["message"] == "invalid_token" or rjson["message"] == "expired_token"):
                    meli = Meli(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
                    url_login_meli = meli.auth_url(redirect_URI=REDIRECT_URI)
                    # print "url_login_meli:", url_login_meli
                    # raise osv.except_osv( _('MELI WARNING'), _('INVALID TOKEN or EXPIRED TOKEN (must login, go to Edit Company and login):  error: %s, message: %s, status: %s') % ( rjson["error"], rjson["message"],rjson["status"],))
                    return warningobj.info(
                        cr, uid, title="MELI WARNING", message="Debe iniciar sesión en MELI.  ", message_html=""
                    )
                else:
                    # Any other errors
开发者ID:Richardgh83,项目名称:meli_oerp,代码行数:70,代码来源:product_post.py


注:本文中的melisdk.meli.Meli.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。