Skip to content

Commit

Permalink
Merge pull request #13 from Vacxe/commit-changes
Browse files Browse the repository at this point in the history
Add edit id for commands
  • Loading branch information
Vacxe authored Jun 4, 2020
2 parents 2a0a0f1 + 16392a3 commit b880c58
Show file tree
Hide file tree
Showing 44 changed files with 248 additions and 154 deletions.
147 changes: 93 additions & 54 deletions src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.io.File
import java.io.FileInputStream

class PlayStoreApi(serviceAccountJson: File, appName: String) :
Edit,
Apks,
Bundles,
Deobfuscationfiles,
Expand Down
19 changes: 11 additions & 8 deletions src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
package com.github.vacxe.googleplaycli

import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.dsl.addCmd
import com.github.vacxe.googleplaycli.dsl.baseCmd
import com.github.vacxe.googleplaycli.dsl.cmd
import com.github.vacxe.googleplaycli.dsl.subcmd

fun main(args: Array<String>) {
cmd("google-play-cli") {
subcmd("apk") {
baseCmd("list", "Lists all current APKs for the specified package and edit") { it.apksList(DefaultModel(packageName)) }
addCmd { Commands.Apks.List() }
addCmd { Commands.Apks.Upload() }
}
subcmd("bundles") {
baseCmd("list") { it.bundlesList(DefaultModel(packageName)) }
addCmd { Commands.Bundles.List() }
addCmd { Commands.Bundles.Upload() }
}
subcmd("deobfuscation-files") {
addCmd { Commands.Deobfuscationfiles.Upload() }
}
subcmd("details") {
baseCmd("get", "Fetches app details for this edit. This includes the default language and developer support contact information") { it.detailsGet(DefaultModel(packageName)) }
addCmd { Commands.Details.Get() }
addCmd { Commands.Details.Patch() }
addCmd { Commands.Details.Update() }
}
subcmd("edit") {
addCmd { Commands.Edits.Create() }
addCmd { Commands.Edits.Validate() }
addCmd { Commands.Edits.Commit() }
}
subcmd("expansion-files") {
addCmd { Commands.ExpansionFiles.Get() }
addCmd { Commands.ExpansionFiles.Patch() }
Expand All @@ -37,8 +40,8 @@ fun main(args: Array<String>) {
addCmd { Commands.Images.Upload() }
}
subcmd("listings") {
baseCmd("deleteAll", "Deletes all localized listings from an edit") { it.listingsDeleteAll(DefaultModel(packageName)) }
baseCmd("list", "Returns all of the localized store listings attached to this edit") { it.listingsList(DefaultModel(packageName)) }
addCmd { Commands.Listings.DeleteAll() }
addCmd { Commands.Listings.List() }
addCmd { Commands.Listings.Get() }
addCmd { Commands.Listings.Delete() }
addCmd { Commands.Listings.Update() }
Expand All @@ -51,7 +54,7 @@ fun main(args: Array<String>) {
}
subcmd("tracks") {
addCmd { Commands.Tracks.Get() }
baseCmd("list", "Lists all the track configurations for this edit") { it.tracksList(DefaultModel(packageName)) }
addCmd { Commands.Tracks.List() }
addCmd { Commands.Tracks.Patch() }
addCmd { Commands.Tracks.Update() }
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/com/github/vacxe/googleplaycli/actions/Apks.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.vacxe.googleplaycli.actions

import com.github.vacxe.googleplaycli.actions.model.ApksUploadModel
import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.actions.model.EditModel
import com.github.vacxe.googleplaycli.core.constants.MediaType.MIME_TYPE_APK
import com.google.api.client.http.AbstractInputStreamContent
import com.google.api.client.http.FileContent
Expand All @@ -10,16 +10,16 @@ import com.google.api.services.androidpublisher.model.Apk
import com.google.api.services.androidpublisher.model.ApksListResponse

interface Apks : BaseAction {
fun apksList(model: DefaultModel): ApksListResponse {
fun apksList(model: EditModel): ApksListResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.apks().list(model.packageName, insert.id).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.apks().list(model.packageName, editId).execute()
}

fun apksUpload(model: ApksUploadModel): Apk {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val apkFile: AbstractInputStreamContent = FileContent(MIME_TYPE_APK, model.apk)
return edits.apks().upload(model.packageName, insert.id, apkFile).execute()
return edits.apks().upload(model.packageName, editId, apkFile).execute()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.vacxe.googleplaycli.actions

import com.github.vacxe.googleplaycli.actions.model.BundlesUploadModel
import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.actions.model.EditModel
import com.github.vacxe.googleplaycli.core.constants.MediaType.MIME_TYPE_APK
import com.google.api.client.http.AbstractInputStreamContent
import com.google.api.client.http.FileContent
Expand All @@ -10,17 +10,17 @@ import com.google.api.services.androidpublisher.model.Bundle
import com.google.api.services.androidpublisher.model.BundlesListResponse

interface Bundles : BaseAction {
fun bundlesList(model: DefaultModel): BundlesListResponse {
fun bundlesList(model: EditModel): BundlesListResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.bundles().list(model.packageName, insert.id).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.bundles().list(model.packageName, editId).execute()
}

fun bundlesUpload(model: BundlesUploadModel): Bundle {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val apkFile: AbstractInputStreamContent = FileContent(MIME_TYPE_APK, model.bundle)
return edits.bundles().upload(model.packageName, insert.id, apkFile)
return edits.bundles().upload(model.packageName, editId, apkFile)
.apply { ackBundleInstallationWarning = model.ackBundleInstallationWarning }
.execute()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.google.api.services.androidpublisher.model.DeobfuscationFilesUploadRe
interface Deobfuscationfiles : BaseAction {
fun deobfuscationFilesUpload(model: DeobfuscationfilesUploadModel): DeobfuscationFilesUploadResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val deobfuscation: AbstractInputStreamContent = FileContent(MIME_TYPE_APK, model.deobfuscation)
return edits.deobfuscationfiles().upload(model.packageName, insert.id, model.apkVersionCode, model.deobfuscationFileType, deobfuscation).execute()
return edits.deobfuscationfiles().upload(model.packageName, editId, model.apkVersionCode, model.deobfuscationFileType, deobfuscation).execute()
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
package com.github.vacxe.googleplaycli.actions

import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.actions.model.DetailsPatchModel
import com.github.vacxe.googleplaycli.actions.model.DetailsUpdateModel
import com.github.vacxe.googleplaycli.actions.model.EditModel
import com.google.api.services.androidpublisher.AndroidPublisher
import com.google.api.services.androidpublisher.model.AppDetails

interface Details : BaseAction {
fun detailsGet(model: DefaultModel): AppDetails {
fun detailsGet(model: EditModel): AppDetails {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.details().get(model.packageName, insert.id).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.details().get(model.packageName, editId).execute()
}

fun detailsPatch(model: DetailsPatchModel): AppDetails {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val appDetails = AppDetails().apply {
model.contactEmail?.let { contactEmail = it }
model.contactPhone?.let { contactPhone = it }
model.contactWebsite?.let { contactWebsite = it }
model.defaultLanguage?.let { defaultLanguage = it }
}
return edits.details().patch(model.packageName, insert.id, appDetails).execute()
return edits.details().patch(model.packageName, editId, appDetails).execute()
}

fun detailsUpdate(model: DetailsUpdateModel): AppDetails {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val appDetails = AppDetails().apply {
model.contactEmail?.let { contactEmail = it }
model.contactPhone?.let { contactPhone = it }
model.contactWebsite?.let { contactWebsite = it }
model.defaultLanguage?.let { defaultLanguage = it }
}
return edits.details().update(model.packageName, insert.id, appDetails).execute()
return edits.details().update(model.packageName, editId, appDetails).execute()
}

}
24 changes: 24 additions & 0 deletions src/main/kotlin/com/github/vacxe/googleplaycli/actions/Edit.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.github.vacxe.googleplaycli.actions

import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.actions.model.EditModel
import com.google.api.services.androidpublisher.AndroidPublisher
import com.google.api.services.androidpublisher.model.AppEdit

interface Edit: BaseAction {
fun editCreate(model: DefaultModel): String {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return insert.id
}

fun editCommit(model: EditModel): AppEdit {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
return edits.commit(model.packageName, model.editId).execute()
}

fun editValidate(model: EditModel): AppEdit {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
return edits.validate(model.packageName, model.editId).execute()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import com.google.api.services.androidpublisher.model.ExpansionFilesUploadRespon
interface ExpansionFiles : BaseAction {
fun expansionFilesGet(model: ExpansionFilesGetModel): ExpansionFile {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.expansionfiles().get(model.packageName, insert.id, model.apkVersionCode, model.expansionFileType).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.expansionfiles().get(model.packageName, editId, model.apkVersionCode, model.expansionFileType).execute()
}

fun expansionFilesPatch(model: ExpansionFilesPatchModel): ExpansionFile {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val expansionFile = ExpansionFile().apply {
model.fileSize?.let { fileSize = it }
model.referencesVersion?.let { referencesVersion = it }
Expand All @@ -29,7 +29,7 @@ interface ExpansionFiles : BaseAction {
return edits.expansionfiles()
.patch(
model.packageName,
insert.id,
editId,
model.apkVersionCode,
model.expansionFileType,
expansionFile)
Expand All @@ -38,7 +38,7 @@ interface ExpansionFiles : BaseAction {

fun expansionFilesUpdate(model: ExpansionFilesUpdateModel): ExpansionFile {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val expansionFile = ExpansionFile().apply {
fileSize = model.fileSize
referencesVersion = model.referencesVersion
Expand All @@ -47,7 +47,7 @@ interface ExpansionFiles : BaseAction {
return edits.expansionfiles()
.update(
model.packageName,
insert.id,
editId,
model.apkVersionCode,
model.expansionFileType,
expansionFile)
Expand All @@ -56,13 +56,13 @@ interface ExpansionFiles : BaseAction {

fun expansionFilesUpload(model: ExpansionFilesUploadModel): ExpansionFilesUploadResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val expansionFile: AbstractInputStreamContent = FileContent(MediaType.MIME_TYPE_APK, model.expansionFile)

return edits.expansionfiles()
.upload(
model.packageName,
insert.id,
editId,
model.apkVersionCode,
model.expansionFileType,
expansionFile)
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/com/github/vacxe/googleplaycli/actions/Images.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ import com.google.api.services.androidpublisher.model.ImagesUploadResponse
interface Images : BaseAction {
fun imagesList(model: ImagesListModel): ImagesListResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.images().list(model.packageName, insert.id, model.language, model.imageType).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.images().list(model.packageName, editId, model.language, model.imageType).execute()
}

fun imagesDelete(model: ImagesDeleteModel): Void {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.images().delete(model.packageName, insert.id, model.language, model.imageType, model.imageId).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.images().delete(model.packageName, editId, model.language, model.imageType, model.imageId).execute()
}

fun imagesDeleteAll(model: ImagesDeleteAllModel): ImagesDeleteAllResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
return edits.images().deleteall(model.packageName, insert.id, model.language, model.imageType).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
return edits.images().deleteall(model.packageName, editId, model.language, model.imageType).execute()
}

fun imagesUploadAll(model: ImagesUploadModel): ImagesUploadResponse {
val edits: AndroidPublisher.Edits = androidPublisher.edits()
val insert = edits.insert(model.packageName, null).execute()
val editId = model.editId ?: edits.insert(model.packageName, null).execute().id
val image: AbstractInputStreamContent = FileContent(MediaType.MIME_TYPE_PNG, model.image)
return edits.images().upload(model.packageName, insert.id, model.language, model.imageType, image).execute()
return edits.images().upload(model.packageName, editId, model.language, model.imageType, image).execute()
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package com.github.vacxe.googleplaycli.actions

import com.github.vacxe.googleplaycli.actions.model.DefaultModel
import com.github.vacxe.googleplaycli.actions.model.InappproductsDeleteModel
import com.github.vacxe.googleplaycli.actions.model.InappproductsGetModel
import com.github.vacxe.googleplaycli.actions.model.InappproductsInsertModel
import com.github.vacxe.googleplaycli.actions.model.InappproductsPatchModel
import com.github.vacxe.googleplaycli.actions.model.InappproductsUpdateModel
import com.github.vacxe.googleplaycli.actions.model.*
import com.google.api.services.androidpublisher.model.InAppProduct
import com.google.api.services.androidpublisher.model.InappproductsListResponse
import java.nio.file.Files
Expand Down
Loading

0 comments on commit b880c58

Please sign in to comment.