Experience with the Github API; It was an awesome task!

A few days ago I was given a Task that was a script based on the Github API. It was very interesting to me because I had never used it before and wanted to know how to get it and I didn’t get many docs. It was just the link that provided the API list and some brief explanations.
The Task Scenario asked me just to get information from any user I just implemented so that I can add more if I have the time, but would love to have you develop it, and I wrote Authorizing OAuth in another test app, which I’ll add later. !
Well let’s get to the story of the Sana and the Github :)
Well, first of all, I needed different dependencies and I listed this:
Here’s a brief explanation, but see the project at the Git Hub for more information.
Because I went through MVVM architecture, the first thing I did was create a data model class called the User and put the information I wanted.
The next step was to create a server-side interface called ApiService. Here I call the endpoint that was for my Api (/ users / {username}) by getting. The point is that this username is something we have to send and reply to @Path to the server, and in the RetrofitClient class we have to build a builder from RetrofitClient and create the one you can see the code.
The next step is to create a Repository that should use the same class we created, as well as our Model class, and pass the variables to the ViewModel class. And note that this class is based on the Singleton pattern so I used Object so I didn’t forget to use LiveData and CoroutineScope.
Well, we get to ViewModel then to the MainViewModel class in the project. Here, using MutableLiveData, we create variables that we have prepared to pass to View.
The last step in using ViewModel information is in the HomeFragment (view our story), which we capture and use with Observing ViewModel.
Well done. You can take a look at the list of APIs like the Repoes list that I’m sure will add.
Please don’t look carefully at the text of Commit :D
I hope it is useful and you can use it. If you have any similar experiences, be happy to share with me and others.
Sana Ebadi | 19:47 PM, 8 December 2019