Package com.google.api.services.androidpublisher.AndroidPublisher

Examples of com.google.api.services.androidpublisher.AndroidPublisher.Edits


                    "ApplicationConfig.PACKAGE_NAME cannot be null or empty!");

            // Create the API service.
            final AndroidPublisher service = AndroidPublisherHelper.init(
                    ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL);
            final Edits edits = service.edits();

            // Create a new edit to make changes.
            Insert editRequest = edits
                    .insert(ApplicationConfig.PACKAGE_NAME,
                            null /** no content */);
            AppEdit appEdit = editRequest.execute();

            // Get a list of apks.
            ApksListResponse apksResponse = edits
                    .apks()
                    .list(ApplicationConfig.PACKAGE_NAME,
                            appEdit.getId()).execute();

            // Print the apk info.
View Full Code Here


                    "ApplicationConfig.PACKAGE_NAME cannot be null or empty!");

            // Create the API service.
            AndroidPublisher service = AndroidPublisherHelper.init(
                    ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL);
            final Edits edits = service.edits();

            // Create an edit to update listing for application.
            Insert editRequest = edits
                    .insert(ApplicationConfig.PACKAGE_NAME,
                            null /** no content */);
            AppEdit edit = editRequest.execute();
            final String editId = edit.getId();
            log.info(String.format("Created edit with id: %s", editId));

            // Update listing for US version of the application.
            final Listing newUsListing = new Listing();
            newUsListing.setTitle(US_LISTING_TITLE)
                    .setFullDescription(US_LISTING_FULL_DESCRIPTION)
                    .setShortDescription(US_LISTING_SHORT_DESCRITPION)
                    .setVideo(LISTINGS_PROMO_VIDEO);

            Update updateUSListingsRequest = edits
                    .listings()
                    .update(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            Locale.US.toString(),
                            newUsListing);
            Listing updatedUsListing = updateUSListingsRequest.execute();
            log.info(String.format("Created new US app listing with title: %s",
                    updatedUsListing.getTitle()));

            // Create and update listing for UK version of the application.
            final Listing newUkListing = new Listing();
            newUkListing.setTitle(UK_LISTING_TITLE)
                    .setFullDescription(UK_LISTING_FULL_DESCRIPTION)
                    .setShortDescription(UK_LISTING_SHORT_DESCRITPION)
                    .setVideo(LISTINGS_PROMO_VIDEO);

            Update updateUkListingsRequest = edits
                    .listings()
                    .update(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            Locale.UK.toString(),
                            newUkListing);
            Listing updatedUkListing = updateUkListingsRequest.execute();
            log.info(String.format("Created new UK app listing with title: %s",
                    updatedUkListing.getTitle()));

            // Commit changes for edit.
            Commit commitRequest = edits.commit(ApplicationConfig.PACKAGE_NAME, editId);
            AppEdit appEdit = commitRequest.execute();
            log.info(String.format("App edit with id %s has been comitted", appEdit.getId()));

        } catch (IOException | GeneralSecurityException ex) {
            log.error("Exception was thrown while updating listing", ex);
View Full Code Here

                    "ApplicationConfig.PACKAGE_NAME cannot be null or empty!");

            // Create the API service.
            AndroidPublisher service = AndroidPublisherHelper.init(
                    ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL);
            final Edits edits = service.edits();

            // Create a new edit to make changes to your listing.
            Insert editRequest = edits
                    .insert(ApplicationConfig.PACKAGE_NAME,
                            null /** no content */);
            AppEdit edit = editRequest.execute();
            final String editId = edit.getId();
            log.info(String.format("Created edit with id: %s", editId));

            // Upload new apk to developer console
            final String apkPath = BasicUploadApk.class
                    .getResource(ApplicationConfig.APK_FILE_PATH)
                    .toURI().getPath();
            final AbstractInputStreamContent apkFile =
                    new FileContent(AndroidPublisherHelper.MIME_TYPE_APK, new File(apkPath));
            Upload uploadRequest = edits
                    .apks()
                    .upload(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            apkFile);
            Apk apk = uploadRequest.execute();
            log.info(String.format("Version code %d has been uploaded",
                    apk.getVersionCode()));

            // Assign apk to alpha track.
            List<Integer> apkVersionCodes = new ArrayList<>();
            apkVersionCodes.add(apk.getVersionCode());
            Update updateTrackRequest = edits
                    .tracks()
                    .update(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            TRACK_ALPHA,
                            new Track().setVersionCodes(apkVersionCodes));
            Track updatedTrack = updateTrackRequest.execute();
            log.info(String.format("Track %s has been updated.", updatedTrack.getTrack()));

            // Commit changes for edit.
            Commit commitRequest = edits.commit(ApplicationConfig.PACKAGE_NAME, editId);
            AppEdit appEdit = commitRequest.execute();
            log.info(String.format("App edit with id %s has been comitted", appEdit.getId()));

        } catch (IOException | URISyntaxException | GeneralSecurityException ex) {
            log.error("Excpetion was thrown while uploading apk to alpha track", ex);
View Full Code Here

                    "ApplicationConfig.PACKAGE_NAME cannot be null or empty!");

            // Create the API service.
            AndroidPublisher service = AndroidPublisherHelper.init(
                    ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL);
            final Edits edits = service.edits();

            // Create a new edit to make changes.
            Insert editRequest = edits
                    .insert(ApplicationConfig.PACKAGE_NAME,
                            null /** no content */);
            AppEdit edit = editRequest.execute();
            final String editId = edit.getId();
            log.info(String.format("Created edit with id: %s", editId));

            // Upload new apk to developer console
            final String apkPath = UploadApkWithListing.class
                    .getResource(ApplicationConfig.APK_FILE_PATH)
                    .toURI().getPath();
            final AbstractInputStreamContent apkFile =
                    new FileContent(AndroidPublisherHelper.MIME_TYPE_APK, new File(apkPath));
            Upload uploadRequest = edits
                    .apks()
                    .upload(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            apkFile);
            Apk apk = uploadRequest.execute();
            log.info(String.format("Version code %d has been uploaded",
                    apk.getVersionCode()));

            // Assign apk to beta track.
            List<Integer> apkVersionCodes = new ArrayList<>();
            apkVersionCodes.add(apk.getVersionCode());
            Update updateTrackRequest = edits
                    .tracks()
                    .update(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            TRACK_BETA,
                            new Track().setVersionCodes(apkVersionCodes));
            Track updatedTrack = updateTrackRequest.execute();
            log.info(String.format("Track %s has been updated.", updatedTrack.getTrack()));

            // Update recent changes field in apk listing.
            final ApkListing newApkListing = new ApkListing();
            newApkListing.setRecentChanges(APK_LISTING_RECENT_CHANGES_TEXT);

            Apklistings.Update
            updateRecentChangesRequest = edits
                    .apklistings()
                    .update(ApplicationConfig.PACKAGE_NAME,
                            editId,
                            apk.getVersionCode(),
                            Locale.US.toString(),
                            newApkListing);
            updateRecentChangesRequest.execute();
            log.info("Recent changes has been updated.");

            // Commit changes for edit.
            Commit commitRequest = edits.commit(ApplicationConfig.PACKAGE_NAME, editId);
            AppEdit appEdit = commitRequest.execute();
            log.info(String.format("App edit with id %s has been comitted", appEdit.getId()));

        } catch (IOException | URISyntaxException | GeneralSecurityException ex) {
            log.error(
View Full Code Here

      AndroidPublisher service = AndroidPublisherHelper.init(
          publisherExtension.getApplicationName(),
          publisherExtension.getServiceAccountEmail(),
          publisherExtension.getServiceAccountKeyFile()
      );
      final Edits edits = service.edits();

      // Create a new edit to make changes to your listing
      Insert editRequest = edits
          .insert(publisherExtension.getPackageName(), null /** no content */);
      AppEdit edit = editRequest.execute();
      final String editId = edit.getId();
      getLogger().info(String.format("Created edit with id: %s", editId));

      // Upload new apk to developer console
      final AbstractInputStreamContent apkFileContent =
          new FileContent(AndroidPublisherHelper.MIME_TYPE_APK,
              getReleaseApkFile(publisherExtension));
      Upload uploadRequest = edits
          .apks()
          .upload(publisherExtension.getPackageName(),
              editId,
              apkFileContent);
      Apk apk = uploadRequest.execute();
      getLogger().info(String.format("Version code %d has been uploaded",
          apk.getVersionCode()));

      // Assign apk to alpha track.
      List<Integer> apkVersionCodes = new ArrayList<Integer>();
      apkVersionCodes.add(apk.getVersionCode());
      Update updateTrackRequest = edits
          .tracks()
          .update(publisherExtension.getPackageName(),
              editId,
              publisherExtension.getTrack(),
              new Track().setVersionCodes(apkVersionCodes));
      Track updatedTrack = updateTrackRequest.execute();
      getLogger().info(String.format("Track %s has been updated", updatedTrack.getTrack()));

      // Commit changes for edit.
      Commit commitRequest = edits.commit(publisherExtension.getPackageName(), editId);
      AppEdit appEdit = commitRequest.execute();
      getLogger().info(String.format("App edit with id %s has been committed", appEdit.getId()));

    } catch (IOException e) {
      throw new InvalidUserDataException(
View Full Code Here

      AndroidPublisher service = AndroidPublisherHelper.init(
          publisherExtension.getApplicationName(),
          publisherExtension.getServiceAccountEmail(),
          publisherExtension.getServiceAccountKeyFile()
      );
      final Edits edits = service.edits();

      // Create a new edit to make changes to your listing
      Insert editRequest = edits
          .insert(publisherExtension.getPackageName(), null /** no content */);
      AppEdit edit = editRequest.execute();
      final String editId = edit.getId();
      getLogger().info(String.format("Created edit with id: %s", editId));

      // List all tracks
      Tracks.List list = edits.tracks().list(publisherExtension.getPackageName(), editId);
      List<Track> tracks = list.execute().getTracks();

      // Identify the source and destination tracks
      Track sourceTrack = null;
      Track destinationTrack = null;
      for (Track track : tracks) {
        if (track.getTrack().equals(publisherExtension.getTrack()))
          sourceTrack = track;
        else if (track.getTrack().equals(publisherExtension.getPromotionTrack()))
          destinationTrack = track;
      }

      // Error checking
      if (sourceTrack==null || destinationTrack==null) {
        throw new InvalidUserDataException(String.format(
            "Cannot find the %s or %s track on Google Play, invalid track name?",
            publisherExtension.getTrack(), publisherExtension.getPromotionTrack()
        ));
      }
      if (sourceTrack.getVersionCodes().size()==0) {
        throw new InvalidUserDataException(String.format(
            "Cannot find a valid APK version code for the %s track, does it have at least one APK already uploaded?",
            sourceTrack.getVersionCodes()
        ));
      }
      getLogger().info("Using source track {} with version codes {}",
          sourceTrack.getTrack(), sourceTrack.getVersionCodes());
      getLogger().info("Using destination track {} with version codes {}",
          destinationTrack.getTrack(), destinationTrack.getVersionCodes());

      // Find version code to promote, remove from source track and add to destination track
      Integer versionCode = Collections.max(sourceTrack.getVersionCodes());
      List<Integer> sourceVersionCodes = sourceTrack.getVersionCodes();
      sourceVersionCodes.remove(versionCode);
      sourceTrack.setVersionCodes(sourceVersionCodes);
      List<Integer> destinationVersionCodes = new ArrayList<Integer>();
      destinationVersionCodes.add(versionCode);
      destinationTrack.setVersionCodes(destinationVersionCodes);
      getLogger().info("Promoting version code {}", versionCode);

      Update sourceUpdateRequest = edits
          .tracks()
          .update(publisherExtension.getPackageName(),
              editId,
              sourceTrack.getTrack(), sourceTrack);
      sourceUpdateRequest.execute();
      getLogger().info(String.format("Source track %s has been updated", sourceTrack.getTrack()));
      Update destinationUpdateRequest = edits
          .tracks()
          .update(publisherExtension.getPackageName(),
              editId,
              destinationTrack.getTrack(), destinationTrack);
      getLogger().info(String.format("Destination track %s has been updated",
          destinationTrack.getTrack()));
      destinationUpdateRequest.execute();

      // Commit changes for edit.
      Commit commitRequest = edits.commit(publisherExtension.getPackageName(), editId);
      AppEdit appEdit = commitRequest.execute();
      getLogger().info(String.format("App edit with id %s has been committed", appEdit.getId()));
      getLogger().lifecycle("Version code {} has been promoted from the {} to the {} track",
          versionCode, sourceTrack.getTrack(), destinationTrack.getTrack());
    } catch (IOException e) {
View Full Code Here

            Preconditions.checkArgument(!Strings.isNullOrEmpty(packageName),
                    "ApplicationConfig.PACKAGE_NAME cannot be null or empty!");

            // Create the API service.
            AndroidPublisher service = AndroidPublisherHelper.init(applicationName, secretFile, authStore);
            final Edits edits = service.edits();

            // Create a new edit to make changes to your listing.
            Insert editRequest = edits
                    .insert(packageName,
                            null /** no content */);
            AppEdit edit = editRequest.execute();
            final String editId = edit.getId();
            log.info(String.format("Created edit with id: %s", editId));

            // Upload new apk to developer console
            final AbstractInputStreamContent apkFile =
                    new FileContent(AndroidPublisherHelper.MIME_TYPE_APK, apkFiles);
            Upload uploadRequest = edits
                    .apks()
                    .upload(packageName,
                            editId,
                            apkFile);
            Apk apk = uploadRequest.execute();
            log.info(String.format("Version code %d has been uploaded",
                    apk.getVersionCode()));

            // Assign apk to alpha track.
            List<Integer> apkVersionCodes = new ArrayList<Integer>();
            apkVersionCodes.add(apk.getVersionCode());
            Update updateTrackRequest = edits
                    .tracks()
                    .update(packageName,
                            editId,
                            productType,
                            new Track().setVersionCodes(apkVersionCodes));
            Track updatedTrack = updateTrackRequest.execute();
            log.info(String.format("Track %s has been updated.", updatedTrack.getTrack()));

            // Commit changes for edit.
            Commit commitRequest = edits.commit(packageName, editId);
            AppEdit appEdit = commitRequest.execute();
            log.info(String.format("App edit with id %s has been comitted", appEdit.getId()));

        } catch (IOException ex) {
            log.error("Excpetion was thrown while uploading apk to production track", ex);
View Full Code Here

TOP

Related Classes of com.google.api.services.androidpublisher.AndroidPublisher.Edits

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.