コード例 #1
0
        /// <summary>
        /// Creates a new in-app product for an app.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/inappproducts/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app; for example, "com.spiffygame".</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>InAppProductResponse</returns>
        public static InAppProduct Insert(AndroidPublisherService service, string packageName, InAppProduct body, InappproductsInsertOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }

                // Building the initial request.
                var request = service.Inappproducts.Insert(body, packageName);

                // Applying optional parameters to the request.
                request = (InappproductsResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Inappproducts.Insert failed.", ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Cancels a user's subscription purchase. The subscription remains valid until its expiration time.
        /// Documentation https://developers.google.com/androidpublisher/v1.1/reference/purchases/cancel
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">The package name of the application for which this subscription was purchased (for example, 'com.some.thing').</param>
        /// <param name="subscriptionId">The purchased subscription ID (for example, 'monthly001').</param>
        /// <param name="token">The token provided to the user's device when the subscription was purchased.</param>
        public static void Cancel(AndroidPublisherService service, string packageName, string subscriptionId, string token)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (subscriptionId == null)
                {
                    throw new ArgumentNullException(subscriptionId);
                }
                if (token == null)
                {
                    throw new ArgumentNullException(token);
                }

                // Make the request.
                return(service.Purchases.Cancel(packageName, subscriptionId, token).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Purchases.Cancel failed.", ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Delete an in-app product for an app.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/inappproducts/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app with the in-app product; for example, "com.spiffygame".</param>
        /// <param name="sku">Unique identifier for the in-app product.</param>
        public static void Delete(AndroidPublisherService service, string packageName, string sku)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (sku == null)
                {
                    throw new ArgumentNullException(sku);
                }

                // Make the request.
                return(service.Inappproducts.Delete(packageName, sku).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Inappproducts.Delete failed.", ex);
            }
        }
コード例 #4
0
        /// <summary>
        /// Fetches the Expansion File configuration for the APK specified.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/expansionfiles/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="apkVersionCode">The version code of the APK whose Expansion File configuration is being read or modified.</param>
        /// <param name="expansionFileType">NA</param>
        /// <returns>ExpansionFileResponse</returns>
        public static ExpansionFile Get(AndroidPublisherService service, string packageName, string editId, int apkVersionCode, string expansionFileType)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (expansionFileType == null)
                {
                    throw new ArgumentNullException(expansionFileType);
                }

                // Make the request.
                return(service.Expansionfiles.Get(packageName, editId, apkVersionCode, expansionFileType).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Expansionfiles.Get failed.", ex);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: qingfeng346/stools
        static void ExecuteAndroidpublisher(string authFile, string packageName, Action <AndroidPublisherService, string> action, Action <TrackRelease> trackAction)
        {
            var service = new AndroidPublisherService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = GoogleCredential.FromFile(authFile).CreateScoped("https://www.googleapis.com/auth/androidpublisher"),
                ApplicationName       = packageName,
            });
            var editId = service.Edits.Insert(new AppEdit()
            {
                ExpiryTimeSeconds = "3600"
            }, packageName).Execute().Id;

            action(service, editId);
            var trackInfo = service.Edits.Tracks.Get(packageName, editId, "internal").Execute();
            var release   = trackInfo.Releases.SingleOrDefault(release => release?.Status == "draft", null);

            if (release == null)
            {
                release = new TrackRelease()
                {
                    Status = "draft"
                };
                trackInfo.Releases.Add(release);
            }
            trackAction(release);
            service.Edits.Tracks.Update(trackInfo, packageName, editId, "internal").Execute();
            var commit = service.Edits.Commit(packageName, editId);

            commit.ChangesNotSentForReview = false;
            commit.Execute();
        }
