Skip to content

Commit

Permalink
Merge pull request #9 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Nov 25, 2020
2 parents 7b63d7d + 7c8838a commit 3e29367
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: macos-11.0
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -35,7 +35,7 @@ jobs:
gradle-${{ runner.os }}-
- name: Build Debug
run: ./gradlew clean app:assembleDebug
run: ./gradlew clean app:assembleDebug --stacktrace

- name: Run Lint
if: github.event_name == 'pull_request'
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlin-android-extensions"
id "org.jetbrains.kotlin.kapt"
id "com.mikepenz.aboutlibraries.plugin"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.mikepenz.storyblok.app.databinding.ActivityMainBinding
import com.mikepenz.storyblok.app.items.SimpleItem
import com.mikepenz.storyblok.app.viewmodel.SampleViewModel
import com.mikepenz.storyblok.sdk.model.Story
import kotlinx.android.synthetic.main.activity_main.*

class SampleActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
Expand All @@ -46,7 +45,7 @@ class SampleActivity : AppCompatActivity() {
}

// Handle Toolbar
setSupportActionBar(toolbar)
setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(false)
supportActionBar?.setHomeButtonEnabled(true)

Expand Down Expand Up @@ -104,8 +103,8 @@ class SampleActivity : AppCompatActivity() {

//configure our fastAdapter
//get our recyclerView and do basic setup
rv.layoutManager = LinearLayoutManager(this)
rv.adapter = fastAdapter
binding.rv.layoutManager = LinearLayoutManager(this)
binding.rv.adapter = fastAdapter
fastAdapter.withSavedInstanceState(savedInstanceState)
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
buildscript {
ext {
release = [
versionName: "0.0.4",
versionCode: 4
versionName: "0.1.0",
versionCode: 100
]

setup = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ import kotlinx.serialization.json.Json
* This class is the main API class to do all the requests on the Storyblok API.
*/
class Storyblok constructor(
/**
* The API token used to do the API requests
*/
/** The API token used to do the API requests */
private val token: String,
/** Provide a custom client implementation, not using the default */
providedClient: HttpClient? = null,
/**
* Creates the [HttpClient]. Overwriting this allows to construct a custom engine, or do further adjustments to the client.
* Note that it is required to provide a serializer again to parse the data
*/
private val configureClient: HttpClientConfig<*>.() -> Unit = {
install(JsonFeature) {
configureClient: (HttpClientConfig<*>.() -> Unit)? = null
) {

constructor(
/** The API token used to do the API requests */
token: String
) : this(token, null, null)

private val client by lazy {
(providedClient ?: provideClient()).config {
(configureClient?.invoke(this) ?: install(JsonFeature) {
serializer = KotlinxSerializer(Json(builderAction = {
ignoreUnknownKeys = true
prettyPrint = true
}))
}
}
) {
private val client by lazy {
provideClient().config {
configureClient()
})
}
}

Expand Down Expand Up @@ -285,9 +289,9 @@ class Storyblok constructor(
companion object {
private val API_PROTOCOL = URLProtocol.HTTPS
private const val API_ENDPOINT = "api.storyblok.com"
private const val API_VERSION = "v1"
private const val API_VERSION = "v2"

private const val SDK_VERSION = "0.1"
private const val SDK_VERSION = "0.1.0"
private const val SDK_USER_AGENT = "storyblok-sdk-android/$SDK_VERSION"

private const val VERSION_PUBLISHED = "published"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mikepenz.storyblok.sdk.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
*
*/
@Serializable
open class Alternate {
/**
* Numeric id
*/
var id: Long = 0

/**
* The name you give this story
*/
var name: String? = null

/**
* The slug / path you give this story
*/
var slug: String? = null

/**
* Combined parent folder and current slug
*/
@SerialName("full_slug")
var fullSlug: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mikepenz.storyblok.sdk.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject

/**
* A data source is simply a collection of key-value pairs. One specific datasource-entry is a set of two linked attributes: a key,
Expand All @@ -11,7 +10,29 @@ import kotlinx.serialization.json.JsonObject
* Key-value pairs can be used for a single-choice, multiple-choice options and as well directly through our API to use them for multi-language labels,
* categories, or any use-case you might need key-value pairs.
*/
typealias DatasourceEntry = JsonObject
@Serializable
open class DatasourceEntry {
/**
* Numeric id
*/
var id: Long = 0

/**
* Given name
*/
var name: String? = null

/**
* Given slug
*/
var slug: String? = null

/**
* Given value in the requested dimension
*/
@SerialName("dimension_value")
var dimensionValue: String? = null
}

@Serializable
internal class DatasourceEntryWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.mikepenz.storyblok.sdk.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
*
*/
@Serializable
open class Slug {
/**
* the slug name (value)
*/
var name: String? = null

/**
* the path for this slug (value)
*/
var path: String? = null

/**
* the lang of the slug (value)
*/
var lang: String? = null

/**
* Is this content entry a folder (true/false)
*/
@SerialName("is_folder")
var isFolder: Boolean? = null

/**
* Parent folder id
*/
@SerialName("parent_id")
var parentId: Int? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ open class Story {
* Numeric id
*/
var id: Long = 0

/**
* Generated uuid string
*/
var uuid: String? = null

/**
* The name you give this story
*/
Expand All @@ -35,6 +37,12 @@ open class Story {
@SerialName("full_slug")
var fullSlug: String? = null

/**
* Contains the full slug of the default language if the app Translatable Slugs is installed
*/
@SerialName("default_full_slug")
var defaultFullSlug: String? = null

/**
* Creation date (Format: YYYY-mm-dd HH:MM)
*/
Expand All @@ -58,6 +66,9 @@ open class Story {
*/
var content: JsonObject? = null

/**
*
*/
@SerialName("sort_by_date")
var sortByDate: Boolean? = null

Expand Down Expand Up @@ -91,7 +102,13 @@ open class Story {
* Array of alternate objects
*/
@SerialName("alternates")
var alternates: List<String>? = null
var alternates: List<JsonObject>? = null

/**
* Array of alternate objects
*/
@SerialName("translated_slugs")
var translatedSlugs: List<JsonObject>? = null

/**
* Id of your content stage (default: null)
Expand Down

0 comments on commit 3e29367

Please sign in to comment.