Skip to content

Commit

Permalink
Merge pull request #50 from LearningProcesss/49-querying-plays-fails-…
Browse files Browse the repository at this point in the history
…silently-for-some-users

feat: add comments property to BggPlaysPlayDto
  • Loading branch information
LearningProcesss committed Aug 8, 2023
2 parents 7bfcc94 + e9ead0d commit 09d3b00
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
8 changes: 8 additions & 0 deletions buildtest/cjs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ describe('BggClient', () => {

const validationResult = ValidatorTraverse(dtoList[0], reflectionProperties, reflectionPropertiesExcludable)

expect(validationResult).toStrictEqual([])
}, 70000);
it('should parse Play dto when xml response is valid with comments', async () => {

const dtoList = await client.play.query({ username: 'Vitho' })

const validationResult = ValidatorTraverse(dtoList[0], reflectionProperties, reflectionPropertiesExcludable)

expect(validationResult).toStrictEqual([])
}, 70000);
});
Expand Down
8 changes: 8 additions & 0 deletions buildtest/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ describe('BggClient', () => {

const validationResult = ValidatorTraverse(dtoList[0], reflectionProperties, reflectionPropertiesExcludable)

expect(validationResult).toStrictEqual([])
}, 70000);
it('should parse Play dto when xml response is valid with comments', async () => {

const dtoList = await client.play.query({ username: 'Vitho' })

const validationResult = ValidatorTraverse(dtoList[0], reflectionProperties, reflectionPropertiesExcludable)

expect(validationResult).toStrictEqual([])
}, 70000);
});
Expand Down
4 changes: 4 additions & 0 deletions rest.http
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ GET https://www.boardgamegeek.com/xmlapi2/collection?username=Vitho HTTP/1.1

GET https://www.boardgamegeek.com/xmlapi2/plays?username=mattiabanned HTTP/1.1

### plays with comme

GET https://www.boardgamegeek.com/xmlapi2/plays?username=Vitho HTTP/1.1

### thread

GET https://www.boardgamegeek.com/xmlapi2/thread?id=1082079 HTTP/1.1
Expand Down
4 changes: 4 additions & 0 deletions src/dto/concrete/subdto/BggPlaySubDtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class BggPlaysPlayDto {
})
item!: BggPlaysPlayItemDto;

@JsonProperty()
@JsonClassType({ type: () => [String] })
comments!: string;

@JsonProperty()
@JsonClassType({ type: () => [BggPlaysPlayItemDto] })
@JsonAlias({ values: ["players"] })
Expand Down
3 changes: 2 additions & 1 deletion src/dto/dtoparser/concrete/BggPlaysDtoParser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { JsonParser } from "jackson-js";
import { JsonParser, ObjectMapper } from "jackson-js";
import { BggPlayDto } from "../../concrete";
import { IDtoParser } from "../interface";