コード例 #6
0
        /// <summary>
        /// Lists the purchases that were cancelled, refunded or charged-back.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/voidedpurchases/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">The package name of the application for which voided purchases need to be returned (for example, 'com.some.thing').</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>VoidedPurchasesListResponseResponse</returns>
        public static VoidedPurchasesListResponse List(AndroidPublisherService service, string packageName, VoidedpurchasesListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }

                // Building the initial request.
                var request = service.Voidedpurchases.List(packageName);

                // Applying optional parameters to the request.
                request = (VoidedpurchasesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Voidedpurchases.List failed.", ex);
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a single review.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/reviews/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".</param>
        /// <param name="reviewId">NA</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ReviewResponse</returns>
        public static Review Get(AndroidPublisherService service, string packageName, string reviewId, ReviewsGetOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (reviewId == null)
                {
                    throw new ArgumentNullException(reviewId);
                }

                // Building the initial request.
                var request = service.Reviews.Get(packageName, reviewId);

                // Applying optional parameters to the request.
                request = (ReviewsResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Reviews.Get failed.", ex);
            }
        }
コード例 #8
0
        /// <summary>
        /// Lists all the track configurations for this edit.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/tracks/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <returns>TracksListResponseResponse</returns>
        public static TracksListResponse List(AndroidPublisherService service, string packageName, string editId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }

                // Make the request.
                return(service.Tracks.List(packageName, editId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Tracks.List failed.", ex);
            }
        }
コード例 #9
0
        private async UniTask UploadArtifact(AndroidPublisherService androidPublisherService,
                                             IAndroidDistributionSettings configs, AppEdit appEdit)
        {
            var isAppBundle = configs.IsAppBundle;
            var uploader    = isAppBundle
                ? new AndroidAppBundlerUploader()
                : new AndroidApkUploader() as IAndroidArtifactUploader;

            Debug.Log($"{nameof(PlayStorePublisher)} : Upload to store With {uploader.GetType().Name}");

            // Upload new apk to developer console
            var upload = uploader.Upload(configs, androidPublisherService, appEdit);

            upload.UploadAsync();

            var uploadProgress = upload.GetProgress();

            while (uploadProgress == null || (uploadProgress.Status != UploadStatus.Completed && uploadProgress.Status != UploadStatus.Failed))
            {
                uploadProgress = upload.GetProgress();
                if (uploadProgress != null)
                {
                    OnUploadProgressChanged(uploadProgress);
                }

                Thread.Sleep(UploadAwaitTimeout);
            }

            switch (uploadProgress)
            {
            case { Status: UploadStatus.Completed } :
コード例 #10
0
        /// <summary>
        /// Checks the purchase and consumption status of an inapp item.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/products/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">The package name of the application the inapp product was sold in (for example, 'com.some.thing').</param>
        /// <param name="productId">The inapp product SKU (for example, 'com.some.thing.inapp1').</param>
        /// <param name="token">The token provided to the user's device when the inapp product was purchased.</param>
        /// <returns>ProductPurchaseResponse</returns>
        public static ProductPurchase Get(AndroidPublisherService service, string packageName, string productId, string token)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (productId == null)
                {
                    throw new ArgumentNullException(productId);
                }
                if (token == null)
                {
                    throw new ArgumentNullException(token);
                }

                // Make the request.
                return(service.Products.Get(packageName, productId, token).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Products.Get failed.", ex);
            }
        }
コード例 #11
0
        private static async Task <int?> UploadApplicationFileAsync(string editId, AndroidPublisherService service, string packageName, string applicationFile)
        {
            if (applicationFile.EndsWith(".apk"))
            {
                await service.Edits.Apks.Upload(packageName, editId, new FileStream(applicationFile, FileMode.Open), "application/vnd.android.package-archive").UploadAsync().ConfigureAwait(false);

                var apks = await service.Edits.Apks.List(packageName, editId).ExecuteAsync().ConfigureAwait(false);

                return(apks.Apks.Last().VersionCode);
            }

            if (applicationFile.EndsWith(".aab"))
            {
                var uploadProgress = await service.Edits.Bundles.Upload(packageName, editId, new FileStream(applicationFile, FileMode.Open), "application/octet-stream").UploadAsync().ConfigureAwait(false);

                if (uploadProgress.Status != UploadStatus.Completed)
                {
                    Console.WriteLine(uploadProgress.Exception.Message);

                    Environment.Exit(1);
                }

                var bundles = await service.Edits.Bundles.List(packageName, editId).ExecuteAsync().ConfigureAwait(false);

                return(bundles.Bundles.Last().VersionCode);
            }

            throw new ArgumentOutOfRangeException(nameof(applicationFile));
        }
コード例 #12
0
        /// <summary>
        /// NA
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/testers/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="track">NA</param>
        /// <returns>TestersResponse</returns>
        public static Testers Get(AndroidPublisherService service, string packageName, string editId, string track)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (track == null)
                {
                    throw new ArgumentNullException(track);
                }

                // Make the request.
                return(service.Testers.Get(packageName, editId, track).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Testers.Get failed.", ex);
            }
        }
コード例 #13
0
        /// <summary>
        /// Updates app details for this edit. This method supports patch semantics.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/details/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <returns>AppDetailsResponse</returns>
        public static AppDetails Patch(AndroidPublisherService service, string packageName, string editId, AppDetails body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }

                // Make the request.
                return(service.Details.Patch(body, packageName, editId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Details.Patch failed.", ex);
            }
        }
コード例 #14
0
        /// <summary>
        /// Reply to a single review, or update an existing reply.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/reviews/reply
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame".</param>
        /// <param name="reviewId">NA</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <returns>ReviewsReplyResponseResponse</returns>
        public static ReviewsReplyResponse Reply(AndroidPublisherService service, string packageName, string reviewId, ReviewsReplyRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (reviewId == null)
                {
                    throw new ArgumentNullException(reviewId);
                }

                // Make the request.
                return(service.Reviews.Reply(body, packageName, reviewId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Reviews.Reply failed.", ex);
            }
        }
コード例 #15
0
        /// <summary>
        /// Defers a user's subscription purchase until a specified future expiration time.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/subscriptions/defer
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">The package name of the application for which this subscription was purchased (for example, 'com.some.thing').</param>
        /// <param name="subscriptionId">The purchased subscription ID (for example, 'monthly001').</param>
        /// <param name="token">The token provided to the user's device when the subscription was purchased.</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <returns>SubscriptionPurchasesDeferResponseResponse</returns>
        public static SubscriptionPurchasesDeferResponse Defer(AndroidPublisherService service, string packageName, string subscriptionId, string token, SubscriptionPurchasesDeferRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (subscriptionId == null)
                {
                    throw new ArgumentNullException(subscriptionId);
                }
                if (token == null)
                {
                    throw new ArgumentNullException(token);
                }

                // Make the request.
                return(service.Subscriptions.Defer(body, packageName, subscriptionId, token).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Subscriptions.Defer failed.", ex);
            }
        }
コード例 #16
0
        /// <summary>
        /// Creates a new APK without uploading the APK itself to Google Play, instead hosting the APK at a specified URL. This function is only available to enterprises using Google Play for Work whose application is configured to restrict distribution to the enterprise domain.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/apks/addexternallyhosted
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <returns>ApksAddExternallyHostedResponseResponse</returns>
        public static ApksAddExternallyHostedResponse Addexternallyhosted(AndroidPublisherService service, string packageName, string editId, ApksAddExternallyHostedRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }

                // Make the request.
                return(service.Apks.Addexternallyhosted(body, packageName, editId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Apks.Addexternallyhosted failed.", ex);
            }
        }
コード例 #17
0
        /// <summary>
        /// Creates or updates a localized store listing.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/listings/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="language">The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT".</param>
        /// <param name="body">A valid AndroidPublisher v2 body.</param>
        /// <returns>ListingResponse</returns>
        public static Listing Update(AndroidPublisherService service, string packageName, string editId, string language, Listing body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (language == null)
                {
                    throw new ArgumentNullException(language);
                }

                // Make the request.
                return(service.Listings.Update(body, packageName, editId, language).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Listings.Update failed.", ex);
            }
        }
コード例 #18
0
        /// <summary>
        /// Uploads a new image and adds it to the list of images for the specified language and image type.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/images/upload
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="language">The language code (a BCP-47 language tag) of the localized listing whose images are to read or modified. For example, to select Austrian German, pass "de-AT".</param>
        /// <param name="imageType">NA</param>
        /// <returns>ImagesUploadResponseResponse</returns>
        public static ImagesUploadResponse Upload(AndroidPublisherService service, string packageName, string editId, string language, string imageType)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (language == null)
                {
                    throw new ArgumentNullException(language);
                }
                if (imageType == null)
                {
                    throw new ArgumentNullException(imageType);
                }

                // Make the request.
                return(service.Images.Upload(packageName, editId, language, imageType).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Images.Upload failed.", ex);
            }
        }
コード例 #19
0
        /// <summary>
        /// Uploads the deobfuscation file of the specified APK. If a deobfuscation file already exists, it will be replaced.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/deobfuscationfiles/upload
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier of the Android app for which the deobfuscatiuon files are being uploaded; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="apkVersionCode">The version code of the APK whose deobfuscation file is being uploaded.</param>
        /// <param name="deobfuscationFileType">NA</param>
        /// <returns>DeobfuscationFilesUploadResponseResponse</returns>
        public static DeobfuscationFilesUploadResponse Upload(AndroidPublisherService service, string packageName, string editId, int apkVersionCode, string deobfuscationFileType)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (deobfuscationFileType == null)
                {
                    throw new ArgumentNullException(deobfuscationFileType);
                }

                // Make the request.
                return(service.Deobfuscationfiles.Upload(packageName, editId, apkVersionCode, deobfuscationFileType).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deobfuscationfiles.Upload failed.", ex);
            }
        }
