Welcome back and this video, we are going to prepare the different models that we're going to need
because we are going to need quite some of them.
We're going to need a lot of different classes which will take care of everything that we can see here,
which is basically just this code here brought into a format that is easier, readable, let's say so
into this format.
You can see it's this code here.
And then we're going to prepare the code to make an API call to our home, open weather map work so
we can then get this kind of result.
And then finally, of course, we will use that in order to display it accordingly later on.
OK, so in order to get that, let's first of all, create the different models.
I'm going to prepare two of them with you and the other ones you will have to build yourself.
So I'm just going to quickly show you the first ones that are the major ones, so to speak.
So we will need a model for the whole response.
So the whole weather response, which will be this chasten object.
And you can see we have multiple different variables in there.
So we have, for example, the court weather domain, the wind, the clouds, the system.
Then we have to deti to ID the name at the court.
OK, so let's add those into our project.
All right, let's go back.
To the project and then create a new.
Folder, I'd say, in order to keep everything clean.
So in here, I'm going to create a new directory, new package.
This one will be called Models.
And actually models like this are written here.
I'm going to create a new kotlin file, which will be a content class, and I'm going to call this one
weather response.
So this one will be a data class where the response and now in this data class, I want to have all
of the different variables that we had there.
So first of all, we had the court, which will be of type court.
Then we had the weather, which will be a list of objects.
So here we just have one weather object, which is the ID main clear description, clear sky and an
icon.
All right, so this is the actual weather object, but we have a list of weather objects, OK, then
we have based, which is just a string.
We have Maine, which is another class, which has a bunch of doubles in their humidity.
Could be an end.
But that's something that we can look at.
Then we have a wind class, so to speak, which has two variables.
One of them being a double, the other one being an integer.
And so forth.
OK, so I'm just going to finish this one up real quick.
So we have a list of whether, of course, we don't have a weather clause yet, we will need to prepare
that.
We have the base, which is a string.
We have the main which is a main class, the visibility, which is going to be an integer.
The wind, which will be a wind object, so here wind, which will be wind, object clouds, which will
be a cloud's object, D.T., which will be an integer system, which will be a sex object idea, which
is an integer.
And then the name, which is a string, and then finally we have the code, which is going to be in
it.
OK, so how do I get all of those things?
Where do I get them from?
Well, let's look at it from this perspective.
So we have caught, which is if we open up an object, then we have a list here, which is a list of
wethers.
So we have a list of whether then we look at base can see base is just a string because we have those
quotation marks here.
We have another object or a class which will be called main.
So we have Main here, which has a bunch of values in it.
Then we have the clout class where we have the wind here as well.
Visibility.
Where does that come from?
Well.
It's not available in this case.
But as you can see here, in other cases, they also have this visibility here, so we could make it
now potentially or set it to zero or something like that.
But you can see some API calls have it, some don't display it, but we will potentially get that later
on.
So let's put that in there as well so you can see that we will need to set those things up.
OK, so I'm going to show you one of them, which will just be the court.
OK, so we have the weather response.
And by the way, I want this to be serializable so that we can then later on use it.
In different formats, and it, for example, because I want to be able to store a weather response
on the phone as a string, so we need to make it serializable.
So then let's go ahead and create another model class, Soheir New.
Cutting class, and as I said, I'm going to call this one court, so coordinates C, O, R, D, and
this one will be another.
That's a class.
And what do we have in court while long, which will be a double and then we'll led, which will also
be a double.
OK, so this is our class court and we'll also make this.
Serializable.
All right, because we use it in our weather response, so now you can see court, this error disappeared.
So now what you will need to do is you need to do that with whether main wind clouds and.
So you need to look at weather.
So how does a weather object look like?
And it's as you can see here, it has an idea which is an integer.
It has a string called Main Eye String called Clear Description and a string called Eichen.
Then you need to do the same thing with men.
You create a main class which has a double, which is called temp, another double, which is called
pressure and so forth.
So please post a video and build those up.
So this is really going to be good practice because you will need to have those models in order for
them to work perfectly fine with Jaeson because we're going to use Jaeson again.
And you have seen at the demo how Jaeson works.
Right.
And it needs to have the clean structure for your classes in order to work correctly.
All right.
So I hope you added all of those different classes to your models.
Now, let's look at those step by step.
And I'm going to make this a little bigger here.
So we have the clouds here to look at the clouds.
Let's open those up here.
Let's open everything.
So let's look at clouds.
We can see clouds has something called all, which is of type.
And now let's look at Maine.
You can see we have the temperature here, which is a double.
Then we have the pressure, which is also a double.
Humidity is an integer, as it seems to mean is a double tap.
Max is a double.
And then we have sea level and ground level.
Well, you can implement them, but for me, it worked without those.
So and most calls, I won't get this information.
But if you want to really make sure, then you would also have the sea level here, which is going to
be a double.
And then finally, the ground level, which will also be a double.
All right.
OK, so this is our main class.
Then we have this.
If we look at this, you can see we have a message, which is a double.
We have the country, which is a string.
We have the sunrise and with the sunset.
And as you can see in this case, we don't have the type.
So this is something that you might want to add as well.
That's why we look over them, because this response here is potentially not having all of the data
that we're going to get later on.
OK, so we will need to see what the response will be like once we use our own API call.
OK, because this is just.
From the sample data, but once we use our own API call, we might get more or less data.
All right, then.
We can look at weather, so here a weather object is what, an integer, which is the ID then domain,
which is a string description, which is a string and an icon, which is a string as well.
We have the wind, which.
Is the speed and the degree which speed will be double and degree will be integer, so you see I use
a double because here potentially we want to have the speed more precisely, but this really depends.
So this could have been an integer as well.
All right.
So these are the different objects that we're going to need.
And then if we look at weather response, you can see now the arrows disappeared and all of them are
good.
Now, if you didn't have all of them exactly as I did, that's totally fine.
You don't need to have all the values exactly as they are in my case, but they should fit to a certain
degree with what you see here in your Jason voyeuristic Soheir and the response that you get from open
weather map and you will have to double check once you get the real results, because these are, as
I said, are just samples.
So once we double check that with our real API calls, then we can see that we, for example, will
also need visibility or other variables that we don't see in this particular example, but maybe in
the other code examples.
So here insist, as you can see, there is this type thing which wasn't available in our other example
here.
So if we look at this, you can see there is no type here.
So this really depends on what we get later on once we do the call.
All right, I think this is going to be enough for this video, even though I wanted to add the other
stuff as well, such as adding the call and everything else, but I just think this is a great point
to make a break.
And then in the next video, we're going to add interfaces and all of the other interesting stuff that
we will need in order to make an API call.
So see you there.