Skip to content

Commit

Permalink
Merge pull request #4 from KSoft-Si/2.1
Browse files Browse the repository at this point in the history
Merge 2.1 into master.
  • Loading branch information
ChachyDev authored Sep 6, 2020
2 parents a321ba9 + 261908c commit 842541f
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 56 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
id 'org.jetbrains.kotlin.jvm' version '1.4.0'
}

group 'si.ksoft'
Expand All @@ -12,9 +12,9 @@ repositories {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "io.ktor:ktor-client-gson:1.3.2"
implementation "io.ktor:ktor-client-core:1.3.2"
implementation "io.ktor:ktor-client-apache:1.3.2"
implementation "io.ktor:ktor-client-gson:1.4.0"
implementation "io.ktor:ktor-client-core:1.4.0"
implementation "io.ktor:ktor-client-apache:1.4.0"
}

compileKotlin {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 3 additions & 4 deletions src/main/kotlin/si/ksoft/ksoftlin/builder/Ksoftlin.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package si.ksoft.ksoftlin.builder

import io.ktor.client.HttpClient
import io.ktor.client.engine.apache.Apache
import io.ktor.client.features.json.GsonSerializer
import io.ktor.client.features.json.Json
import io.ktor.client.*
import io.ktor.client.engine.apache.*
import io.ktor.client.features.json.*
import si.ksoft.ksoftlin.endpoints.KsoftEndpoints

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package si.ksoft.ksoftlin.data.dbl.vote.list
import com.google.gson.annotations.SerializedName
import si.ksoft.ksoftlin.data.dbl.vote.Vote

data class Vote(val expiry: String, val extras: List<String>, @SerializedName("user") val id: Long, val isWeekend: Boolean)
data class Vote(
val expiry: String,
val extras: List<String>,
@SerializedName("user") val id: Long,
val isWeekend: Boolean
)

data class ListVoteResponse(val votes: List<Vote>)
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ data class RedditPost(
val createdAt: Long,
@SerializedName("nsfw")
val isNsfw: Boolean,
val author: String
val author: String,
val awards: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package si.ksoft.ksoftlin.data.kumo.location

import com.google.gson.annotations.SerializedName

data class Location(val address: String,
@SerializedName("lat")
val latitude: Double,
@SerializedName("lon")
val longitude: Double,
@SerializedName("bounding_box")
val boundingBox: List<String>,
val type: List<String>,
val map: String)
data class Location(
val address: String,
@SerializedName("lat")
val latitude: Double,
@SerializedName("lon")
val longitude: Double,
@SerializedName("bounding_box")
val boundingBox: List<String>,
val type: List<String>,
val map: String
)

data class LocationResponse(val error: Boolean, val code: Int, val message: String? = null, val data: Location)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import com.google.gson.annotations.SerializedName

data class LocationLinks(
val weather: String,
val gis: String, @SerializedName("openstreetmap") val openStreetMap: String, @SerializedName("googlemaps") val googleMaps: String
val gis: String,
@SerializedName("openstreetmap") val openStreetMap: String,
@SerializedName("googlemaps") val googleMaps: String
)

data class Location(
Expand All @@ -31,4 +33,9 @@ data class Location(
val apis: LocationLinks
)

data class GeoIPLocationResponse(val error: Boolean, val code: Int, @SerializedName("data") val location: Location, val message: String? = null)
data class GeoIPLocationResponse(
val error: Boolean,
val code: Int,
@SerializedName("data") val location: Location,
val message: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,64 @@ import com.google.gson.annotations.SerializedName

data class SongResponse(val data: List<Song>)

data class Song(val artist: String,
val artistId: Int,
val album: String,
@SerializedName("album_ids")
val albumIds: String,
@SerializedName("album_year")
val albumYear: String,
val name: String,
val lyrics: String,
@SerializedName("search_str")
val searchString: String,
@SerializedName("album_art")
val albumArt: String,
val popularity: Int,
val id: String,
@SerializedName("search_score")
val searchScore: Double)
data class Song(
val artist: String,
val artistId: Int,
val album: String,
@SerializedName("album_ids")
val albumIds: String,
@SerializedName("album_year")
val albumYear: String,
val name: String,
val lyrics: String,
@SerializedName("search_str")
val searchString: String,
@SerializedName("album_art")
val albumArt: String,
val popularity: Int,
val id: String,
@SerializedName("search_score")
val searchScore: Double,
val url: String,
val singalongStamp: List<SingalongStamp>?,
val meta: Metadata
)

data class Metadata(
val spotify: SpotifyMetadata,
val deezer: DeezerMetadata,
val artist: List<Artist>,
val other: OtherMetadata
)

data class SpotifyMetadata(
val artists: List<String>?,
val track: String?,
val album: String?
)

data class DeezerMetadata(
val artist: List<String>?,
val track: String?,
val album: String?
)


data class Artist(
val name: String?,
@SerializedName("is_primary")
val isPrimary: Boolean?
)

data class OtherMetadata(
val gain: Double,
val bpm: Double
)

data class SingalongStamp(
@SerializedName("lrc_timestamp")
val lyricTimestamp: String,
val milliseconds: String,
val duration: String,
val line: String
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package si.ksoft.ksoftlin.endpoints

import io.ktor.client.request.get
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.request.*
import si.ksoft.ksoftlin.builder.client
import si.ksoft.ksoftlin.data.dbl.vote.VoteResponse
import si.ksoft.ksoftlin.data.dbl.vote.list.ListVoteResponse
Expand Down
15 changes: 7 additions & 8 deletions src/main/kotlin/si/ksoft/ksoftlin/endpoints/ImageEndpoint.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package si.ksoft.ksoftlin.endpoints

import io.ktor.client.request.get
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.request.*
import si.ksoft.ksoftlin.builder.client
import si.ksoft.ksoftlin.data.image.ImageResponse
import si.ksoft.ksoftlin.data.image.reddit.RedditPost
Expand All @@ -19,11 +17,12 @@ import si.ksoft.ksoftlin.util.api
*/

class ImageEndpoint(private val token: String) {
suspend fun getRandomImage(tag: String, isNsfw: Boolean = false) = client.get<ImageResponse>("$api/images/random-image") {
parameter("tag", tag)
parameter("nsfw", isNsfw)
header("Authorization", token)
}
suspend fun getRandomImage(tag: String, isNsfw: Boolean = false) =
client.get<ImageResponse>("$api/images/random-image") {
parameter("tag", tag)
parameter("nsfw", isNsfw)
header("Authorization", token)
}

suspend fun getTags() = client.get<TagResponse>("$api/images/tags") { header("Authorization", token) }

Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/si/ksoft/ksoftlin/endpoints/KumoEndpoint.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package si.ksoft.ksoftlin.endpoints

import io.ktor.client.request.get
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.request.*
import si.ksoft.ksoftlin.builder.client
import si.ksoft.ksoftlin.data.kumo.currency.CurrencyResponse
import si.ksoft.ksoftlin.data.kumo.location.LocationResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package si.ksoft.ksoftlin.endpoints

import io.ktor.client.request.get
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.request.*
import si.ksoft.ksoftlin.builder.client
import si.ksoft.ksoftlin.data.music.artist.Artist
import si.ksoft.ksoftlin.data.music.track.Track
Expand Down

0 comments on commit 842541f

Please sign in to comment.