コード例 #20
0
        /// <summary>
        /// Deletes all localized listings from an edit.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/listings/deleteall
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        public static void Deleteall(AndroidPublisherService service, string packageName, string editId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }

                // Make the request.
                return(service.Listings.Deleteall(packageName, editId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Listings.Deleteall failed.", ex);
            }
        }
コード例 #21
0
        /// <summary>
        /// Deletes the APK-specific localized listing for a specified APK and language code.
        /// Documentation https://developers.google.com/androidpublisher/v2/reference/apklistings/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidPublisher service.</param>
        /// <param name="packageName">Unique identifier for the Android app that is being updated; for example, "com.spiffygame".</param>
        /// <param name="editId">Unique identifier for this edit.</param>
        /// <param name="apkVersionCode">The APK version code whose APK-specific listings should be read or modified.</param>
        /// <param name="language">The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT".</param>
        public static void Delete(AndroidPublisherService service, string packageName, string editId, int apkVersionCode, string language)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (packageName == null)
                {
                    throw new ArgumentNullException(packageName);
                }
                if (editId == null)
                {
                    throw new ArgumentNullException(editId);
                }
                if (language == null)
                {
                    throw new ArgumentNullException(language);
                }

                // Make the request.
                return(service.Apklistings.Delete(packageName, editId, apkVersionCode, language).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Apklistings.Delete failed.", ex);
            }
        }
