APIs & Integrations

robsoncabral
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

como identificar a qual line item e a qual negócio o produto pertence?

Como eu consigo identificar a qual item de linha o meu produto pertence e a qual negócio ele pertence tendo apenas o ID do produto como informação dentro de uma API?

4 Antworten
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

como identificar a qual line item e a qual negócio o produto pertence?

hello @robsoncabral ,

I am going to hand this off to some of our Spanish speaking friends as I will definitely make a fool of myself!

 

@jpsanchez @prosa would you all mind weighing in here?

 

Thanks!

 

0 Upvotes
caiodonald
Stratege/Strategin | Diamond Partner
Stratege/Strategin | Diamond Partner

como identificar a qual line item e a qual negócio o produto pertence?

Hi @dennisedson it's portuguese actually, so a portuguese speaker would be more helpful

Caio Donald

HubSpot Trainer and Specialist

Zing - Platinum Tiered Partner Agency

Vamos conversar? / Let's talk?
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

como identificar a qual line item e a qual negócio o produto pertence?

Ladies and gentlemen,

I am officially retiring.  I see that now... :facepalm

 

Thanks, @caiodonald 

 

@robsoncabral , can you be more specific with what you are trying to do?  What is your API request, what endpoint are you using? Any examples of what is being returned would also be helpful

 

Thanks again, and sorry for my language trip up! 

 

Tagging @PamCotton , just in case translations are needed (clearly I need them)

 

 

robsoncabral
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

como identificar a qual line item e a qual negócio o produto pertence?

Hi Dennis,

 

I need to update some products within line items in some deals.

 

I created a page where the user will send a spreadsheet and the system will read this spreadsheet and for each product it should:

- Check if the product exists

- If it exists then update all the properties identified in the spreeadsheet that belong to the product

- Then identify which line intem is associated with the product and update the properties of that item if necessary

- Then identify which deal is associated with the line item and update the properties of that deal if necessary

 

I set up an API where I filter by the product id and make sure it exists using the endpoint Product - Search and update the properties of product.

 

But in the sequence I can´t evolve because I didn´t find a way to link the product with the line item or the deal.

 

Exemple:

 

<cfif StructKeyExists(form"NomeArquivo")>
    <!--- Passando o arquivo para o servidor --->
    <cffile action = "upload" fileField = "NomeArquivo" destination = "#expandpath('.')#\HubSpot\ImportarPlanilha\" nameConflict = "overwrite" result = "arquivo">
    <!--- Lendo o arquivo em uma variável --->
    <cffile action = "read" file = "#expandpath('.')#\HubSpot\ImportarPlanilha\#arquivo.serverfile#" variable = "meuCSV">
    <!--- Array com o conteúdo da linha --->
    <cfset aLinha = ArrayNew("1")>
    <!--- Extraindo o conteudo do arquivo --->
    <cfloop index = "linha" list = "#meuCSV#" delimiters = "#chr(10)##chr(13)#">
        <cfif len(trim(replace(linha,";","")))>
            <cfset aLinha = ListToArray(linha,";","true")>
            <cfif arrayLen(aLinha)>
                <!---dados para consultar se o produto existe --->
                <cfsavecontent variable = "dadosJSON">
                    {
                        "after": "0",
                        "filterGroups": [
                            {
                                "filters": [
                                    {
                                        "operator": "EQ",
                                        "propertyName": "id",
                                        "value": "<cfoutput>#aLinha[1]#</cfoutput>"
                                    }
                                ]
                            }
                        ],
                        "limit": "20",
                        "properties": [
                            "string"
                        ],
                        "query": ""
                    }
                </cfsavecontent>
                <!--- Monta o componente de controle --->
                <cfset cfcHubSpot = new HubSpot()>
                <!--- Usa a função de consulta do componente --->
                <cfset consultaProduto = cfcHubSpot.consultaServico(
                    urlServico:"https://api.hubapi.com/crm/v3/objects/products/search?hapikey=HSKey",
                    metodoServico:"post",
                    body:dadosJSON
                )>
                <cfif consultaProduto.codigo EQ 200>
                    <!--- dados para alteração dos campos do produto localizado --->
                    <cfsavecontent variable = "dadosJSON_Update">
                        {
                            "archived": false,
                            "properties": { <!--- Última modificação (Timespam with timezone) --->
                                            "hs_lastmodifieddate": "<cfoutput>#DateFormat(now(),"YYYY-MM-DDThh:mm:ss.sTZD")#</cfoutput>",
                                            <!--- Custo unitário - quanto os produtos vendidos custaram para os clientes, numérico --->
                                            "hs_cost_of_goods_sold": "<cfoutput>#aLinha[3]#</cfoutput>",
                                            <!--- Nome, texto --->
                                            "name": "<cfoutput>#aLinha[6]#</cfoutput>",
                                            <!--- Descrição - Descrição completa do produto, texto --->
                                            "description": "<cfoutput>#aLinha[14]#</cfoutput>"
                                            .
                                            .
                                            .
                                        },
                            "updatedAt": "<cfoutput>#DateFormat(now(),"YYYY-MM-DDThh:mm:ss.sTZD")#</cfoutput>"
                        }
                    </cfsavecontent>
                    <cfset AtualizaProduto = cfcHubSpot.atualizaProduto(
                        urlServico:"https://api.hubapi.com/crm/v3/objects/products/#aLinha[1]#?hapikey=HSKey",
                        metodoServico:"PATCH",
                        body:dadosJSON_Update
                    )>
                    <cfif AtualizaProduto.codigo EQ 200>
                        line item ???
                        deal ???
                    <cfelse>
                        <cfdump var = "#AtualizaProduto#" label="Temos problemas com a atualização">
                        <cfexit>
                    </cfif>
                <cfelse>
                    <cfdump var = "#consultaProduto#" label="Temos problemas com a consulta">
                    <cfexit>
                </cfif>
            <cfelse>
                <cfexit>
            </cfif>
        <cfelse>
            <cfexit>
        </cfif>
    </cfloop>
</cfif>

 

0 Upvotes