#4 Get Coin History Scripting Part 2 - Integration
hi everyone so this video we are continuing the scripting part and in our previous video we saw how we can actually get the data for for example for one coin it can be Bitcoin or - for example they have the same length okay the length of the response body I mean specifically the story is three arrays thousand eight under than 25 now we're going to see how we can actually have for all coins okay so the first thing before we get started to write anything in the previous video the value they actually sorry is thousand 165 that's wrong we should have thousand four hundred and sixty-five okay that's you should make you should make these changes and as well in your cool here so then we'll just copy the code and I put right here [Music] okay the first thing that I want to show you I have a table here I have the coin ID okay I have the coin name and I have also the length for each individual coin okay I have thousand eight and twenty five for example Christmas I have thousand one hundred and forty four okay and I have some other values here so let's see why we have these values and why we're good for which purpose I'm using this one thousand seven hundred zero five thousand seven endures fight okay this value is is the one that we are using in our code let's go back here you know cool right here in the level that's a value that is going to be used in the last loop that we are going to have for the for loop but this one not this one but this one and in order to collect the last part of the the response okay it is actually going to start from thousand seven hundred zero five and then we'll go to thousand twenty-four okay so to collect the last part of our JSON response if you if you want to have kind of visual so then let's say this is the last part okay and by having this value here I can actually calculate what is the length of my last area for example H I can just take this value thousand eight hundred twenty-five minus this value it is I'm going to have 120 so that is the length of my last area okay it is important to know this value for all coins because it's not going to be the same that's why I'm doing this so if it is - it is fine I'm going to have thousand seven hundred zero right and it is actually going to have n have the same length but if we have decreed for example this coin thousand seven hundred eighty three that's a length okay know this value minus this value I'm getting 78 okay that's the length of my coronary H okay that's one thing to understand then we have the second part where we have the length for each coins it's even more smaller okay for example chain link I have thousand four hundred seven in this case the value but I'm having here it is not thousands so I'm going to fry it is not thousand four hundred and sixty five which is here but it is thousand two hundred and twenty so in this case what is happening if we have a chain link I'm not using all the ways I'm just going to have few always but not all eight are easy even blue so I'm gonna have a B C D E and then F I'm not using these two okay that's what we are actually we have to see here okay so we're gonna use five you know six six days and also the the last for the last oriental for example coronary F the length is not the same depending on the coin that I'm going to have as input if it is chain-link the length is 187 if this belongs coin it's going to 207 that's that is also changing here okay so we have to notice two different things the length but the number of areas that we're going to use and also the number the in length of my last Eric it is also different depending on the coin that we receive so I put all this together like in a form of again arrays let's go back to the coil here and want to show you something if you have Bitcoin I can use these two arrays well a and B that's what I have here and here okay so it's like a pair okay for this Bitcoin and for this - it was decreed I can use this one okay but if there's some other coins I need some other pairs okay I cannot have the same pair because the length is different I'm gonna have I show you how I should build different Aries so therefore I'm gonna have very seedy enf each one will have for example the same way we did for for Amy we're gonna have here the length for each individual arrays that we are having here so we know obviously now we have only six arrays it's visible here and the last the D is actually the value data that we are going to have in the history all right okay right here same logic same thing that we have done for a and B but we are doing for now for I mean for the coin bit coin and - we had we built these arrays so we are doing the same thing for other coins so I have all the pairs here so I'm going to just copy the pair's and then go here put it right here and then I'm gonna put a gap here so it's gonna look like a pair okay so that's the first thing the second thing is we need to know now we can see McCoy we have 120 and 207 here to 221 but we cannot have this all the time okay as you saw here the length it is changing depending on the coin that we have as input so we need to know we need to work now how we can change these values like based on the input okay we need to put some other code which is actually going to have automatically I have a different value here instead of having 120 or any other way right okay so that's what we are going to do now say so what I do the first thing I'm creating an Eric battery we contain my coin which gonna have and I do a second row will have the values that I have here okay the length so 120 120 78 207 and then swap okay so if I had access this value what I want to do so the name of the area is going to be coins I will end fair it's going to be kind of a length or 1 0 I'm gonna get to here okay if it is a 0 0 I'm gonna get to Bitcoin okay I'm gonna have this array and I can access this in this way and so now let's create this one let's screw this array in our code let's put that and then we will write the code and you'll understand how we can change that top here great so that you can see here a Bitcoin - decreed and B no one's gonna and so on these are just names okay but I have to create those variables so I have to show that in the beginning okay which is this one so I have well Bitcoin equals 1 what - equal to 13 well decree it could mean so I'm including these variables inside this way for each variables I have the coin ID so that's the first thing that you have to define so I'm going to define that here okay and then I have another area where I have good going guys to create going on so I'm gonna in the same way I have another area which has these values which which are the length ok 120 and and so on now we change these values so how we can change that the first thing that I'm going to do is I'm going to create a follow ok to smaller than 8 because if you we are having 8 coins and then okay okay but we're not going to dictate the call a time okay we are going to have a condition after that only if this condition is satisfied we can run the code okay what is that condition the condition is going to be checking what what is the input that I have okay let's imagine that you have as input one Bitcoin one so we are going to check if I have really one so how we can check that so I can put here if it's okay and I can have calling underscore ID which is a variable that we'll be creating in flow designer code which will contain basically the value that we are going to send as an input okay will be equal to to a certain value okay then I'm going to just open this one okay so what I'm going to have here is I'm good I can have one 13:28 and something like this but instead of having this I'm going to have a syntax which is actually going to get the value of the coin that I from this array so I can write here coin ID lost hurry pairs okay but I kiss brackets so if I run Bitcoin I'm gonna have zero zero okay but if I want - it is going to be 0 1 so each time I'm gonna have the second one it will be changing like this I'm gonna have here K so k will be 0 1 2 3 4 5 6 7 ok so what's happening here I am running a loop in that tube okay let me put it like this let's say you're running a test you will click on testing for designer I put the value 59 okay you put that value then what's gonna happen is gonna run this true he's going around the loop he's going to check what value that we have in the coin ID so it has already 59 in his memory coin ID we have 59 and it's going to compare to the value that is going to pick from this syntax here from this area so he's going to see 0 0 when we have its Bitcoin is it equal to 59 is it equal to 1 no it's not equal so I'm not going to execute the cool then it's going to check for - okay the second value that we have here is - so it's going to say is it equal to 30 59 in quotes um no it's not equal to 30 then is going to check for the cream and then bananas current and you will come to chain-link okay which is here it is actually 0 4 so coins ideal a story pair 0 for I have chain-link 59 is it equal to 59 yes it is equal to 59 I'm going to executor Co then we have to know the value of K here is true okay that's what we have here so I can actually use the same logic here okay I'm gonna have coins ID lost so logically issue one with this ball this voltage should be this one okay this is the one that we are going to use so it's going to call Heidi last three pairs okay brackets brackets we're gonna have k equal to 4 but if you want to get this value 187 or you want to do is to put 1 so in this way in see array in this particular place we're gonna have 187 if we get as input chain-link that's how we're going to understand so we are using the same logic for all other coins so all I want to do is just copy and then paste it here okay so we will have already to the right value in our arrays here a C or E any of these URLs will have the right value in the last element based on input in this way so this is what we have done so far but still look at the cool we have still a and B here and we cannot have all the time a and B that's what we are going to do next okay so we are we are going to actually write like regularities in order to switch in between pairs so if I have Bitcoin I will have a and B here if I have chain link I will have Cindy if I have cosmos I will have pmf so that's the next part so see in the next video
https://www.youtube.com/watch?v=gmXMSRttEaA