コード例 #22
0
 public void Dispose()
 {
     if (_androidPublisherService != null)
     {
         _androidPublisherService.Dispose();
         _androidPublisherService = null;
     }
 }
コード例 #23
0
        private static Track LoadTrackBranch(AndroidPublisherService androidPublisherService, BundleSettings configs,
                                             AppEdit edit)
        {
            var track = androidPublisherService.Edits.Tracks.Get(configs.PackageName, edit.Id, configs.TrackBranch)
                        .Execute();

            Console.WriteLine($"Load TrackBranch:{track.TrackValue}");
            return(track);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: wade1990/mobile-1
        private async Task Run()
        {
            GoogleCredential creds;

            using (var stream = new FileStream(_credsFilePath, FileMode.Open))
            {
                creds = GoogleCredential.FromStream(stream).CreateScoped(
                    AndroidPublisherService.Scope.Androidpublisher);
            }

            var service = new AndroidPublisherService(new BaseClientService.Initializer
            {
                HttpClientInitializer = creds
            });

            var editRequest = service.Edits.Insert(null, Package);
            var edit        = await editRequest.ExecuteAsync();

            Console.WriteLine("Created edit with id {0}.", edit.Id);

            Apk apk = null;

            using (var stream = new FileStream(_apkFilePath, FileMode.Open))
            {
                var uploadMedia = service.Edits.Apks.Upload(Package, edit.Id, stream,
                                                            "application/vnd.android.package-archive");

                var progress = await uploadMedia.UploadAsync();

                if (progress.Status == Google.Apis.Upload.UploadStatus.Completed)
                {
                    apk = uploadMedia.ResponseBody;
                }
                else
                {
                    throw new Exception("Upload failed.");
                }
            }

            Console.WriteLine("Version code {0} has been uploaded.", apk.VersionCode);

            var trackRequest = service.Edits.Tracks.Update(new Track
            {
                VersionCodes = new List <int?> {
                    apk.VersionCode
                }
            }, Package, edit.Id, _track);

            var updatedTrack = await trackRequest.ExecuteAsync();

            Console.WriteLine("Track {0} has been updated.", updatedTrack.TrackValue);

            var commitRequest = service.Edits.Commit(Package, edit.Id);
            var commitEdit    = await commitRequest.ExecuteAsync();

            Console.WriteLine("App edit with id {0} has been comitted.", commitEdit.Id);
        }
コード例 #25
0
        private static void CommitChangesToGooglePlay(AndroidPublisherService androidPublisherService,
                                                      BundleSettings configs,
                                                      AppEdit edit)
        {
            var commitRequest = androidPublisherService.Edits.Commit(configs.PackageName, edit.Id);
            var appEdit       = commitRequest.Execute();

            Console.WriteLine("App edit with id " + appEdit.Id + " has been comitted");
        }
コード例 #26
0
        public override async Task Execute(MessageData data)
        {
            var    args = data.GetAs <Arguments>();
            string serviceAccountEmail = "*****@*****.**";

            var certificate = new X509Certificate2(@"keyfile.p12", "notasecret", X509KeyStorageFlags.Exportable);

            ServiceAccountCredential credential = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = new[] { "https://www.googleapis.com/auth/androidpublisher" }
            }.FromCertificate(certificate));



            var service = new AndroidPublisherService(
                new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "GooglePlay API Sample",
            });
            // try catch this function because if you input wrong params ( wrong token) google will return error.
            //var request = service.Inappproducts.List("de.flou.hypixel.skyblock");
            var request = service.Purchases.Products.Get(
                args.PackageName,
                args.ProductId,
                args.Token);

            try
            {
                Console.WriteLine($"Purchasing Product with id: {args.ProductId}");
                var purchaseState = await request.ExecuteAsync();

                //get purchase'status


                Console.WriteLine(JsonConvert.SerializeObject(purchaseState));

                if (((long)purchaseState.PurchaseTimeMillis / 1000).ThisIsNowATimeStamp() < DateTime.Now - TimeSpan.FromDays(7))
                {
                    throw new CoflnetException("purchase_expired", "This purchase is older than a week and thus expired");
                }

                var days = int.Parse(args.ProductId.Split('_')[1]);
                UserService.Instance.SavePurchase(data.User, days, purchaseState.OrderId);
            }
            catch (Exception e)
            {
                Logger.Instance.Error("Purchase failure " + e.Message);
                throw new CoflnetException("purchase_failed", "Purchase failed, please contact the admin");
            }



            await data.SendBack(data.Create("accepted", "payment was accepted enjoy your premium", A_WEEK));
        }
