Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Added new models for results
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenedith committed Nov 12, 2015
1 parent aff090f commit 45d08b7
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 3 deletions.
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ module.exports = {
* @static
*/
amountResponse: require('./lib/model/response/amountResponse'),
/**
* the lotteryResultsCollectionResponse model and builder.
* @property lotteryResultsCollectionResponse
* @type lotteryResultsCollectionResponse
* @static
*/
lotteryResultsCollectionResponse: require('./lib/model/response/lotteryResultsCollectionResponse'),
/**
* the lotteryTicketsCollectionResponse model and builder.
* @property lotteryTicketsCollectionResponse
Expand All @@ -56,6 +63,27 @@ module.exports = {
* @static
*/
lotteryTradesCollectionResponse: require('./lib/model/response/lotteryTradesCollectionResponse'),
/**
* the resultPrizeResponse model and builder.
* @property resultPrizeResponse
* @type resultPrizeResponse
* @static
*/
resultPrizeResponse: require('./lib/model/response/resultPrizeResponse'),
/**
* the resultPrizeWinnerResponse model and builder.
* @property resultPrizeWinnerResponse
* @type resultPrizeWinnerResponse
* @static
*/
resultPrizeWinnerResponse: require('./lib/model/response/resultPrizeWinnerResponse'),
/**
* the resultResponse model and builder.
* @property resultResponse
* @type resultResponse
* @static
*/
resultResponse: require('./lib/model/response/resultResponse'),
/**
* the ticketResponse model and builder.
* @property ticketResponse
Expand Down
35 changes: 35 additions & 0 deletions lib/model/response/lotteryResultsCollectionResponse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var LotteryResultsCollectionResponse = function LotteryResultsCollectionResponse(total, results) {
this.total = total;
this.results = results;
};

var LotteryResultsCollectionResponseBuilder = function LotteryResultsCollectionResponseBuilder() {
this.total = null;
this.results = null;

var self = this;

this.withTotal = function withTotal(total) {
self.total = total;
return self;
};

this.withResults = function withResults(results) {
self.results = results;
return self;
};


this.build = function build() {
return new LotteryResultsCollectionResponse(
self.total,
self.results
);
};

};

module.exports = exports = {
LotteryResultsCollectionResponse: LotteryResultsCollectionResponse,
LotteryResultsCollectionResponseBuilder: LotteryResultsCollectionResponseBuilder
};
35 changes: 35 additions & 0 deletions lib/model/response/resultPrizeResponse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var ResultPrizeResponse = function ResultPrizeResponse(name, winners) {
this.name = name;
this.winners = winners;
};

var ResultPrizeResponseBuilder = function ResultPrizeResponseBuilder() {
this.name = null;
this.winners = null;

var self = this;

this.withName = function withName(name) {
self.name = name;
return self;
};

this.withWinners = function withWinners(winners) {
self.winners = winners;
return self;
};


this.build = function build() {
return new ResultPrizeResponse(
self.name,
self.winners
);
};

};

module.exports = exports = {
ResultPrizeResponse: ResultPrizeResponse,
ResultPrizeResponseBuilder: ResultPrizeResponseBuilder
};
27 changes: 27 additions & 0 deletions lib/model/response/resultPrizeWinnerResponse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var ResultPrizeWinnerResponse = function ResultPrizeWinnerResponse(code) {
this.code = code;
};

var ResultPrizeWinnerResponseBuilder = function ResultPrizeWinnerResponseBuilder() {
this.code = null;

var self = this;

this.withCode = function withCode(code) {
self.code = code;
return self;
};


this.build = function build() {
return new ResultPrizeWinnerResponse(
self.code
);
};

};

module.exports = exports = {
ResultPrizeWinnerResponse: ResultPrizeWinnerResponse,
ResultPrizeWinnerResponseBuilder: ResultPrizeWinnerResponseBuilder
};
51 changes: 51 additions & 0 deletions lib/model/response/resultResponse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
var ResultResponse = function ResultResponse(name, date, status, prizes) {
this.name = name;
this.date = date;
this.status = status;
this.prizes = prizes;
};

var ResultResponseBuilder = function ResultResponseBuilder() {
this.name = null;
this.date = null;
this.status = null;
this.prizes = null;

var self = this;

this.withName = function withName(name) {
self.name = name;
return self;
};

this.withDate = function withDate(date) {
self.date = date;
return self;
};

this.withStatus = function withStatus(status) {
self.status = status;
return self;
};

this.withPrizes = function withPrizes(prizes) {
self.prizes = prizes;
return self;
};


this.build = function build() {
return new ResultResponse(
self.name,
self.date,
self.status,
self.prizes
);
};

};

module.exports = exports = {
ResultResponse: ResultResponse,
ResultResponseBuilder: ResultResponseBuilder
};
97 changes: 94 additions & 3 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ tags:
description: Operation about lottery tickets
- name: trades
description: Operation about lottery trades
- name: results
description: Operation about lottery results
schemes:
- https
security:
Expand All @@ -27,7 +29,7 @@ paths:
- application/vnd.receipts.v1+xml
security:
- oauth2token:
- lotteries:tickets:get
- lotteries:trades:get
parameters:
- name: id
in: path
Expand All @@ -39,6 +41,30 @@ paths:
description: successful operation
schema:
$ref: "#/definitions/LotteryTradesCollectionResponse"
"/lotteries/{id}/results":
get:
tags:
- results
summary: Get lottery results
description: Get lottery results
operationId: getLotteryResultsCollection
produces:
- application/vnd.receipts.v1+json
- application/vnd.receipts.v1+xml
security:
- oauth2token:
- lotteries:results:get
parameters:
- name: id
in: path
description: Lottery id
required: true
type: string
responses:
"200":
description: successful operation
schema:
$ref: "#/definitions/LotteryResultsCollectionResponse"
"/lotteries/{id}/tickets":
get:
tags:
Expand Down Expand Up @@ -129,6 +155,8 @@ securityDefinitions:
public: public API scope
lotteries:tickets:get: permission to get lottery tickets
lotteries:tickets:create: permission to create lottery ticket
lotteries:trades:get: permission to get lottery trades
lotteries:results:get: permission to get lottery results

definitions:
AmountResponse:
Expand Down Expand Up @@ -226,9 +254,10 @@ definitions:
properties:
total:
type: integer
description: Total lottery tickets collection
description: Total lottery tickets
tickets:
type: array
description: Lottery tickets collection
items:
$ref: "#/definitions/TicketResponse"
description: Lottery tickets collection
Expand All @@ -251,12 +280,74 @@ definitions:
properties:
total:
type: integer
description: Total lottery tickets collection
description: Total lottery trades
trades:
type: array
description: Trades collection
items:
$ref: "#/definitions/TradeResponse"
description: Lottery trades collection
required:
- total
- trades
ResultPrizeWinnerResponse:
properties:
code:
type: string
description: Winner code
required:
- code
ResultPrizeResponse:
properties:
name:
type: string
description: Prize name
winners:
type: array
description: Prize winners
items:
$ref: "#/definitions/ResultPrizeWinnerResponse"
required:
- name
- winners
ResultResponse:
properties:
name:
type: string
description: Result name
date:
type: string
description: Result date
status:
type: string
description: Result status
default: ACTIVE
enum:
- ACTIVE
- PENDING
- FINISHED
prizes:
type: array
description: Result prizes
items:
$ref: "#/definitions/ResultPrizeResponse"
description: Lottery results data
required:
- name
- date
- status
- prizes
LotteryResultsCollectionResponse:
properties:
total:
type: integer
description: Total lottery results
results:
type: array
description: Lottery results collection
items:
$ref: "#/definitions/ResultResponse"
description: Lottery results collection
required:
- total
- results
28 changes: 28 additions & 0 deletions test/indexTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ describe('index test', function () {
done();
});

it('should export lotteryResultsCollectionResponse', function (done) {

var lotteryResultsCollectionResponse = index.model.lotteryResultsCollectionResponse;
should.exist(lotteryResultsCollectionResponse);
done();
});

it('should export lotteryTicketsCollectionResponse', function (done) {

var lotteryTicketsCollectionResponse = index.model.lotteryTicketsCollectionResponse;
Expand All @@ -130,6 +137,27 @@ describe('index test', function () {
done();
});

it('should export resultPrizeResponse', function (done) {

var resultPrizeResponse = index.model.resultPrizeResponse;
should.exist(resultPrizeResponse);
done();
});

it('should export resultPrizeWinnerResponse', function (done) {

var resultPrizeWinnerResponse = index.model.resultPrizeWinnerResponse;
should.exist(resultPrizeWinnerResponse);
done();
});

it('should export resultResponse', function (done) {

var resultResponse = index.model.resultResponse;
should.exist(resultResponse);
done();
});

it('should export ticketRequest', function (done) {

var ticketRequest = index.model.ticketRequest;
Expand Down
Loading

0 comments on commit 45d08b7

Please sign in to comment.