// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_COMMERCE_CORE_SUBSCRIPTIONS_COMMERCE_SUBSCRIPTION_H_ #define COMPONENTS_COMMERCE_CORE_SUBSCRIPTIONS_COMMERCE_SUBSCRIPTION_H_ #include <stdint.h> #include <optional> #include <string> /** * To add a new SubscriptionType / IdentifierType / ManagementType: * 1. Define the type in the enum class in commerce_subscription.h. * 2. Update the conversion methods between the type and std::string in * commerce_subscription.cc. * 3. Add the corresponding entry in {@link * commerce_subscription_db_content.proto} to ensure the storage works * correctly. */ namespace commerce { // The type of subscription. // A Java counterpart will be generated for this enum. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.commerce.core enum class SubscriptionType { … }; // The type of subscription identifier. // A Java counterpart will be generated for this enum. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.commerce.core enum class IdentifierType { … }; // The type of subscription management. // A Java counterpart will be generated for this enum. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.commerce.core enum class ManagementType { … }; // The user seen offer data upon price tracking subscribing, used to improve the // price drop notification quality. struct UserSeenOffer { … }; extern const int64_t kUnknownSubscriptionTimestamp; extern const uint64_t kInvalidSubscriptionId; struct CommerceSubscription { … }; std::string SubscriptionTypeToString(SubscriptionType type); SubscriptionType StringToSubscriptionType(const std::string& s); std::string SubscriptionIdTypeToString(IdentifierType type); IdentifierType StringToSubscriptionIdType(const std::string& s); std::string SubscriptionManagementTypeToString(ManagementType type); ManagementType StringToSubscriptionManagementType(const std::string& s); // Gets a key for the provided subscription that can be used for storage or // caching. std::string GetStorageKeyForSubscription( const CommerceSubscription& subscription); } // namespace commerce #endif // COMPONENTS_COMMERCE_CORE_SUBSCRIPTIONS_COMMERCE_SUBSCRIPTION_H_