export class BggPlayDtoParser implements IDtoParser<BggPlayDto> {
parser: JsonParser<BggPlayDto>;
mapper: ObjectMapper;
constructor() {
this.parser = new JsonParser<BggPlayDto>();
}
Expand Down
25 changes: 15 additions & 10 deletions test/unit/__fixtures__/response_play.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<plays username="mattiabanned" userid="1236367" total="1" page="1" termsofuse="https://boardgamegeek.com/xmlapi/termsofuse">
<play id="57445284" date="2017-12-03" quantity="1" length="180" incomplete="0" nowinstats="0" location="">
<item name="Mistfall" objecttype="thing" objectid="168274">
<subtypes>
<subtype value="boardgame" />
<subtype value="boardgameimplementation" />
<subtype value="boardgameintegration" />
</subtypes>
</item>
</play>
</plays>
<play id="57445284" date="2017-12-03" quantity="1" length="180" incomplete="0" nowinstats="0" location="Italy">
<item name="Mistfall" objecttype="thing" objectid="168274">
<subtypes>
<subtype value="boardgame" />
<subtype value="boardgameimplementation" />
<subtype value="boardgameintegration" />
</subtypes>
</item>
<comments>this is the first comment line
this is the second comment line</comments>
<players>
<player username="fake" userid="159073" name="fake" startposition="positionFake" color="blue" score="1" new="1" rating="1" win="1" />
</players>
</play>
</plays>
2 changes: 1 addition & 1 deletion test/unit/utils/reflection/reflectionexport.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[["BggArticleDto",["id","username","body","subject","numedits","editdate","postdate","link"]],["BggCollectionDto",["id","totalitems","pubdate","items"]],["BggFamilyDto",["name","description","thumbnail","image","id","type","things"]],["BggForumDto",["id","lastpostdate","noposting","numthreads","numposts","title","threads"]],["BggForumThreadDto",["id","numarticles","subject","author","postdate","lastpostdate"]],["BggForumlistDto",["id","type","forums"]],["BggForumlistForumDto",["id","groupid","lastpostdate","noposting","numthreads","numposts","title","description"]],["BggGuildDto",["id","name","created","category","website","manager","description","members"]],["BggGuildMemberDto",["name","date"]],["BggGuildMemeberDto",["name","date"]],["BggHotDto",["id","rank","thumbnail","name","yearpublished"]],["BggPlayDto",["id","userid","total","page","username","plays"]],["BggSearchDto",["id","total","items"]],["BggThingDto",["id","name","type","description","thumbnail","image","yearpublished","minplayers","maxplayers","playingtime","minplaytime","maxplaytime","minage","links","statistics","videos","comments","marketplacelistings","polls","versions"]],["BggThreadDto",[]],["BggUserDto",["id","name","firstname","lastname","avatarlink","yearregistered","lastlogin","stateorprovince","country","webaddress","xboxaccount","wiiaccount","psnaccount","battlenetaccount","steamaccount","traderating"]],["index",[]],["BggStatisticsPaginatedDto",["page","ratings"]],["BggStatisticsRatingDto",["average","usersrated","bayesaverage","stddev","median","owned","trading","wanting","wishing","numcomments","numweights","averageweight","ranks"]],["BggStatisticsRatingRanksDto",["type","id","name","friendlyname","value","bayesaverage"]],["BggThingCommentDto",["value","username","rating"]],["BggThingCommentPaginatedDto",["page","totalitems","items"]],["BggThingVideoDto",["category","language","link","postdate","title","username","id","userid"]],["BggThingVideoPaginatedDto",["total","items"]],["BggCollectionItemDto",[]],["BggCollectionItemStatsDto",["rating","usersrated","average","bayesaverage","stddev","median","ranks"]],["BggCollectionItemStatusDto",["own","prevowned","fortrade","want","wanttoplay","wanttobuy","wishlist","wishlistpriority","preordered","lastmodified"]],["BggLinkDto",["id","type","value","inbound"]],["BggPlaySubDtos",["id","userid","date","quantity","length","incomplete","nowinstats","location","item","players"]],["BggPlaysPlayItemDto",["name","objecttype","objectid","subtypes"]],["BggPlaysPlayItemSubtypes",["value"]],["BggPlaysPlayPlayerDto",["color","name","new","rating","score","startposition","userid","username","win"]],["BggPollDto",["name","title","totalvotes","results"]],["BggPollResultDto",["numplayers","resultItemList"]],["BggPollResultItemDto",["level","value","numvotes"]],["BggSearchItemDto",["id","type","name","yearpublished"]],["BggThingMarketlistingsDto",["condition","link","listdate","notes","price"]],["BggThingVersionDto",["type","id","thumbnail","image","links","name","yearpublished","productcode","width","length","depth","weight"]]]
[["BggArticleDto",["id","username","body","subject","numedits","editdate","postdate","link"]],["BggCollectionDto",["id","totalitems","pubdate","items"]],["BggFamilyDto",["name","description","thumbnail","image","id","type","things"]],["BggForumDto",["id","lastpostdate","noposting","numthreads","numposts","title","threads"]],["BggForumThreadDto",["id","numarticles","subject","author","postdate","lastpostdate"]],["BggForumlistDto",["id","type","forums"]],["BggForumlistForumDto",["id","groupid","lastpostdate","noposting","numthreads","numposts","title","description"]],["BggGuildDto",["id","name","created","category","website","manager","description","members"]],["BggGuildMemberDto",["name","date"]],["BggGuildMemeberDto",["name","date"]],["BggHotDto",["id","rank","thumbnail","name","yearpublished"]],["BggPlayDto",["id","userid","total","page","username","plays"]],["BggSearchDto",["id","total","items"]],["BggThingDto",["id","name","type","description","thumbnail","image","yearpublished","minplayers","maxplayers","playingtime","minplaytime","maxplaytime","minage","links","statistics","videos","comments","marketplacelistings","polls","versions"]],["BggThreadDto",[]],["BggUserDto",["id","name","firstname","lastname","avatarlink","yearregistered","lastlogin","stateorprovince","country","webaddress","xboxaccount","wiiaccount","psnaccount","battlenetaccount","steamaccount","traderating"]],["index",[]],["BggStatisticsPaginatedDto",["page","ratings"]],["BggStatisticsRatingDto",["average","usersrated","bayesaverage","stddev","median","owned","trading","wanting","wishing","numcomments","numweights","averageweight","ranks"]],["BggStatisticsRatingRanksDto",["type","id","name","friendlyname","value","bayesaverage"]],["BggThingCommentDto",["value","username","rating"]],["BggThingCommentPaginatedDto",["page","totalitems","items"]],["BggThingVideoDto",["category","language","link","postdate","title","username","id","userid"]],["BggThingVideoPaginatedDto",["total","items"]],["BggCollectionItemDto",[]],["BggCollectionItemStatsDto",["rating","usersrated","average","bayesaverage","stddev","median","ranks"]],["BggCollectionItemStatusDto",["own","prevowned","fortrade","want","wanttoplay","wanttobuy","wishlist","wishlistpriority","preordered","lastmodified"]],["BggLinkDto",["id","type","value","inbound"]],["BggPlaySubDtos",["id","userid","date","quantity","length","incomplete","nowinstats","location","item","comments","players"]],["BggPlaysPlayItemDto",["name","objecttype","objectid","subtypes"]],["BggPlaysPlayItemSubtypes",["value"]],["BggPlaysPlayPlayerDto",["color","name","new","rating","score","startposition","userid","username","win"]],["BggPollDto",["name","title","totalvotes","results"]],["BggPollResultDto",["numplayers","resultItemList"]],["BggPollResultItemDto",["level","value","numvotes"]],["BggSearchItemDto",["id","type","name","yearpublished"]],["BggThingMarketlistingsDto",["condition","link","listdate","notes","price"]],["BggThingVersionDto",["type","id","thumbnail","image","links","name","yearpublished","productcode","width","length","depth","weight"]]]

0 comments on commit 09d3b00

Please sign in to comment.