Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 668210a

Browse files
committed
Add contract_type to api returns
1 parent 2a1901e commit 668210a

File tree

5 files changed

+75
-17
lines changed

5 files changed

+75
-17
lines changed

api/restapi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ def parse_listings(listings):
238238
"origin": str(CountryCode.Name(l.origin)),
239239
"ships_to": []
240240
}
241+
if l.contract_type != 0:
242+
listing_json["contract_type"] = str(objects.Listings.ContractType.Name(l.contract_type))
241243
for country in l.ships_to:
242244
listing_json["ships_to"].append(str(CountryCode.Name(country)))
243245
response["listings"].append(listing_json)

api/ws.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ def handle_response(listings, node):
181181
"ships_to": []
182182
}
183183
}
184+
if l.contract_type != 0:
185+
listing_json["contract_type"] = str(Listings.ContractType.Name(l.contract_type))
184186
for country in l.ships_to:
185187
listing_json["listing"]["ships_to"].append(str(CountryCode.Name(country)))
186188
if not os.path.isfile(os.path.join( \

market/contracts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,12 @@ def save(self):
998998
self.contract["vendor_offer"]["listing"]["shipping"]["shipping_origin"].upper())
999999
for region in self.contract["vendor_offer"]["listing"]["shipping"]["shipping_regions"]:
10001000
data.ships_to.append(CountryCode.Value(region.upper()))
1001+
if self.contract["vendor_offer"]["listing"]["metadata"]["category"].lower() == "physical good":
1002+
data.contract_type = listings.PHYSICAL_GOOD
1003+
elif self.contract["vendor_offer"]["listing"]["metadata"]["category"].lower() == "digital good":
1004+
data.contract_type = listings.DIGITAL_GOOD
1005+
elif self.contract["vendor_offer"]["listing"]["metadata"]["category"].lower() == "service":
1006+
data.contract_type = listings.SERVICE
10011007

10021008
# save the mapping of the contract file path and contract hash in the database
10031009
self.db.filemap.insert(data.contract_hash.encode("hex"), file_path[len(DATA_FOLDER):])

protos/objects.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ message Listings {
120120
repeated CountryCode ships_to = 9;
121121
bytes avatar_hash = 10;
122122
string handle = 11;
123+
ContractType contract_type = 12;
124+
}
125+
126+
enum ContractType {
127+
NOT_SET = 0;
128+
PHYSICAL_GOOD = 1;
129+
DIGITAL_GOOD = 2;
130+
SERVICE = 3;
123131
}
124132
}
125133

protos/objects.py

Lines changed: 57 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)