Skip to content

Commit

Permalink
nullable fixes working
Browse files Browse the repository at this point in the history
  • Loading branch information
iankang committed Nov 2, 2021
2 parents d0f220b + f6bcddb commit 6f63fe1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/
.idea/*
.idea/workspace.xml
28 changes: 4 additions & 24 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# mixjar
music mixes java library
This is an unofficial [Mixcloud Developer API](https://www.mixcloud.com/developers/) wrapper developed in kotlin for
the purpose of easily consuming the API for use in JVM environments.

#Usage

Add it in your root build.gradle at the end of repositories:

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Add the dependency

dependencies {
implementation 'com.github.iankang:mixjar:1.03'
}

### Implementation Example

val mixCloudServiceImpl = MixCloud()
val item = mixCloudServiceImpl.getUser("DjChief254")
//you can now use your fresh item object

## Language Used:
* Kotlin

## Libraries Used.
These are the libraries used in the development of this wrapper.
Order does not denote significance.

1. [gson](https://github.com/google/gson)
2. [okhttp](https://square.github.io/okhttp/)
3. [retrofit](https://square.github.io/retrofit/)
4. [io.rest-assured](https://rest-assured.io/)

## Caveat

This is not yet complete and is not an official MixCloud wrapper.
send your thoughts and suggestions to ianngech@gmail.com
4 changes: 2 additions & 2 deletions src/main/java/com/mixsteroids/mixjar/main.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mixsteroids.mixjar

fun main(){
// val mixCloudServiceImpl = MixCloud()
val mixCloudServiceImpl = MixCloud()
// val item1 = mixCloudServiceImpl.getShow("spartacus","party-time",1)
// val item = mixCloudServiceImpl.getUser("ian-kangethe")
// println("actualItem: ${item?.toString()}")
// println("getShow: $item1")
// mixCloudServiceImpl.getUser("DjChief254")
// val item = mixCloudServiceImpl.getUserFeed("ian-kangethe",1)
// mixCloudServiceImpl.getUserCloudCast("DjChief254",2)
// mixCloudServiceImpl.getCity("nairobi");
// mixCloudServiceImpl.getUserFeed("ndungujan23",3)
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/com/mixsteroids/mixjar/models/UserResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ package com.mixsteroids.mixjar.models
import com.google.gson.annotations.SerializedName


data class UserResponse (
data class UserResponse(

@SerializedName("key") val key : String?,
@SerializedName("url") val url : String?,
@SerializedName("name") val name : String?,
@SerializedName("username") val username : String?,
@SerializedName("pictures") val pictures : UserResponsePictures?,
@SerializedName("biog") val biog : String?,
@SerializedName("created_time") val created_time : String?,
@SerializedName("updated_time") val updated_time : String?,
@SerializedName("follower_count") val follower_count : Int?,
@SerializedName("following_count") val following_count : Int?,
@SerializedName("cloudcast_count") val cloudcast_count : Int?,
@SerializedName("favorite_count") val favorite_count : Int?,
@SerializedName("listen_count") val listen_count : Int?,
@SerializedName("is_pro") val is_pro : Boolean?,
@SerializedName("is_premium") val is_premium : Boolean?,
@SerializedName("city") val city : String?,
@SerializedName("country") val country : String?,
@SerializedName("cover_pictures") val cover_pictures : UserResponseCoverPictures?,
@SerializedName("picture_primary_color") val picture_primary_color : Int?,
@SerializedName("type") val type : String?,
@SerializedName("metadata") val metadata : UserResponseMetadata?
@SerializedName("key") val key: String?,
@SerializedName("url") val url: String?,
@SerializedName("name") val name: String?,
@SerializedName("username") val username: String?,
@SerializedName("pictures") val pictures: UserResponsePictures?,
@SerializedName("biog") val biog: String?,
@SerializedName("created_time") val created_time: String?,
@SerializedName("updated_time") val updated_time: String?,
@SerializedName("follower_count") val follower_count: Int?,
@SerializedName("following_count") val following_count: Int?,
@SerializedName("cloudcast_count") val cloudcast_count: Int?,
@SerializedName("favorite_count") val favorite_count: Int?,
@SerializedName("listen_count") val listen_count: Int?,
@SerializedName("is_pro") val is_pro: Boolean?,
@SerializedName("is_premium") val is_premium: Boolean?,
@SerializedName("city") val city: String?,
@SerializedName("country") val country: String?,
@SerializedName("cover_pictures") val cover_pictures: UserResponseCoverPictures?,
@SerializedName("picture_primary_color") val picture_primary_color: Int?,
@SerializedName("type") val type: String?,
@SerializedName("metadata") val metadata: UserResponseMetadata?
){
constructor( userResponse:UserResponse?) : this(
userResponse?.key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import retrofit2.http.Query

interface MixCloudService {
@GET("{user}/?metadata=1")
fun getUser(@Path("user")username:String): Single<UserResponse>
fun getUser(@Path("user")username:String): Single<UserResponse?>

@GET("{user}/cloudcasts")
fun getUserCloudCasts(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single<UserCloudCastResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class MixCloudServiceImpl : MixCloudInterface {
val showCall = mixCloudApi.getShow(entertainer, show, offset = getOffsetFromPage(page)!!)
var showResponseRx:ShowResponse? = null
showCall.subscribe { showResponse, throwable ->
showResponseRx = ShowResponse(showResponse)
if(throwable == null) {
showResponseRx = ShowResponse(showResponse)
}else{
println(throwable.message)
}
}
return showResponseRx
}
Expand Down Expand Up @@ -59,7 +63,11 @@ class MixCloudServiceImpl : MixCloudInterface {
val userCall = mixCloudApi.getUser(username)
var userResponselocal:UserResponse? = null
userCall.subscribe { userResponse, throwable ->
userResponselocal = UserResponse(userResponse)
if(throwable == null) {
userResponselocal = UserResponse(userResponse)
}else{
throw Error(throwable.message)
}
}
return userResponselocal
}
Expand Down

0 comments on commit 6f63fe1

Please sign in to comment.