Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MortalSoft/mortalsoft-client-node

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Example Usage

Here's an example of how to use the MortalSoftClient module to interact with the MortalSoft API:

const MortalSoftClient = require('mortalsoft-client');

// Replace 'your_base_url' and 'your_token' with the actual values
const baseUrl = 'https://api-prod.mortalsoft.online';
const token = 'your_token';

const client = new MortalSoftClient(baseUrl, token);

(async () => {
  try {
    // List all games
    const games = await client.listGames();
    console.log('List of games:', games);

    // Get the balance for a user with the identifier 'user123'
    const identifier = 'user123';
    const balance = await client.getBalance(identifier);
    console.log('Balance for', identifier, ':', balance);

    // Change the balance for the user 'user123' to 500
    const newBalance = await client.changeBalance(identifier, 500);
    console.log('Updated balance for', identifier, ':', newBalance);

    // Create a new session for the user 'user123'
    const sessionToken = await client.createSession(identifier);
    console.log('Session token for', identifier, ':', sessionToken);
  } catch (error) {
    console.error('Error:', error.message);
  }
})();

API Reference

new MortalSoftClient(baseUrl, token)

Creates a new instance of the MortalSoftClient.

  • baseUrl (string): The base URL of the MortalSoft API.
  • token (string): The API token for authentication.

client.listGames(queryParams)

Retrieves the list of games from the MortalSoft API.

  • queryParams (object, optional): Query parameters to filter the games (e.g., { id: 1, name: 'Game Name' }).

Returns an array of games.

client.getBalance(identifier)

Retrieves the balance for a user with the given identifier.

  • identifier (string): The user identifier.

Returns the balance of the user.

client.changeBalance(identifier, amount)

Changes the balance for a user with the given identifier.

  • identifier (string): The user identifier.
  • amount (number): The new balance amount.

client.createSession(identifier)

Creates a new session for a user with the given identifier.

  • identifier (string): The user identifier.

Returns the session token.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.