1.1.23 • Published 2 months ago

cnr-client v1.1.23

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

Codenrock gaming SDK

Installation

Run in console npm i --save cnr-client or add the package "cnr-client": "1.1.0" in package.json file.

The stable version of the package is ^1.1.0

Init the game

Import the package

import CompetitionClient from 'cnr-client'

and create a game instance

The apiEndpoint parameter is https://codenrock.com by default, contestId parameter will be given to you by Codenrock.

Sign up with email

To register in the platform you have to use signUpWithEmail method:

If there will be any errors during authorization, the SIGN_UP_FAILED error will be thrown.

Sign in with email

To login in the platform you have to use signInWithEmail method:

If there will be any errors during authorization, the SIGN_IN_FAILED error will be thrown.

OAuth2

There are two properties in the game instance: signInGoogleUrl and signInFacebookUrl.

To sign in using OAuth2, you have to redirect user to selected social.

<a :href="game.signInGoogleUrl">Sign in with Google</a>

or

<a :href="game.signInFacebookUrl">Sign in with Facebook</a>

After passing social authorization steps, you will be redirected on the main page of the game (window.location.origin) with token parameter in query string.

Example:

You have to set this token to the game and clear query string.

Profile

Since user is authorized, you can always get its profile by user property

If the user object is null (for example, after OAuth2 authorization), you can ask it using the getProfile method.

Init game

Starting the game, you have to make its initialization. Initialization process is required before getting any private data from the competition

Available methods

MethodSuccessErrorDescription
signUpWithEmail()SignUpErrorSign up the system with email, returns validation errors if something wrong
signInWithEmail()SignInErrorSign in the system with email, returns validation errors if something wrong
getProfile()IUser403Get user profile
getContest()ContestGet contest info
getForm()IFormResponse403Get user form questions
sendForm(data: IAnswerRequest)IFormAnswerResponseValidationFailedAnswer the form
getNominations()Nomination[]403Get the list of the task categories
getNomination(nominationId: number)Nomination403Get category item by ID
getRandomNomination()Nomination403Get random category
getTasks(nominationId: number)Task[]403Get tasks from the category
getRandomTask(nominationId: number)Task403Get random task from the category
getTask(nominationId: number, taskId: number)Task403Get task from the category by ID
answer(nominationId: number, taskId: number, data: any)ISolutionResponse422Answer the task
getLeaderboard(page: number = 1, search: string = "")IRatingResponse403Get contest leaderboard (summary leaderboard)
getMyGlobalScore()IMyScoreResponse403Get the user score in contest
getWheelTries()IWheelSpins403only for wheel - get spins information
setToken(token: string)Set Auth token
logout()Logout the system

Available properties

PropertyTypeDescription
signInGoogleUrlstringThe URL to sign in with Google
signInFacebookUrlstringThe URL to sign in with Facebook
authorizedbooleanDetermines if the user is login
userUserAuth user instance

Types

User

Contest

Form

IQuestion

AnswerRequest

Answer

Nomination

Task

SolutionResponse

Solution

IRatingResponse

IRatingPosition

IMyScoreResponse

IWheelSpins

1.1.23

2 months ago

1.1.19

2 months ago

1.1.18

2 months ago

1.1.22

2 months ago

1.1.21

2 months ago

1.1.20

2 months ago

1.1.16

2 months ago

1.1.15

2 months ago

1.1.14

2 months ago

1.1.17

2 months ago

1.1.12

8 months ago

1.1.13

8 months ago

1.1.9

11 months ago

1.1.11

11 months ago

1.1.10

11 months ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.1

1 year ago

1.1.0

2 years ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.22

2 years ago

1.0.11

2 years ago

1.0.21

2 years ago

1.0.10

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago