Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored and migrated Rewards category from category to type #3630

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions browser/ui/webui/brave_rewards_page_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class RewardsDOMHandler : public WebUIMessageHandler,
unsigned int result,
const std::string& viewing_id,
const std::string& probi,
const int32_t category) override;
const int32_t type) override;
void OnPendingContributionSaved(
brave_rewards::RewardsService* rewards_service,
int result) override;
Expand All @@ -225,7 +225,7 @@ class RewardsDOMHandler : public WebUIMessageHandler,
void OnContributionSaved(
brave_rewards::RewardsService* rewards_service,
bool success,
int category) override;
int type) override;

void OnPendingContributionRemoved(
brave_rewards::RewardsService* rewards_service,
Expand Down Expand Up @@ -948,11 +948,11 @@ void RewardsDOMHandler::OnReconcileComplete(
unsigned int result,
const std::string& viewing_id,
const std::string& probi,
const int32_t category) {
const int32_t type) {
if (web_ui()->CanCallJavascript()) {
base::DictionaryValue complete;
complete.SetKey("result", base::Value(static_cast<int>(result)));
complete.SetKey("category", base::Value(category));
complete.SetKey("type", base::Value(type));

web_ui()->CallJavascriptFunctionUnsafe("brave_rewards.reconcileComplete",
complete);
Expand Down Expand Up @@ -1403,14 +1403,14 @@ void RewardsDOMHandler::OnRecurringTipRemoved(
void RewardsDOMHandler::OnContributionSaved(
brave_rewards::RewardsService* rewards_service,
bool success,
int category) {
int type) {
if (!web_ui()->CanCallJavascript()) {
return;
}

base::DictionaryValue result;
result.SetBoolean("success", success);
result.SetInteger("category", category);
result.SetInteger("type", type);

web_ui()->CallJavascriptFunctionUnsafe(
"brave_rewards.onContributionSaved", result);
Expand Down Expand Up @@ -1454,7 +1454,7 @@ void RewardsDOMHandler::OnGetPendingContributions(
contribution->SetKey("amount", base::Value(item.amount));
contribution->SetKey("addedDate",
base::Value(std::to_string(item.added_date)));
contribution->SetKey("category", base::Value(item.category));
contribution->SetKey("type", base::Value(item.type));
contribution->SetKey("viewingId", base::Value(item.viewing_id));
contribution->SetKey("expirationDate",
base::Value(std::to_string(item.expiration_date)));
Expand Down
4 changes: 2 additions & 2 deletions common/extensions/api/brave_rewards.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@
"type": "integer",
"description": "result for this contribution"
},
"category": {
"type": {
"type": "integer",
"description": "category of this contribution"
"description": "type of this contribution"
}
}
}
Expand Down
32 changes: 17 additions & 15 deletions components/brave_rewards/browser/contribution_info.cc
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/components/brave_rewards/browser/contribution_info.h"

namespace brave_rewards {

ContributionInfo::ContributionInfo() :
date(0) {
}
ContributionInfo::ContributionInfo() :
date(0) {
}

ContributionInfo::~ContributionInfo() { }
ContributionInfo::~ContributionInfo() = default;

ContributionInfo::ContributionInfo(const ContributionInfo &data) {
probi = data.probi;
month = data.month;
year = data.year;
category = data.category;
date = data.date;
publisher_key = data.publisher_key;
}
ContributionInfo::ContributionInfo(const ContributionInfo& data) {
probi = data.probi;
month = data.month;
year = data.year;
type = data.type;
date = data.date;
publisher_key = data.publisher_key;
}

} // namespace brave_rewards
36 changes: 19 additions & 17 deletions components/brave_rewards/browser/contribution_info.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_PAYMENTS_CONTRIBUTION_INFO_
#define BRAVE_BROWSER_PAYMENTS_CONTRIBUTION_INFO_
#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_
#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_

#include <string>

namespace brave_rewards {
struct ContributionInfo {
ContributionInfo();
~ContributionInfo();
ContributionInfo(const ContributionInfo& properties);

std::string probi;
int month;
int year;
int category;
uint32_t date = 0;
std::string publisher_key;
};
struct ContributionInfo {
ContributionInfo();
~ContributionInfo();
ContributionInfo(const ContributionInfo& properties);

std::string probi;
int month;
int year;
int type;
uint32_t date = 0;
std::string publisher_key;
};

} // namespace brave_rewards

#endif //BRAVE_BROWSER_PAYMENTS_CONTRIBUTION_INFO_
#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_
Loading