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

Parse version 2 of the ad catalog #3980

Merged
merged 3 commits into from
Nov 14, 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
4 changes: 4 additions & 0 deletions vendor/bat-native-ads/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ source_set("ads") {
"src/bat/ads/internal/catalog_creative_set_info.h",
"src/bat/ads/internal/catalog_geo_target_info.cc",
"src/bat/ads/internal/catalog_geo_target_info.h",
"src/bat/ads/internal/catalog_day_part_info.cc",
"src/bat/ads/internal/catalog_day_part_info.h",
"src/bat/ads/internal/catalog_payload_info.cc",
"src/bat/ads/internal/catalog_payload_info.h",
"src/bat/ads/internal/catalog_segment_info.cc",
"src/bat/ads/internal/catalog_segment_info.h",
"src/bat/ads/internal/catalog_os_info.cc",
"src/bat/ads/internal/catalog_os_info.h",
"src/bat/ads/internal/catalog_state.cc",
"src/bat/ads/internal/catalog_state.h",
"src/bat/ads/internal/catalog_type_info.cc",
Expand Down
83 changes: 71 additions & 12 deletions vendor/bat-native-ads/resources/catalog-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@
"type": "object",
"additionalProperties": false,
"required": [
"priority",
"campaignId",
"advertiserId",
"name",
"startAt",
"endAt",
"dailyCap",
"budget",
"geoTargets",
"dayParts",
"creativeSets"
],
"properties": {
"campaignId": {
"type": "string"
},
"advertiserId": {
"type": "string"
"priority": {
"type": "number"
},
"name": {
"advertiserId": {
"type": "string"
},
"startAt": {
Expand All @@ -73,8 +73,28 @@
"dailyCap": {
"type": "number"
},
"budget": {
"type": "number"
"dayParts": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"dow",
"startMinute",
"endMinute"
],
"properties": {
"dow": {
"type": "string"
},
"startMinute": {
"type": "number"
},
"endMinute": {
"type": "number"
}
}
}
},
"geoTargets": {
"type": "array",
Expand Down Expand Up @@ -102,25 +122,45 @@
"additionalProperties": false,
"required": [
"creativeSetId",
"execution",
"perDay",
"totalMax",
"segments",
"creatives"
"creatives",
"oses"
],
"properties": {
"creativeSetId": {
"type": "string"
},
"execution": {
"type": "string"
},
"perDay": {
"type": "number"
},
"totalMax": {
"type": "number"
},
"conversions": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"urlPattern",
"type",
"observationWindow"
],
"properties": {
"urlPattern": {
"type": "string"
},
"type": {
"type": "string"
},
"observationWindow": {
"type": "number"
}
}
}
},
"segments": {
"type": "array",
"items": {
Expand All @@ -143,6 +183,25 @@
}
}
},
"oses": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"code",
"name"
],
"properties": {
"code": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"creatives": {
"type": "array",
"items": {
Expand Down
6 changes: 3 additions & 3 deletions vendor/bat-native-ads/src/bat/ads/internal/campaign_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ namespace ads {

CampaignInfo::CampaignInfo() :
campaign_id(""),
priority(0),
name(""),
start_at(""),
end_at(""),
daily_cap(0),
budget(0),
advertiser_id(""),
geo_targets({}),
creative_sets({}) {}

CampaignInfo::CampaignInfo(const std::string& campaign_id) :
campaign_id(campaign_id),
priority(0),
name(""),
start_at(""),
end_at(""),
daily_cap(0),
budget(0),
advertiser_id(""),
geo_targets({}),
creative_sets({}) {}

CampaignInfo::CampaignInfo(const CampaignInfo& info) :
campaign_id(info.campaign_id),
priority(info.priority),
name(info.name),
start_at(info.start_at),
end_at(info.end_at),
daily_cap(info.daily_cap),
budget(info.budget),
advertiser_id(info.advertiser_id),
geo_targets(info.geo_targets),
creative_sets(info.creative_sets) {}
Expand Down
4 changes: 3 additions & 1 deletion vendor/bat-native-ads/src/bat/ads/internal/campaign_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "bat/ads/internal/catalog_geo_target_info.h"
#include "bat/ads/internal/catalog_day_part_info.h"
#include "bat/ads/internal/catalog_creative_set_info.h"

namespace ads {
Expand All @@ -21,13 +22,14 @@ struct CampaignInfo {
~CampaignInfo();

std::string campaign_id;
unsigned int priority;
std::string name;
std::string start_at;
std::string end_at;
unsigned int daily_cap;
unsigned int budget;
std::string advertiser_id;
std::vector<GeoTargetInfo> geo_targets;
std::vector<DayPartInfo> day_parts;
std::vector<CreativeSetInfo> creative_sets;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ namespace ads {

CreativeSetInfo::CreativeSetInfo() :
creative_set_id(""),
execution(""),
per_day(0),
total_max(0),
segments({}),
oses({}),
creatives({}) {}

CreativeSetInfo::CreativeSetInfo(const std::string& creative_set_id) :
creative_set_id(creative_set_id),
execution(""),
per_day(0),
total_max(0),
segments({}),
oses({}),
creatives({}) {}

CreativeSetInfo::CreativeSetInfo(const CreativeSetInfo& info) :
creative_set_id(info.creative_set_id),
execution(info.execution),
per_day(info.per_day),
total_max(info.total_max),
segments(info.segments),
oses(info.oses),
creatives(info.creatives) {}

CreativeSetInfo::~CreativeSetInfo() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "bat/ads/internal/catalog_segment_info.h"
#include "bat/ads/internal/catalog_os_info.h"
#include "bat/ads/internal/catalog_creative_info.h"

namespace ads {
Expand All @@ -21,10 +22,10 @@ struct CreativeSetInfo {
~CreativeSetInfo();

std::string creative_set_id;
std::string execution;
unsigned int per_day;
unsigned int total_max;
std::vector<SegmentInfo> segments;
std::vector<OsInfo> oses;
std::vector<CreativeInfo> creatives;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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 "bat/ads/internal/catalog_day_part_info.h"

namespace ads {

DayPartInfo::DayPartInfo() :
dow(""),
startMinute(0),
endMinute(0) {}

DayPartInfo::DayPartInfo(const DayPartInfo& info) :
dow(info.dow),
startMinute(info.startMinute),
endMinute(info.endMinute) {}

DayPartInfo::~DayPartInfo() {}

} // namespace ads
25 changes: 25 additions & 0 deletions vendor/bat-native-ads/src/bat/ads/internal/catalog_day_part_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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 BAT_ADS_INTERNAL_CATALOG_DAY_PART_INFO_H_
#define BAT_ADS_INTERNAL_CATALOG_DAY_PART_INFO_H_

#include <string>

namespace ads {

struct DayPartInfo {
DayPartInfo();
DayPartInfo(const DayPartInfo& info);
~DayPartInfo();

std::string dow;
unsigned int startMinute;
unsigned int endMinute;
};

} // namespace ads

#endif // BAT_ADS_INTERNAL_CATALOG_DAY_PART_INFO_H_
20 changes: 20 additions & 0 deletions vendor/bat-native-ads/src/bat/ads/internal/catalog_os_info.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* 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 "bat/ads/internal/catalog_os_info.h"

namespace ads {

OsInfo::OsInfo() :
code(""),
name("") {}

OsInfo::OsInfo(const OsInfo& info) :
code(info.code),
name(info.name) {}

OsInfo::~OsInfo() {}

} // namespace ads
24 changes: 24 additions & 0 deletions vendor/bat-native-ads/src/bat/ads/internal/catalog_os_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* 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 BAT_ADS_INTERNAL_CATALOG_OS_INFO_H_
#define BAT_ADS_INTERNAL_CATALOG_OS_INFO_H_

#include <string>

namespace ads {

struct OsInfo {
OsInfo();
OsInfo(const OsInfo& info);
~OsInfo();

std::string code;
std::string name;
};

} // namespace ads

#endif // BAT_ADS_INTERNAL_CATALOG_OS_INFO_H_
Loading