Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Created constants file and added language codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barend committed Mar 13, 2017
1 parent 7cb4e1f commit 168d8d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
19 changes: 19 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
//Platforms
PC: 'http://api.paladins.com/paladinsapi.svc',

//Response formats.
JSON: 'Json',
XML: 'Xml',

//Language codes.
ENGLISH: '1',
GERMAN: '2',
FRENCH: '3',
SPANISH: '7',
SPANISHLA: '9',
PORTUGUESE: '10',
RUSSIAN: '11',
POLISH: '12',
TURKISH: '13'
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paladins-api",
"version": "1.1.4",
"version": "1.1.5",
"description": "Wrapper for the Paladins API",
"main": "paladins-api.js",
"scripts": {
Expand Down
15 changes: 6 additions & 9 deletions paladins-api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const request = require('request');
const moment = require('moment');
const md5 = require('md5');
const URL = 'http://api.paladins.com/paladinsapi.svc',
FORMAT = 'Json';

'use strict';
var request = require('request');
var moment = require('moment');
var md5 = require('md5');
var c = require('./constants');

module.exports = class API {

Expand Down Expand Up @@ -92,7 +89,7 @@ module.exports = class API {
}

connect(response) {
var builtUrl = URL + '/' + 'createsession' + FORMAT + '/' + this.devId + '/' + this.getSignature('createsession') + '/' + this.timeStamp();
var builtUrl = c.PC + '/' + 'createsession' + c.JSON + '/' + this.devId + '/' + this.getSignature('createsession') + '/' + this.timeStamp();
request(builtUrl, function(err, res, body) {
if(!err) {
var bodyParsed = JSON.parse(body);
Expand All @@ -102,7 +99,7 @@ module.exports = class API {
}

urlBuilder(session, method, player, lang, matchId) {
var baseURL = URL + '/' + method + FORMAT + '/' + this.devId + '/' +
var baseURL = c.PC + '/' + method + c.JSON + '/' + this.devId + '/' +
this.getSignature(method) + '/' + session + '/' + this.timeStamp();

if (player != null) {
Expand Down

0 comments on commit 168d8d3

Please sign in to comment.