chromium/chrome/browser/cart/cart_discount_fetcher.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/cart/cart_discount_fetcher.h"

#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/cart/cart_db.h"
#include "chrome/browser/cart/cart_discount_metric_collector.h"
#include "chrome/grit/generated_resources.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/proto/cart_db_content.pb.h"
#include "components/commerce/core/proto/coupon_db_content.pb.h"
#include "components/endpoint_fetcher/endpoint_fetcher.h"
#include "components/search/ntp_features.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/base/l10n/l10n_util.h"

namespace {
const char kPostMethod[] =;
const char kContentType[] =;
const char kAcceptLanguageKey[] =;
// The name string for the header for variations information.
const char kClientDataHeader[] =;

const char kFetchDiscountsEndpoint[] =;
constexpr base::TimeDelta kTimeout =;

const char kCartDiscountFetcherEndpointParam[] =;

constexpr base::FeatureParam<std::string> kDiscountFetcherServerConfigEndpoint{};

struct RuleDiscountInfo {};

struct CouponDiscountInfo {};

enum CouponType {};

// TODO(crbug.com/40181210): Consolidate to one util method to get string.
std::string GetMerchantUrl(const base::Value::Dict* merchant_identifier) {}

std::string GetMerchantId(const base::Value::Dict* merchant_identifier) {}

std::string GetStringFromDict(const base::Value* dict,
                              const std::string key,
                              bool is_required) {}

RuleDiscountInfo CovertToRuleDiscountInfo(
    const base::Value* rule_discount_list) {}

CouponType ConvertToCouponType(const base::Value* type) {}

bool IsCouponWithCode(CouponType type) {}

CouponDiscountInfo ConvertToCouponDiscountInfo(
    const base::Value* coupon_discount_list) {}

bool ValidateResponse(const std::optional<base::Value>& response) {}
}  // namespace

MerchantIdAndDiscounts::MerchantIdAndDiscounts(
    std::string merchant_id,
    std::vector<cart_db::RuleDiscountInfoProto> rule_discounts,
    std::vector<coupon_db::FreeListingCouponInfoProto> coupon_discounts,
    std::string discount_string,
    bool has_coupons)
    :{}

MerchantIdAndDiscounts::MerchantIdAndDiscounts(
    const MerchantIdAndDiscounts& other) = default;

MerchantIdAndDiscounts& MerchantIdAndDiscounts::operator=(
    const MerchantIdAndDiscounts& other) = default;

MerchantIdAndDiscounts::MerchantIdAndDiscounts(MerchantIdAndDiscounts&& other) =
    default;

MerchantIdAndDiscounts& MerchantIdAndDiscounts::operator=(
    MerchantIdAndDiscounts&& other) = default;

MerchantIdAndDiscounts::~MerchantIdAndDiscounts() = default;

std::unique_ptr<CartDiscountFetcher>
CartDiscountFetcherFactory::createFetcher() {}

CartDiscountFetcherFactory::~CartDiscountFetcherFactory() = default;

CartDiscountFetcher::~CartDiscountFetcher() = default;

void CartDiscountFetcher::Fetch(
    std::unique_ptr<network::PendingSharedURLLoaderFactory> pending_factory,
    CartDiscountFetcherCallback callback,
    std::vector<CartDB::KeyAndValue> proto_pairs,
    bool is_oauth_fetch,
    const std::string access_token,
    const std::string fetch_for_locale,
    const std::string variation_headers) {}

void CartDiscountFetcher::FetchForDiscounts(
    std::unique_ptr<network::PendingSharedURLLoaderFactory> pending_factory,
    CartDiscountFetcherCallback callback,
    std::vector<CartDB::KeyAndValue> proto_pairs,
    bool is_oauth_fetch,
    const std::string access_token,
    const std::string fetch_for_locale,
    const std::string variation_headers) {}

std::unique_ptr<EndpointFetcher> CartDiscountFetcher::CreateEndpointFetcher(
    std::unique_ptr<network::PendingSharedURLLoaderFactory> pending_factory,
    std::vector<CartDB::KeyAndValue> proto_pairs,
    bool is_oauth_fetch,
    const std::string fetch_for_locale,
    const std::string variation_headers) {}

std::string CartDiscountFetcher::generatePostData(
    std::vector<CartDB::KeyAndValue> proto_pairs,
    base::Time current_time) {}

void CartDiscountFetcher::OnDiscountsAvailable(
    std::unique_ptr<EndpointFetcher> endpoint_fetcher,
    CartDiscountFetcherCallback callback,
    std::unique_ptr<EndpointResponse> responses) {}