コード例 #27
0
        public static Track LoadTrackBranch(
            this AndroidPublisherService androidPublisherService,
            IAndroidDistributionSettings configs,
            AppEdit edit)
        {
            var track = androidPublisherService.Edits.Tracks.Get(configs.PackageName, edit.Id, configs.TrackBranch)
                        .Execute();

            Debug.Log($"Load TrackBranch:{track.TrackValue}");
            return(track);
        }
コード例 #28
0
        public Google(
            AndroidPublisherService googleService,
            IVerificationRepository verificationRepository,
            IConfiguration configuration)
        {
            _googleService          = googleService;
            _verificationRepository = verificationRepository;

            _graceDays = int.TryParse(configuration["GraceDays"], out var val)
                ? val : 0;
        }
コード例 #29
0
        private static AppEdit CreateAnEditObject(AndroidPublisherService androidPublisherService,
                                                  BundleSettings configs)
        {
            var edit = androidPublisherService.Edits
                       .Insert(null /** no content */, configs.PackageName)
                       .Execute();

            Console.WriteLine("Created edit with id: " +
                              edit.Id +
                              " (valid for " + edit.ExpiryTimeSeconds + " seconds)");
            return(edit);
        }
コード例 #30
0
        private AppEdit CreateAppEdit(
            AndroidPublisherService androidPublisherService,
            IAndroidDistributionSettings configs)
        {
            var edit = androidPublisherService.Edits
                       .Insert(null /** no content */, configs.PackageName)
                       .Execute();

            Debug.Log("Created edit with id: " +
                      edit.Id +
                      " (valid for " + edit.ExpiryTimeSeconds + " seconds)");
            return(edit);
        }