2021-06-17 10:34:23 +12:00
|
|
|
from PyQt5.QtCore import QObject
|
|
|
|
|
|
|
|
|
|
|
|
# Class to use QObject.tr()
|
|
|
|
class Constants(QObject):
|
|
|
|
def __init__(self):
|
|
|
|
super(Constants, self).__init__()
|
2021-12-24 22:09:50 +13:00
|
|
|
self.categories = sorted(
|
|
|
|
[
|
|
|
|
(self.tr("Action"), "1216"),
|
|
|
|
(self.tr("Adventure"), "1117"),
|
|
|
|
(self.tr("Puzzle"), "1298"),
|
|
|
|
(self.tr("Open world"), "1307"),
|
|
|
|
(self.tr("Racing"), "1212"),
|
|
|
|
(self.tr("RPG"), "1367"),
|
|
|
|
(self.tr("Shooter"), "1210"),
|
|
|
|
(self.tr("Strategy"), "1115"),
|
|
|
|
(self.tr("Survival"), "1080"),
|
|
|
|
(self.tr("First Person"), "1294"),
|
|
|
|
(self.tr("Indie"), "1263"),
|
|
|
|
(self.tr("Simulation"), "1393"),
|
|
|
|
(self.tr("Sport"), "1283"),
|
|
|
|
],
|
|
|
|
key=lambda x: x[0],
|
|
|
|
)
|
2021-06-17 10:34:23 +12:00
|
|
|
|
|
|
|
self.platforms = [
|
|
|
|
("MacOS", "9548"),
|
|
|
|
("Windows", "9547"),
|
|
|
|
]
|
|
|
|
self.others = [
|
|
|
|
(self.tr("Single player"), "1370"),
|
|
|
|
(self.tr("Multiplayer"), "1203"),
|
|
|
|
(self.tr("Controller"), "9549"),
|
|
|
|
(self.tr("Co-op"), "1264"),
|
|
|
|
]
|
|
|
|
|
|
|
|
self.types = [
|
|
|
|
(self.tr("Editor"), "editors"),
|
|
|
|
(self.tr("Game"), "games/edition/base"),
|
|
|
|
(self.tr("Bundle"), "bundles/games"),
|
|
|
|
(self.tr("Add-on"), "addons"),
|
2021-12-24 22:09:50 +13:00
|
|
|
(self.tr("Apps"), "software/edition/base"),
|
2021-06-17 10:34:23 +12:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
__Image = '''
|
|
|
|
type
|
|
|
|
url
|
|
|
|
alt
|
|
|
|
'''
|
|
|
|
|
|
|
|
__StorePageMapping = '''
|
|
|
|
cmsSlug
|
|
|
|
offerId
|
|
|
|
prePurchaseOfferId
|
|
|
|
'''
|
|
|
|
|
|
|
|
__PageSandboxModel = '''
|
|
|
|
pageSlug
|
|
|
|
pageType
|
|
|
|
productId
|
|
|
|
sandboxId
|
|
|
|
createdDate
|
|
|
|
updatedDate
|
|
|
|
deletedDate
|
|
|
|
mappings {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
''' % (__StorePageMapping)
|
|
|
|
|
|
|
|
__CatalogNamespace = '''
|
|
|
|
parent
|
|
|
|
displayName
|
|
|
|
store
|
|
|
|
home: mappings(pageType: "productHome") {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
addons: mappings(pageType: "addon--cms-hybrid") {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
offers: mappings(pageType: "offer") {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
''' % (__PageSandboxModel, __PageSandboxModel, __PageSandboxModel)
|
|
|
|
|
|
|
|
__CatalogItem = '''
|
|
|
|
id
|
|
|
|
namespace
|
|
|
|
'''
|
|
|
|
|
|
|
|
__GetPriceRes = '''
|
|
|
|
totalPrice {
|
|
|
|
discountPrice
|
|
|
|
originalPrice
|
|
|
|
voucherDiscount
|
|
|
|
discount
|
|
|
|
currencyCode
|
|
|
|
currencyInfo {
|
|
|
|
decimals
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
fmtPrice(locale: $locale) {
|
|
|
|
originalPrice
|
|
|
|
discountPrice
|
|
|
|
intermediatePrice
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lineOffers {
|
|
|
|
appliedRules {
|
|
|
|
id
|
|
|
|
endDate
|
|
|
|
discountSetting {
|
|
|
|
discountType
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
'''
|
|
|
|
|
|
|
|
__Promotions = '''
|
|
|
|
promotionalOffers {
|
|
|
|
promotionalOffers {
|
|
|
|
startDate
|
|
|
|
endDate
|
|
|
|
discountSetting {
|
|
|
|
discountType
|
|
|
|
discountPercentage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
upcomingPromotionalOffers {
|
|
|
|
promotionalOffers {
|
|
|
|
startDate
|
|
|
|
endDate
|
|
|
|
discountSetting {
|
|
|
|
discountType
|
|
|
|
discountPercentage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
|
|
|
|
__CatalogOffer = '''
|
|
|
|
title
|
|
|
|
id
|
|
|
|
namespace
|
|
|
|
offerType
|
|
|
|
expiryDate
|
|
|
|
status
|
|
|
|
isCodeRedemptionOnly
|
|
|
|
description
|
|
|
|
effectiveDate
|
|
|
|
keyImages {
|
|
|
|
%(image)s
|
|
|
|
}
|
|
|
|
currentPrice
|
|
|
|
seller {
|
|
|
|
id
|
|
|
|
name
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
productSlug
|
|
|
|
urlSlug
|
|
|
|
url
|
|
|
|
tags {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
groupName
|
|
|
|
}
|
|
|
|
items {
|
|
|
|
%(catalog_item)s
|
|
|
|
}
|
|
|
|
customAttributes {
|
|
|
|
key
|
|
|
|
value
|
|
|
|
}
|
|
|
|
categories {
|
|
|
|
path
|
|
|
|
}
|
|
|
|
catalogNs @include(if: $withMapping) {
|
|
|
|
%(catalog_namespace)s
|
|
|
|
}
|
|
|
|
offerMappings @include(if: $withMapping) {
|
|
|
|
%(page_sandbox_model)s
|
|
|
|
}
|
|
|
|
price(country: $country) @include(if: $withPrice) {
|
|
|
|
%(get_price_res)s
|
|
|
|
}
|
|
|
|
promotions(category: $category) @include(if: $withPromotions) {
|
|
|
|
%(promotions)s
|
|
|
|
}
|
|
|
|
''' % {
|
|
|
|
"image": __Image,
|
|
|
|
"catalog_item": __CatalogItem,
|
|
|
|
"catalog_namespace": __CatalogNamespace,
|
|
|
|
"page_sandbox_model": __PageSandboxModel,
|
|
|
|
"get_price_res": __GetPriceRes,
|
|
|
|
"promotions": __Promotions,
|
|
|
|
}
|
|
|
|
|
|
|
|
__Pagination = '''
|
|
|
|
count
|
|
|
|
total
|
|
|
|
'''
|
2021-08-08 09:42:40 +12:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
SEARCH_STORE_QUERY = '''
|
|
|
|
query searchStoreQuery(
|
|
|
|
$allowCountries: String
|
|
|
|
$category: String
|
|
|
|
$count: Int
|
|
|
|
$country: String!
|
|
|
|
$keywords: String
|
|
|
|
$locale: String
|
|
|
|
$namespace: String
|
|
|
|
$withMapping: Boolean = false
|
|
|
|
$itemNs: String
|
|
|
|
$sortBy: String
|
|
|
|
$sortDir: String
|
|
|
|
$start: Int
|
|
|
|
$tag: String
|
|
|
|
$releaseDate: String
|
|
|
|
$withPrice: Boolean = false
|
|
|
|
$withPromotions: Boolean = false
|
|
|
|
$priceRange: String
|
|
|
|
$freeGame: Boolean
|
|
|
|
$onSale: Boolean
|
|
|
|
$effectiveDate: String
|
|
|
|
) {
|
2023-01-30 12:56:29 +13:00
|
|
|
Catalog {
|
|
|
|
searchStore(
|
|
|
|
allowCountries: $allowCountries
|
|
|
|
category: $category
|
|
|
|
count: $count
|
|
|
|
country: $country
|
|
|
|
keywords: $keywords
|
|
|
|
locale: $locale
|
|
|
|
namespace: $namespace
|
|
|
|
itemNs: $itemNs
|
|
|
|
sortBy: $sortBy
|
|
|
|
sortDir: $sortDir
|
|
|
|
releaseDate: $releaseDate
|
|
|
|
start: $start
|
|
|
|
tag: $tag
|
|
|
|
priceRange: $priceRange
|
|
|
|
freeGame: $freeGame
|
|
|
|
onSale: $onSale
|
|
|
|
effectiveDate: $effectiveDate
|
|
|
|
) {
|
|
|
|
elements {
|
2023-04-10 23:03:45 +12:00
|
|
|
%s
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
|
|
|
paging {
|
2023-04-10 23:03:45 +12:00
|
|
|
%s
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
''' % (__CatalogOffer, __Pagination)
|
|
|
|
|
|
|
|
__WISHLIST_ITEM = '''
|
|
|
|
id
|
|
|
|
order
|
|
|
|
created
|
|
|
|
offerId
|
|
|
|
updated
|
|
|
|
namespace
|
|
|
|
isFirstTime
|
|
|
|
offer(locale: $locale) {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
''' % __CatalogOffer
|
2021-08-19 08:17:14 +12:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
WISHLIST_QUERY = '''
|
|
|
|
query wishlistQuery(
|
|
|
|
$country: String!
|
|
|
|
$locale: String
|
|
|
|
$category: String
|
|
|
|
$withMapping: Boolean = false
|
|
|
|
$withPrice: Boolean = false
|
|
|
|
$withPromotions: Boolean = false
|
|
|
|
) {
|
2023-01-30 12:56:29 +13:00
|
|
|
Wishlist {
|
|
|
|
wishlistItems {
|
|
|
|
elements {
|
2023-04-10 23:03:45 +12:00
|
|
|
%s
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
''' % __WISHLIST_ITEM
|
2023-01-30 12:56:29 +13:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
WISHLIST_ADD_QUERY = '''
|
|
|
|
mutation addWishlistMutation(
|
|
|
|
$namespace: String!
|
|
|
|
$offerId: String!
|
|
|
|
$country: String!
|
|
|
|
$locale: String
|
|
|
|
$category: String
|
|
|
|
$withMapping: Boolean = false
|
|
|
|
$withPrice: Boolean = false
|
|
|
|
$withPromotions: Boolean = false
|
|
|
|
) {
|
|
|
|
Wishlist {
|
|
|
|
addToWishlist(
|
|
|
|
namespace: $namespace
|
|
|
|
offerId: $offerId
|
|
|
|
) {
|
|
|
|
wishlistItem {
|
|
|
|
%s
|
|
|
|
}
|
|
|
|
success
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
''' % __WISHLIST_ITEM
|
2023-01-30 12:56:29 +13:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
WISHLIST_REMOVE_QUERY = '''
|
|
|
|
mutation removeFromWishlistMutation(
|
|
|
|
$namespace: String!
|
|
|
|
$offerId: String!
|
|
|
|
$operation: RemoveOperation!
|
|
|
|
) {
|
|
|
|
Wishlist {
|
|
|
|
removeFromWishlist(
|
|
|
|
namespace: $namespace
|
|
|
|
offerId: $offerId
|
|
|
|
operation: $operation
|
|
|
|
) {
|
|
|
|
success
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
'''
|
2023-01-30 12:56:29 +13:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
COUPONS_QUERY = '''
|
|
|
|
query getCoupons(
|
|
|
|
$currencyCountry: String!
|
|
|
|
$identityId: String!
|
|
|
|
$locale: String
|
|
|
|
) {
|
|
|
|
CodeRedemption {
|
|
|
|
coupons(
|
|
|
|
currencyCountry: $currencyCountry
|
|
|
|
identityId: $identityId
|
|
|
|
includeSalesEventInfo: true
|
|
|
|
) {
|
|
|
|
code
|
|
|
|
codeStatus
|
|
|
|
codeType
|
|
|
|
consumptionMetadata {
|
|
|
|
amountDisplay {
|
|
|
|
amount
|
|
|
|
currency
|
|
|
|
placement
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
minSalesPriceDisplay {
|
|
|
|
amount
|
|
|
|
currency
|
|
|
|
placement
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endDate
|
|
|
|
namespace
|
|
|
|
salesEvent(locale: $locale) {
|
|
|
|
eventName
|
|
|
|
eventSlug
|
|
|
|
voucherImages {
|
|
|
|
type
|
|
|
|
url
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
voucherLink
|
|
|
|
}
|
|
|
|
startDate
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
'''
|
2023-01-30 12:56:29 +13:00
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
STORE_CONFIG_QUERY = '''
|
|
|
|
query getStoreConfig(
|
|
|
|
$includeCriticReviews: Boolean = false
|
|
|
|
$locale: String!
|
|
|
|
$sandboxId: String!
|
|
|
|
$templateId: String
|
|
|
|
) {
|
|
|
|
Product {
|
|
|
|
sandbox(sandboxId: $sandboxId) {
|
|
|
|
configuration(locale: $locale, templateId: $templateId) {
|
|
|
|
... on StoreConfiguration {
|
|
|
|
configs {
|
|
|
|
shortDescription
|
|
|
|
criticReviews @include(if: $includeCriticReviews) {
|
|
|
|
openCritic
|
|
|
|
}
|
|
|
|
socialLinks {
|
|
|
|
platform
|
|
|
|
url
|
|
|
|
}
|
|
|
|
supportedAudio
|
|
|
|
supportedText
|
|
|
|
tags(locale: $locale) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
groupName
|
|
|
|
}
|
|
|
|
technicalRequirements {
|
|
|
|
macos {
|
|
|
|
minimum
|
|
|
|
recommended
|
|
|
|
title
|
|
|
|
}
|
|
|
|
windows {
|
|
|
|
minimum
|
|
|
|
recommended
|
|
|
|
title
|
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
... on HomeConfiguration {
|
|
|
|
configs {
|
|
|
|
keyImages {
|
|
|
|
... on KeyImage {
|
|
|
|
type
|
|
|
|
url
|
|
|
|
alt
|
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
longDescription
|
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
}
|
2023-01-30 12:56:29 +13:00
|
|
|
}
|
2023-04-10 23:03:45 +12:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
def compress_query(query: str) -> str:
|
|
|
|
return query.replace(" ", "").replace("\n", " ")
|
|
|
|
|
|
|
|
|
|
|
|
game_query = compress_query(SEARCH_STORE_QUERY)
|
|
|
|
search_query = compress_query(SEARCH_STORE_QUERY)
|
|
|
|
wishlist_query = compress_query(WISHLIST_QUERY)
|
|
|
|
wishlist_add_query = compress_query(WISHLIST_ADD_QUERY)
|
|
|
|
wishlist_remove_query = compress_query(WISHLIST_REMOVE_QUERY)
|
|
|
|
coupons_query = compress_query(COUPONS_QUERY)
|
|
|
|
store_config_query = compress_query(STORE_CONFIG_QUERY)
|
2023-01-30 12:56:29 +13:00
|
|
|
|
|
|
|
|
2023-04-10 23:03:45 +12:00
|
|
|
if __name__ == "__main__":
|
|
|
|
print(SEARCH_STORE_QUERY)
|