Biblioteki SDK Dla Kalkulatora Kodów Do Radia

Biblioteki programistyczne SDK dla PHP, Python, JavaScript, C#, Rust, Go, Java, PowerShell i Ruby kalkulatora kodów odblokowujących radioodtwarzacze w samochodach.

Opis

Aby skorzystać ze wszystkich funkcji Kalkulatora Kodów Do Radia API, użyj gotowych pakietów SDK dla swojego języka programowania.

Usługa Web API bazuje na prostym zapytaniu POST i odpowiedzi zakodowanej w postaci JSON.

Instalacja

W celu szybszego wdrożenia, paczki instalacyjne interfejsu Web API zostały wgrane na popularne repozytoria (Packagist, PyPI, npm, crates.io, NuGet, pkg.go.dev, Maven, PowerShell Gallery, RubyGems), a ich kody źródłowe zostały dodatkowo opublikowane na GitHubie:

Język Instalacja SDK Źródła
Język programowania PHP

Uruchom komendę:

php composer.phar require --prefer-dist pelock/radio-code-calculator "*"

lub dodaj do sekcji require w pliku konfiguracyjnym composer.json wpis:

"pelock/radio-code-calculator": "*"
Packagist GitHub
Język programowania Python pip install radio-code-calculator PyPI GitHub
Język programowania JavaScript

Uruchom komendę:

npm i radio-code-calculator

lub dodaj do sekcji dependencies w pliku konfiguracyjnym package.json wpis:

"dependencies": {
  "radio-code-calculator": "latest"
},

npm GitHub
Rust / Cargo

Uruchom komendę:

cargo add radio-code-calculator

lub dodaj wpis do sekcji [dependencies] w pliku Cargo.toml:

[dependencies]
radio-code-calculator = "1.0.0"
Crates GitHub
Repozytorium NuGet

Uruchom komendę:

dotnet add package RadioCodeCalculator

lub dodaj do pliku .csproj:

<PackageReference Include="RadioCodeCalculator" Version="1.0.1" />
NuGet GitHub
Pakiety modułów Go

Uruchom komendę:

go get github.com/PELock/Radio-Code-Calculator-Go

lub dodaj poniższy wpis do pliku go.mod

require github.com/PELock/Radio-Code-Calculator-Go v1.1.6
Go GitHub
Centralne Repozytorium Maven Dodaj tę zależność do pliku pom.xml
<dependency>
  <groupId>com.pelock</groupId>
  <artifactId>radio-code-calculator</artifactId>
  <version>1.1.6</version>
</dependency>
Maven GitHub
PowerShell Gallery

Uruchom komendę:

Install-Module -Name RadioCodeCalculator

lub:

Install-PSResource -Name RadioCodeCalculator

PowerShell Gallery GitHub
Repozytorium RubyGems

Uruchom komendę:

gem install radio-code-calculator

lub dodaj poniższy wpis do pliku Gemfile

gem "radio-code-calculator"
RubyGems GitHub

Formaty danych wejściowych

Każdy kalkulator wymaga innego formatu danych wejściowych, takich jak numer seryjny radia, aby poprawnie wygenerować kod odblokowujący. W przypadku podania błędnego formatu danych nie będzie możliwe wygenerowanie kodu odblokowującego.

Formaty danych są weryfikowane w bibliotece programistycznej w trybie online oraz opcjonalnie w trybie offline. Poniżej prezentujemy wymagane formaty dla danych wejściowych:

Model Opis Długość RegEx (PCRE)
Renault i Dacia Kalkulator i Generator Kodu RadiaRenault i Dacia PreCode, gdzie pierwszy znak to zawsze litera A..Z, a po niej występują trzy cyfry 0..9. 4 /^([A-Z]{1}[0-9]{3})$/
Ford Kod Do Radia M Seria Kalkulator i Generator Kodu RadiaFord M Seria Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki M). 6 /^([0-9]{6})$/
Ford Kod Do Radia V Seria Kalkulator i Generator Kodu RadiaFord V Seria Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki V). 6 /^([0-9]{6})$/
Ford TravelPilot EX, FX i NX Kod Do Radia Generator i KalkulatorFord TravelPilot EX, FX i NX Ostatnie 7 cyfr numeru seryjnego. 7 /^([0-9]{7})$/
Toyota ERC Kalkulator i Generator Kodu Do Odblokowania RadiaToyota ERC Kod ERC składa się z 16 cyfr i liter. 16 /^([A-Z0-9]{16})$/i
Jeep Cherokee Kod Do Odblokowania Radia Kalkulator i GeneratorJeep Cherokee Numer seryjny składa się z 14 znaków i cyfr (pomiń spacje). Upewnij się, że kod dostawcy (ang. supplier code) zaczyna się od cyfr 17719. 14 /^([A-Z0-9]{10}[0-9]{4})$/i
Chrysler Panasonic TM9 Kalkulator i Generator Kodu Do RadiaChrysler Panasonic TM9 Ostatnie 4 cyfry numeru seryjnego. Upewnij się, że numer seryjny rozpoczyna się od znaków TM9 np. T M9 XXX X X1234. 4 /^([0-9]{4})$/
Kod do radia Chrysler Dodge Ram Uconnect Harman Kardon VP2Chrysler Dodge Uconnect VP2 Ostatnie 4 znaki numeru seryjnego. Upewnij się, że numer seryjny rozpoczyna się od znaków TVPQN i to radio model VP2. 4 /^([A-Z0-9]{4})$/
Fiat Stilo i Bravo Kod Do Radia Visteon Kalkulator i GeneratorFiat Stilo i Bravo (Visteon) Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki M). 6 /^([A-Z0-9]{6})$/i
Fiat DAIICHI Kod Do Radia MOPAR Kalkulator i GeneratorFiat DAIICHI MOPAR Ostatnie 4 cyfry numeru seryjnego (zignoruj i NIE WPISUJ pierwszej literki). 4 /^([0-9]{4})$/i
Continental Fiat 250 i 500 VP1/VP2 Kod Do Radia Kalkulator i GeneratorFiat 250 i 500 VP1/VP2 Kod zaczyna się od znaków A2C i 16 cyfr. Wpisz jedynie ostatnie 4 cyfry numeru seryjnego. 4 /^([0-9]{4})$/i
Nissan Kalkulator Kodu PIN z Numeru SchowkaNissan PIN Immobilizera Kod schowka składa się z 12 cyfr i liter. 12 /^([A-Z0-9]{12})$/i
Eclipse ESN Kalkulator Kodu OdblokowującegoEclipse ESN Kod ESN składa się z 6 cyfr i liter. 6 /^([A-Z0-9]{6})$/i
Jaguar Alpine Kalkulator Kodu Odblokowującego Radio SamochodoweJaguar Alpine Ostatnie 5 cyfr numeru seryjnego. 5 /^([0-9]{5})$/

Przykłady użycia

Generowanie kodu radiowego

W tym przykładzie zaprezentowane jest generowanie kodu dla wybranego modelu radiowego. Cała walidacja parametrów wejściowych odbywa się po stronie serwera i jeśli numer seryjny radia będzie posiadał nieprawidłową długość lub wzorzec - usługa zwróci błąd.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.1.5
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;
use PELock\RadioCodeCalculator\RadioModels;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate radio code (using Web API)
//
list($error, $result) = $myRadioCodeCalculator->calc(RadioModels::get(RadioModels::FORD_M_SERIES), "123456");

switch($error)
{
        case RadioErrors::SUCCESS: echo "Radio code is " . $result["code"]; break;
        case RadioErrors::INVALID_RADIO_MODEL: echo "Invalid radio model (not supported)"; break;
        case RadioErrors::INVALID_SERIAL_LENGTH: echo "Invalid serial number length (expected " . $result["serialMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_SERIAL_PATTERN: echo "Invalid serial number regular expression pattern (expected " . $result["serialRegexPattern"]["php"] . " regex pattern)"; break;
        case RadioErrors::INVALID_SERIAL_NOT_SUPPORTED: echo "This serial number is not supported"; break;
        case RadioErrors::INVALID_EXTRA_LENGTH: echo "Invalid extra data length (expected " . $result["extraMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_EXTRA_PATTERN: echo "Invalid extra data regular expression pattern (expected " . $result["extraRegexPattern"]["php"] . " regex pattern"; break;
        case RadioErrors::INVALID_INPUT: echo "Invalid input data"; break;
        case RadioErrors::INVALID_COMMAND: echo "Invalid command sent to the Web API interface"; break;
        case RadioErrors::INVALID_LICENSE: echo "Invalid license key!"; break;
        default: echo "Something unexpected happen while trying to login to the service (error code {error})."; break;
}
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to generate a code for a specific
# type of car radio.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# generate radio code (using Web API)
#
error, result = myRadioCodeCalculator.calc(RadioModels.FORD_M_SERIES, "123456")

if error == RadioErrors.SUCCESS:
    print(f'Radio code is {result["code"]}')
elif error == RadioErrors.INVALID_RADIO_MODEL:
    print("Invalid radio model (not supported)")
elif error == RadioErrors.INVALID_SERIAL_LENGTH:
    print(f'Invalid serial number length (expected {result["serialMaxLen"]} characters)')
elif error == RadioErrors.INVALID_SERIAL_PATTERN:
    print(f'Invalid serial number regular expression pattern (expected {result["serialRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
    print("This serial number is not supported")
elif error == RadioErrors.INVALID_EXTRA_LENGTH:
    print(f'Invalid extra data length (expected {result["extraMaxLen"]} characters)')
elif error == RadioErrors.INVALID_EXTRA_PATTERN:
    print(f'Invalid extra data regular expression pattern (expected {result["extraRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_INPUT:
    print("Invalid input data")
elif error == RadioErrors.INVALID_COMMAND:
    print("Invalid command sent to the Web API interface")
elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key")
elif error == RadioErrors.ERROR_CONNECTION:
    print("Something unexpected happen while trying to login to the service.")
else:
    print(f'Unknown error {error}')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.1.5
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate radio code (using Web API)
//
myRadioCodeCalculator.calc(RadioModels.FORD_M_SERIES, "123456").then((result) => {

    console.log("Radio code is " + result["code"]);

}).catch((error) => {

    switch(error["error"])
    {
    case RadioErrors.INVALID_RADIO_MODEL: console.log("Invalid radio model (not supported)"); break;
    case RadioErrors.INVALID_SERIAL_LENGTH: console.log("Invalid serial number length (expected " + result["serialMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_SERIAL_PATTERN: console.log("Invalid serial number regular expression pattern (expected " + result["serialRegexPattern"]["php"] + " regex pattern)"); break;
    case RadioErrors.INVALID_SERIAL_NOT_SUPPORTED: console.log("This serial number is not supported"); break;
    case RadioErrors.INVALID_EXTRA_LENGTH: console.log("Invalid extra data length (expected " + result["extraMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_EXTRA_PATTERN: console.log("Invalid extra data regular expression pattern (expected " + result["extraRegexPattern"]["php"] + " regex pattern"); break;
    case RadioErrors.INVALID_INPUT: console.log("Invalid input data"); break;
    case RadioErrors.INVALID_COMMAND: console.log("Invalid command sent to the Web API interface"); break;
    case RadioErrors.INVALID_LICENSE: console.log("Invalid license key!"); break;
    default: console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`); break;
    }
});
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.0.0
 * Rust         : 2021
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2026 PELock LLC
 * @license Apache-2.0
 *
 *****************************************************************************/

//
// include Radio Code Calculator API module
//
use radio_code_calculator::{RadioCodeCalculator, RadioCodeCalculatorError, RadioErrors, RadioModels};

#[tokio::main]
async fn main() {
    //
    // create Radio Code Calculator API class instance (we are using our activation key)
    //
    let my_radio_code_calculator =
        RadioCodeCalculator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));

    //
    // generate radio code (using Web API)
    //
    match my_radio_code_calculator
        .calc(&*RadioModels::FORD_M_SERIES, "123456", "")
        .await
    {
        Ok(result) => {
            println!("Radio code is {}", result["code"]);
        }
        Err(e) => match e {
            RadioCodeCalculatorError::ApiError(ref v) => match v["error"].as_i64().unwrap_or(-1) as i32 {
                RadioErrors::INVALID_RADIO_MODEL => {
                    println!("Invalid radio model (not supported)");
                },
                RadioErrors::INVALID_SERIAL_LENGTH => println!(
                    "Invalid serial number length (expected {} characters)",
                    v["serialMaxLen"]
                ),
                RadioErrors::INVALID_SERIAL_PATTERN => println!(
                    "Invalid serial number regular expression pattern (expected {} regex pattern)",
                    v["serialRegexPattern"]["php"]
                ),
                RadioErrors::INVALID_SERIAL_NOT_SUPPORTED => {
                    println!("This serial number is not supported");
                },
                RadioErrors::INVALID_EXTRA_LENGTH => println!(
                    "Invalid extra data length (expected {} characters)",
                    v["extraMaxLen"]
                ),
                RadioErrors::INVALID_EXTRA_PATTERN => println!(
                    "Invalid extra data regular expression pattern (expected {} regex pattern",
                    v["extraRegexPattern"]["php"]
                ),
                RadioErrors::INVALID_INPUT => println!("Invalid input data"),
                RadioErrors::INVALID_COMMAND => {
                    println!("Invalid command sent to the Web API interface");
                },
                RadioErrors::INVALID_LICENSE => println!("Invalid license key!"),
                _ => println!("Something unexpected happen while trying to login to the service (error code {v:?})."),
            },
            RadioCodeCalculatorError::InvalidLicense => println!("Invalid license key!"),
            RadioCodeCalculatorError::Transport(msg) => {
                println!("Connection error: {msg}");
            }
        },
    }
}
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v.1.0.0
 * Language     : C#
 * Dependencies : RadioCodeCalculator (NuGet / project reference)
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

var myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

try
{
    var result = await myRadioCodeCalculator.CalcAsync(RadioModels.FordMSeries, "123456");
    Console.WriteLine("Radio code is " + result["code"]?.ToString());
}
catch (RadioApiException ex)
{
    switch (ex.ErrorCode)
    {
        case RadioErrors.InvalidRadioModel:
            Console.WriteLine("Invalid radio model (not supported)");
            break;
        case RadioErrors.InvalidSerialLength:
            Console.WriteLine("Invalid serial number length (expected " + ex.Response["serialMaxLen"] + " characters)");
            break;
        case RadioErrors.InvalidSerialPattern:
            Console.WriteLine("Invalid serial number regular expression pattern (expected " +
                              ex.Response["serialRegexPattern"]?["php"] + " regex pattern)");
            break;
        case RadioErrors.InvalidSerialNotSupported:
            Console.WriteLine("This serial number is not supported");
            break;
        case RadioErrors.InvalidExtraLength:
            Console.WriteLine("Invalid extra data length (expected " + ex.Response["extraMaxLen"] + " characters)");
            break;
        case RadioErrors.InvalidExtraPattern:
            Console.WriteLine("Invalid extra data regular expression pattern (expected " +
                              ex.Response["extraRegexPattern"]?["php"] + " regex pattern)");
            break;
        case RadioErrors.InvalidInput:
            Console.WriteLine("Invalid input data");
            break;
        case RadioErrors.InvalidCommand:
            Console.WriteLine("Invalid command sent to the Web API interface");
            break;
        case RadioErrors.InvalidLicense:
            Console.WriteLine("Invalid license key!");
            break;
        default:
            Console.WriteLine($"Something unexpected happen while trying to login to the service (error code {ex.ErrorCode}).");
            break;
    }
}
/******************************************************************************
 * Radio Code Calculator API usage example.
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.1.6
 * Language     : Go
 * Author       : Bartosz Wójcik
 * Homepage     : https://www.pelock.com
 *
 *****************************************************************************/

package main

import (
	"context"
	"fmt"
	"os"

	radiocodecalculator "github.com/PELock/Radio-Code-Calculator-Go"
)

func main() {
	client := radiocodecalculator.New("ABCD-ABCD-ABCD-ABCD")
	errCode, result, err := client.Calc(context.Background(), radiocodecalculator.FordMSeries, "123456", "")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	switch errCode {
	case radiocodecalculator.ErrorSuccess:
		fmt.Println("Radio code is", result["code"])
	case radiocodecalculator.ErrorInvalidRadioModel:
		fmt.Println("Invalid radio model (not supported)")
	case radiocodecalculator.ErrorInvalidSerialLength:
		fmt.Println("Invalid serial number length")
	case radiocodecalculator.ErrorInvalidSerialPattern:
		fmt.Println("Invalid serial number regular expression pattern")
	case radiocodecalculator.ErrorInvalidLicense:
		fmt.Println("Invalid license key!")
	default:
		fmt.Printf("Something unexpected happen while trying to talk to the service (error code %d).\n", errCode)
	}
}
/******************************************************************************
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version        : v1.1.6
 * Language       : Java
 * Author         : Bartosz Wójcik
 * Web page       : https://www.pelock.com
 *
 *****************************************************************************/

import com.pelock.radiocode.RadioApiResult;
import com.pelock.radiocode.RadioCodeCalculator;
import com.pelock.radiocode.RadioErrors;
import com.pelock.radiocode.RadioModels;

public class RadioCodeCalculatorSimple {

  public static void main(String[] args) throws Exception {
    RadioCodeCalculator client = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");
    RadioApiResult result = client.calc(RadioModels.FORD_M_SERIES, "123456");

    switch (result.getError()) {
      case RadioErrors.SUCCESS:
        System.out.println("Radio code is " + result.getCode());
        break;
      case RadioErrors.INVALID_RADIO_MODEL:
        System.out.println("Invalid radio model (not supported)");
        break;
      case RadioErrors.INVALID_SERIAL_LENGTH:
        System.out.println("Invalid serial number length");
        break;
      case RadioErrors.INVALID_SERIAL_PATTERN:
        System.out.println("Invalid serial number regular expression pattern");
        break;
      case RadioErrors.INVALID_LICENSE:
        System.out.println("Invalid license key!");
        break;
      default:
        System.out.println("Something unexpected happen while trying to talk to the service (error code " + result.getError() + ").");
        break;
    }
  }
}
################################################################################
#
# Radio Code Calculator WebApi interface usage example.
#
# Generate a code for a specific radio model.
#
# Version        : v1.0.0
# Language       : PowerShell
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
################################################################################

using module RadioCodeCalculator

$myRadioCodeCalculator = New-RadioCodeCalculator -ApiKey 'ABCD-ABCD-ABCD-ABCD'
$apiError, $result = $myRadioCodeCalculator.Calc([RadioModels]::Get([RadioModels]::FORD_M_SERIES), '123456')

switch ($apiError) {
    ([RadioErrors]::SUCCESS) { Write-Host ("Radio code is {0}" -f $result.code) }
    ([RadioErrors]::INVALID_RADIO_MODEL) { Write-Host 'Invalid radio model (not supported)' }
    ([RadioErrors]::INVALID_SERIAL_LENGTH) { Write-Host ("Invalid serial number length (expected {0} characters)" -f $result.serialMaxLen) }
    ([RadioErrors]::INVALID_SERIAL_PATTERN) { Write-Host 'Invalid serial number regular expression pattern' }
    ([RadioErrors]::INVALID_SERIAL_NOT_SUPPORTED) { Write-Host 'This serial number is not supported' }
    ([RadioErrors]::INVALID_EXTRA_LENGTH) { Write-Host ("Invalid extra data length (expected {0} characters)" -f $result.extraMaxLen) }
    ([RadioErrors]::INVALID_EXTRA_PATTERN) { Write-Host 'Invalid extra data regular expression pattern' }
    ([RadioErrors]::INVALID_INPUT) { Write-Host 'Invalid input data' }
    ([RadioErrors]::INVALID_COMMAND) { Write-Host 'Invalid command sent to the Web API interface' }
    ([RadioErrors]::INVALID_LICENSE) { Write-Host 'Invalid license key!' }
    default { Write-Host ("Something unexpected happen while trying to talk to the service (error code {0})." -f $apiError) }
}
# frozen_string_literal: true

###############################################################################
#
# Radio Code Calculator — generate a code
#
# Version        : v1.1.6
# Language       : Ruby
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
###############################################################################

require "radio-code-calculator"

client = RadioCodeCalculator.new("ABCD-ABCD-ABCD-ABCD")
error, result = client.calc(RadioModels.get(RadioModels::FORD_M_SERIES), "123456")

case error
when RadioErrors::SUCCESS
  puts "Radio code is #{result["code"]}"
when RadioErrors::INVALID_RADIO_MODEL
  puts "Invalid radio model (not supported)"
when RadioErrors::INVALID_SERIAL_LENGTH
  puts "Invalid serial number length"
when RadioErrors::INVALID_SERIAL_PATTERN
  puts "Invalid serial number regular expression pattern"
when RadioErrors::INVALID_LICENSE
  puts "Invalid license key!"
else
  puts "Something unexpected happen while trying to talk to the service (error code #{error})."
end

Generowanie kodu radiowego z dodatkową walidacją w trybie offline

Kody radiowe generowane są na podstawie wejściowych parametrów takich jak m.in. numer seryjny radia.

Numery seryjne radia różnią się dla różnych raddioodtwarzaczy, mają różną długość i różny wzór, jedne mogą się składać z samych cyfr np. 1234, a inne z cyfr i liter np. AB1234XYZ.

Walidacja tych danych odbywa się po stronie serwera. Jednak dla usprawnienia działania, możemy wykorzystać informacje o dostępnych limitach i wzorcach poszczególnych numerów seryjnych, aby np. ustawić te ograniczenia w kontrolkach we własnych aplikacjach bez zbędnego wywoływania zapytań do interfejsu Web API.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v1.1.5
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;
use PELock\RadioCodeCalculator\RadioModel;
use PELock\RadioCodeCalculator\RadioModels;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate a single radio unlocking code
//
$serial = "123456";
$extra = "";

//
// select a radio model
//
$radioModel = RadioModels::get(RadioModels::FORD_M_SERIES);

//
// display radio model information, you can use it to set limits in your controls e.g.
//
// textFieldRadioSerial.maxLength = radioModel->serial_max_len
// textFieldRadioSerial.regEx = radioModel->serial_regex_pattern()
//
// (if allowed by your controls)
//
echo "Radio model $radioModel->name expects a serial number of $radioModel->serial_max_len length and {$radioModel->serial_regex_pattern()} regex pattern<br>";

// additional information
if ($radioModel->extra_max_len > 0)
{
        echo "Additionally an extra field is required with $radioModel->extra_max_len and {$radioModel->extra_regex_pattern()} regex pattern<br>";
}

//
// validate the serial number (offline) before sending the Web API request
//
$error = $radioModel->validate($serial, $extra);

if ($error !== RadioErrors::SUCCESS)
{
    if ($error === RadioErrors::INVALID_SERIAL_LENGTH)
        echo "Invalid serial number length (expected $radioModel->serial_max_len characters<br>";
    else if ($error == RadioErrors::INVALID_SERIAL_PATTERN)
        echo "Invalid serial number regular expression pattern (expected $radioModel->serial_regex_pattern() regex pattern)<br>";
    else if ($error == RadioErrors::INVALID_SERIAL_NOT_SUPPORTED)
        echo "This serial number is not supported";
    else if ($error == RadioErrors::INVALID_EXTRA_LENGTH)
        echo "Invalid extra data length (expected $radioModel->extra_max_len characters)<br>";
    else if ($error == RadioErrors::INVALID_EXTRA_PATTERN)
        echo "Invalid extra data regular expression pattern (expected $radioModel->extra_regex_pattern() regex pattern)<br>";

    exit(1);
}

//
// generate radio code (using Web API)
//
list($error, $result) = $myRadioCodeCalculator->calc($radioModel, $serial);

switch($error)
{
        case RadioErrors::SUCCESS: echo "Radio code is " . $result["code"]; break;
        case RadioErrors::INVALID_RADIO_MODEL: echo "Invalid radio model (not supported)"; break;
        case RadioErrors::INVALID_SERIAL_LENGTH: echo "Invalid serial number length (expected " . $result["serialMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_SERIAL_PATTERN: echo "Invalid serial number regular expression pattern (expected " . $result["serialRegexPattern"]["php"] . " regex pattern)"; break;
        case RadioErrors::INVALID_SERIAL_NOT_SUPPORTED: echo "This serial number is not supported"; break;
        case RadioErrors::INVALID_EXTRA_LENGTH: echo "Invalid extra data length (expected " . $result["extraMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_EXTRA_PATTERN: echo "Invalid extra data regular expression pattern (expected " . $result["extraRegexPattern"]["php"] . " regex pattern"; break;
        case RadioErrors::INVALID_INPUT: echo "Invalid input data"; break;
        case RadioErrors::INVALID_COMMAND: echo "Invalid command sent to the Web API interface"; break;
        case RadioErrors::INVALID_LICENSE: echo "Invalid license key!"; break;
        default: echo "Something unexpected happen while trying to login to the service (error code {error})."; break;
}
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to generate a code for a specific
# type of car radio. This examples shows how to use an extended offline
# validation.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# generate a single radio unlocking code
#
serial: str = "123456"
extra: str = ""

#
# select a radio model
#
radioModel: RadioModel = RadioModels.FORD_M_SERIES

#
# display radio model information, you can use it to set limits in your controls e.g.
#
# textFieldRadioSerial.maxLength = radioModel.serial_max_len
# textFieldRadioSerial.regEx = radioModel.serial_regex_pattern
#
# (if allowed by your controls)
#
print(f'Radio model {radioModel.name} expects a serial number of {radioModel.serial_max_len}'
      f' length and {radioModel.serial_regex_pattern} regex pattern')

# additional information
if radioModel.extra_max_len > 0:
    print(f'Additionally an extra field is required with {radioModel.extra_max_len} and'
          f' and {radioModel.extra_regex_pattern} regex pattern')

#
# validate the serial number (offline) before sending the Web API request
#
error = radioModel.validate(serial, extra)

if error != RadioErrors.SUCCESS:

    if error == RadioErrors.INVALID_SERIAL_LENGTH:
        print(f'Invalid serial number length (expected {radioModel.serial_max_len} characters)')
    elif error == RadioErrors.INVALID_SERIAL_PATTERN:
        print(f'Invalid serial number regular expression pattern (expected {radioModel.serial_regex_pattern} regex pattern)')
    elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
        print("This serial number is not supported")
    elif error == RadioErrors.INVALID_EXTRA_LENGTH:
        print(f'Invalid extra data length (expected {radioModel.extra_max_len} characters)')
    elif error == RadioErrors.INVALID_EXTRA_PATTERN:
        print(f'Invalid extra data regular expression pattern (expected {radioModel.extra_regex_pattern} regex pattern)')
    exit(1)

#
# generate radio code (using Web API)
#
error, result = myRadioCodeCalculator.calc(radioModel, "123456")

if error == RadioErrors.SUCCESS:
    print(f'Radio code is {result["code"]}')
elif error == RadioErrors.INVALID_RADIO_MODEL:
    print("Invalid radio model (not supported)")
elif error == RadioErrors.INVALID_SERIAL_LENGTH:
    print(f'Invalid serial number length (expected {result["serialMaxLen"]} characters)')
elif error == RadioErrors.INVALID_SERIAL_PATTERN:
    print(f'Invalid serial number regular expression pattern (expected {result["serialRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
    print("This serial number is not supported")
elif error == RadioErrors.INVALID_EXTRA_LENGTH:
    print(f'Invalid extra data length (expected {result["extraMaxLen"]} characters)')
elif error == RadioErrors.INVALID_EXTRA_PATTERN:
    print(f'Invalid extra data regular expression pattern (expected {result["extraRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_INPUT:
    print("Invalid input data")
elif error == RadioErrors.INVALID_COMMAND:
    print("Invalid command sent to the Web API interface")
elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key")
elif error == RadioErrors.ERROR_CONNECTION:
    print("Something unexpected happen while trying to login to the service.")
else:
    print(f'Unknown error {error}')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v1.1.5
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate a single radio unlocking code
//
let serial = "123456";
let extra = "";

//
// select a radio model
//
let radioModel = RadioModels.FORD_M_SERIES;

//
// display radio model information, you can use it to set limits in your controls e.g.
//
// textFieldRadioSerial.maxLength = radioModel.serial_max_len
// textFieldRadioSerial.regEx = radioModel.serial_regex_pattern()
//
// (if allowed by your controls)
//
console.log(`Radio model ${radioModel.name} expects a serial number of ${radioModel.serial_max_len} length and ${radioModel.serial_regex_pattern()} regex pattern<br>`);

// additional information
if (radioModel.extra_max_len > 0)
{
    console.log(`Additionally an extra field is required with ${radioModel.extra_max_len} and ${radioModel.extra_regex_pattern()} regex pattern<br>`);
}

//
// validate the serial number (offline) before sending the Web API request
//
let error = radioModel.validate(serial, extra);

if (error !== RadioErrors.SUCCESS)
{
    if (error === RadioErrors.INVALID_SERIAL_LENGTH)
        console.log(`Invalid serial number length (expected ${radioModel.serial_max_len} characters<br>`);
    else if (error == RadioErrors.INVALID_SERIAL_PATTERN)
        console.log(`Invalid serial number regular expression pattern (expected ${radioModel.serial_regex_pattern()} regex pattern)<br>`);
    else if (error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED)
        console.log("This serial number is not supported");
    else if (error == RadioErrors.INVALID_EXTRA_LENGTH)
        console.log(`Invalid extra data length (expected ${radioModel.extra_max_len} characters)<br>`);
    else if (error == RadioErrors.INVALID_EXTRA_PATTERN)
        console.log(`Invalid extra data regular expression pattern (expected ${radioModel.extra_regex_pattern()} regex pattern)<br>`);

    process.exit(1);
}

//
// generate radio code (using Web API)
//
myRadioCodeCalculator.calc(radioModel, serial).then((result) => {

    console.log("Radio code is " + result["code"]);

}).catch((error) => {

    switch(error["error"])
    {
    case RadioErrors.INVALID_RADIO_MODEL: console.log("Invalid radio model (not supported)"); break;
    case RadioErrors.INVALID_SERIAL_LENGTH: console.log("Invalid serial number length (expected " + result["serialMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_SERIAL_PATTERN: console.log("Invalid serial number regular expression pattern (expected " + result["serialRegexPattern"]["php"] + " regex pattern)"); break;
    case RadioErrors.INVALID_SERIAL_NOT_SUPPORTED: console.log("This serial number is not supported"); break;
    case RadioErrors.INVALID_EXTRA_LENGTH: console.log("Invalid extra data length (expected " + result["extraMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_EXTRA_PATTERN: console.log("Invalid extra data regular expression pattern (expected " + result["extraRegexPattern"]["php"] + " regex pattern"); break;
    case RadioErrors.INVALID_INPUT: console.log("Invalid input data"); break;
    case RadioErrors.INVALID_COMMAND: console.log("Invalid command sent to the Web API interface"); break;
    case RadioErrors.INVALID_LICENSE: console.log("Invalid license key!"); break;
    default: console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`); break;
    }
});
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v1.0.0
 * Rust         : 2021
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2026 PELock LLC
 * @license Apache-2.0
 *
 *****************************************************************************/

//
// include Radio Code Calculator API module
//
use radio_code_calculator::{RadioCodeCalculator, RadioCodeCalculatorError, RadioErrors, RadioModels};

#[tokio::main]
async fn main() {
    //
    // create Radio Code Calculator API class instance (we are using our activation key)
    //
    let my_radio_code_calculator =
        RadioCodeCalculator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));

    //
    // generate a single radio unlocking code
    //
    let serial = "123456";
    let extra = "";

    //
    // select a radio model
    //
    let radio_model = &*RadioModels::FORD_M_SERIES;

    //
    // display radio model information, you can use it to set limits in your controls e.g.
    //
    // textFieldRadioSerial.maxLength = radioModel.serial_max_len
    // textFieldRadioSerial.regEx = radioModel.serial_regex_pattern()
    //
    // (if allowed by your controls)
    //
    println!(
        "Radio model {} expects a serial number of {} length and {} regex pattern<br>",
        radio_model.name,
        radio_model.serial_max_len,
        radio_model.serial_regex_pattern()
    );

    // additional information
    if radio_model.extra_max_len > 0 {
        println!(
            "Additionally an extra field is required with {} and {:?} regex pattern<br>",
            radio_model.extra_max_len,
            radio_model.extra_regex_pattern()
        );
    }

    //
    // validate the serial number (offline) before sending the Web API request
    //
    let error = radio_model.validate(serial, Some(extra));

    if error != RadioErrors::SUCCESS {
        if error == RadioErrors::INVALID_SERIAL_LENGTH {
            println!(
                "Invalid serial number length (expected {} characters<br>",
                radio_model.serial_max_len
            );
        } else if error == RadioErrors::INVALID_SERIAL_PATTERN {
            println!(
                "Invalid serial number regular expression pattern (expected {} regex pattern)<br>",
                radio_model.serial_regex_pattern()
            );
        } else if error == RadioErrors::INVALID_SERIAL_NOT_SUPPORTED {
            println!("This serial number is not supported");
        } else if error == RadioErrors::INVALID_EXTRA_LENGTH {
            println!(
                "Invalid extra data length (expected {} characters)<br>",
                radio_model.extra_max_len
            );
        } else if error == RadioErrors::INVALID_EXTRA_PATTERN {
            println!(
                "Invalid extra data regular expression pattern (expected {:?} regex pattern)<br>",
                radio_model.extra_regex_pattern()
            );
        }
        std::process::exit(1);
    }

    //
    // generate radio code (using Web API)
    //
    match my_radio_code_calculator
        .calc(radio_model, serial, extra)
        .await
    {
        Ok(result) => println!("Radio code is {}", result["code"]),
        Err(e) => match e {
            RadioCodeCalculatorError::ApiError(ref v) => match v["error"].as_i64().unwrap_or(-1) as i32 {
                RadioErrors::INVALID_RADIO_MODEL => {
                    println!("Invalid radio model (not supported)");
                },
                RadioErrors::INVALID_SERIAL_LENGTH => println!(
                    "Invalid serial number length (expected {} characters)",
                    v["serialMaxLen"]
                ),
                RadioErrors::INVALID_SERIAL_PATTERN => println!(
                    "Invalid serial number regular expression pattern (expected {} regex pattern)",
                    v["serialRegexPattern"]["php"]
                ),
                RadioErrors::INVALID_SERIAL_NOT_SUPPORTED => {
                    println!("This serial number is not supported");
                },
                RadioErrors::INVALID_EXTRA_LENGTH => println!(
                    "Invalid extra data length (expected {} characters)",
                    v["extraMaxLen"]
                ),
                RadioErrors::INVALID_EXTRA_PATTERN => println!(
                    "Invalid extra data regular expression pattern (expected {} regex pattern)",
                    v["extraRegexPattern"]["php"]
                ),
                RadioErrors::INVALID_INPUT => println!("Invalid input data"),
                RadioErrors::INVALID_COMMAND => {
                    println!("Invalid command sent to the Web API interface");
                },
                RadioErrors::INVALID_LICENSE => println!("Invalid license key!"),
                _ => println!("Something unexpected happen while trying to login to the service (error code {v:?})."),
            },
            RadioCodeCalculatorError::InvalidLicense => println!("Invalid license key!"),
            RadioCodeCalculatorError::Transport(msg) => println!("Connection error: {msg}"),
        },
    }
}
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v.1.0.0
 * Language     : C#
 * Dependencies : RadioCodeCalculator (NuGet / project reference)
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

var myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

var serial = "123456";
var extra = "";

var radioModel = RadioModels.FordMSeries;

Console.WriteLine(
    $"Radio model {radioModel.Name} expects a serial number of {radioModel.SerialMaxLen} length and {radioModel.SerialRegexPattern()} regex pattern<br>");

if (radioModel.ExtraMaxLen > 0)
{
    Console.WriteLine(
        $"Additionally an extra field is required with {radioModel.ExtraMaxLen} and {radioModel.ExtraRegexPattern()} regex pattern<br>");
}

var error = radioModel.Validate(serial, extra);

if (error != RadioErrors.Success)
{
    if (error == RadioErrors.InvalidSerialLength)
        Console.WriteLine($"Invalid serial number length (expected {radioModel.SerialMaxLen} characters<br>");
    else if (error == RadioErrors.InvalidSerialPattern)
        Console.WriteLine(
            $"Invalid serial number regular expression pattern (expected {radioModel.SerialRegexPattern()} regex pattern)<br>");
    else if (error == RadioErrors.InvalidSerialNotSupported)
        Console.WriteLine("This serial number is not supported");
    else if (error == RadioErrors.InvalidExtraLength)
        Console.WriteLine($"Invalid extra data length (expected {radioModel.ExtraMaxLen} characters)<br>");
    else if (error == RadioErrors.InvalidExtraPattern)
        Console.WriteLine(
            $"Invalid extra data regular expression pattern (expected {radioModel.ExtraRegexPattern()} regex pattern)<br>");

    Environment.Exit(1);
}

try
{
    var result = await myRadioCodeCalculator.CalcAsync(radioModel, serial);
    Console.WriteLine("Radio code is " + result["code"]?.ToString());
}
catch (RadioApiException ex)
{
    switch (ex.ErrorCode)
    {
        case RadioErrors.InvalidRadioModel:
            Console.WriteLine("Invalid radio model (not supported)");
            break;
        case RadioErrors.InvalidSerialLength:
            Console.WriteLine("Invalid serial number length (expected " + ex.Response["serialMaxLen"] + " characters)");
            break;
        case RadioErrors.InvalidSerialPattern:
            Console.WriteLine("Invalid serial number regular expression pattern (expected " +
                              ex.Response["serialRegexPattern"]?["php"] + " regex pattern)");
            break;
        case RadioErrors.InvalidSerialNotSupported:
            Console.WriteLine("This serial number is not supported");
            break;
        case RadioErrors.InvalidExtraLength:
            Console.WriteLine("Invalid extra data length (expected " + ex.Response["extraMaxLen"] + " characters)");
            break;
        case RadioErrors.InvalidExtraPattern:
            Console.WriteLine("Invalid extra data regular expression pattern (expected " +
                              ex.Response["extraRegexPattern"]?["php"] + " regex pattern)");
            break;
        case RadioErrors.InvalidInput:
            Console.WriteLine("Invalid input data");
            break;
        case RadioErrors.InvalidCommand:
            Console.WriteLine("Invalid command sent to the Web API interface");
            break;
        case RadioErrors.InvalidLicense:
            Console.WriteLine("Invalid license key!");
            break;
        default:
            Console.WriteLine($"Something unexpected happen while trying to login to the service (error code {ex.ErrorCode}).");
            break;
    }
}
/******************************************************************************
 * Radio Code Calculator API usage example.
 *
 * Generate a radio code after offline validation of the serial number.
 *
 * Version      : v1.1.6
 * Language     : Go
 * Author       : Bartosz Wójcik
 * Homepage     : https://www.pelock.com
 *
 *****************************************************************************/

package main

import (
	"context"
	"fmt"
	"os"

	radiocodecalculator "github.com/PELock/Radio-Code-Calculator-Go"
)

func main() {
	client := radiocodecalculator.New("ABCD-ABCD-ABCD-ABCD")
	model := radiocodecalculator.FordMSeries
	serial := "123456"
	extra := ""

	fmt.Printf("Radio model %s expects a serial number of %d length and %s regex pattern\n",
		model.Name, model.SerialMaxLen, model.SerialRegexPattern())

	if apiError := model.Validate(serial, extra); apiError != radiocodecalculator.ErrorSuccess {
		switch apiError {
		case radiocodecalculator.ErrorInvalidSerialLength:
			fmt.Printf("Invalid serial number length (expected %d characters)\n", model.SerialMaxLen)
		case radiocodecalculator.ErrorInvalidSerialPattern:
			fmt.Printf("Invalid serial number regular expression pattern (expected %s)\n", model.SerialRegexPattern())
		default:
			fmt.Printf("Validation failed (error code %d)\n", apiError)
		}
		os.Exit(1)
	}

	errCode, result, err := client.Calc(context.Background(), model, serial, extra)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	if errCode == radiocodecalculator.ErrorSuccess {
		fmt.Println("Radio code is", result["code"])
	} else {
		fmt.Printf("API error %d\n", errCode)
	}
}
/******************************************************************************
 * Radio Code Calculator API - WebApi interface usage example
 *
 * Generate a radio code after offline validation of the serial number.
 *
 * Version        : v1.1.6
 * Language       : Java
 * Author         : Bartosz Wójcik
 * Web page       : https://www.pelock.com
 *
 *****************************************************************************/

import com.pelock.radiocode.RadioApiResult;
import com.pelock.radiocode.RadioCodeCalculator;
import com.pelock.radiocode.RadioErrors;
import com.pelock.radiocode.RadioModel;
import com.pelock.radiocode.RadioModels;

public class RadioCodeCalculatorOfflineValidation {

  public static void main(String[] args) throws Exception {
    RadioCodeCalculator client = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");
    RadioModel radioModel = RadioModels.FORD_M_SERIES;
    String serial = "123456";

    System.out.println(
        "Radio model "
            + radioModel.name
            + " expects a serial number of "
            + radioModel.serialMaxLen
            + " length and "
            + radioModel.serialRegexPattern()
            + " regex pattern");

    int apiError = radioModel.validate(serial, "");
    if (apiError != RadioErrors.SUCCESS) {
      if (apiError == RadioErrors.INVALID_SERIAL_LENGTH) {
        System.out.println("Invalid serial number length (expected " + radioModel.serialMaxLen + " characters)");
      } else if (apiError == RadioErrors.INVALID_SERIAL_PATTERN) {
        System.out.println("Invalid serial number regular expression pattern (expected " + radioModel.serialRegexPattern() + ")");
      } else {
        System.out.println("Validation failed (error code " + apiError + ")");
      }
      return;
    }

    RadioApiResult result = client.calc(radioModel, serial);
    if (result.getError() == RadioErrors.SUCCESS) {
      System.out.println("Radio code is " + result.getCode());
    } else {
      System.out.println("API error " + result.getError());
    }
  }
}
################################################################################
#
# Radio Code Calculator WebApi interface usage example.
#
# Offline validation of a serial before calling the Web API.
#
# Version        : v1.0.0
# Language       : PowerShell
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
################################################################################

using module RadioCodeCalculator

$myRadioCodeCalculator = New-RadioCodeCalculator -ApiKey 'ABCD-ABCD-ABCD-ABCD'
$serial = '123456'
$extra = ''
$radioModel = [RadioModels]::Get([RadioModels]::FORD_M_SERIES)

Write-Host ("Radio model {0} expects a serial number of {1} length and {2} regex pattern" -f $radioModel.name, $radioModel.serial_max_len, $radioModel.serial_regex_pattern())

$apiError = $radioModel.validate($serial, $extra)
if ($apiError -ne [RadioErrors]::SUCCESS) {
    switch ($apiError) {
        ([RadioErrors]::INVALID_SERIAL_LENGTH) { Write-Host ("Invalid serial number length (expected {0} characters)" -f $radioModel.serial_max_len) }
        ([RadioErrors]::INVALID_SERIAL_PATTERN) { Write-Host ("Invalid serial number regular expression pattern (expected {0})" -f $radioModel.serial_regex_pattern()) }
        ([RadioErrors]::INVALID_EXTRA_LENGTH) { Write-Host ("Invalid extra data length (expected {0} characters)" -f $radioModel.extra_max_len) }
        ([RadioErrors]::INVALID_EXTRA_PATTERN) { Write-Host ("Invalid extra data regular expression pattern (expected {0})" -f $radioModel.extra_regex_pattern()) }
        default { Write-Host ("Validation failed (error code {0})" -f $apiError) }
    }
    exit 1
}

$apiError, $result = $myRadioCodeCalculator.Calc($radioModel, $serial)
if ($apiError -eq [RadioErrors]::SUCCESS) {
    Write-Host ("Radio code is {0}" -f $result.code)
}
else {
    Write-Host ("API error {0}" -f $apiError)
}
# frozen_string_literal: true

###############################################################################
#
# Radio Code Calculator — offline validation
#
# Version        : v1.1.6
# Language       : Ruby
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
###############################################################################

require "radio-code-calculator"

client = RadioCodeCalculator.new("ABCD-ABCD-ABCD-ABCD")
model = RadioModels.get(RadioModels::FORD_M_SERIES)
serial = "123456"

puts "Radio model #{model.name} expects a serial number of #{model.serial_max_len} length and #{model.serial_regex_pattern} regex pattern"

api_error = model.validate(serial)
unless api_error == RadioErrors::SUCCESS
  case api_error
  when RadioErrors::INVALID_SERIAL_LENGTH
    puts "Invalid serial number length (expected #{model.serial_max_len} characters)"
  when RadioErrors::INVALID_SERIAL_PATTERN
    puts "Invalid serial number regular expression pattern (expected #{model.serial_regex_pattern})"
  else
    puts "Validation failed (error code #{api_error})"
  end
  exit 1
end

error, result = client.calc(model, serial)
if error == RadioErrors::SUCCESS
  puts "Radio code is #{result["code"]}"
else
  puts "API error #{error}"
end

Pobieranie listy obsługiwanych kalkulatorów radiowych

Jeśli chciałbyś pobrać informację o wszystkich obsługiwanych modelach radioodtwarzaczy oraz ich parametrach takich jak długość numeru seryjnego i wzorzec - możesz to zrobić.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v1.1.5
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// get the list of the supported radio calculators and their parameters (max. length, regex pattern)
//
list($error, $radio_models) = $myRadioCodeCalculator->list();

if ($error == RadioErrors::SUCCESS)
{
        echo "Supported radio models " . count($radio_models) . "<br>";

        foreach ($radio_models as $radio_model)
        {
                echo "Radio model name - $radio_model->name<br>";

                echo "Max. length of the radio serial number - " . $radio_model->serial_max_len . "<br>";
                echo "Regex pattern for the radio serial number - " . $radio_model->serial_regex_pattern() . "<br>";

                // is extra field specified?
                if ($radio_model->extra_max_len > 0)
                {
                        echo "Max. length of the radio extra data - " . $radio_model->extra_max_len . "<br>";
                        echo "Regex pattern for the radio extra data - " . $radio_model->extra_regex_pattern() . "<br>";
                        echo "<br>";
                }
        }
}
else if ($error == RadioErrors::INVALID_LICENSE)
        echo "Invalid license key!";
else
        echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example we will list all the available calculators, and their
# parameters like name, maximum length of the radio serial number and its
# regex pattern.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# get the list of the supported radio calculators and their parameters (max. length, regex pattern)
#
error, radio_models = myRadioCodeCalculator.list()

if error == RadioErrors.SUCCESS:

    print(f'Supported radio models {len(radio_models)}:\n')

    for radio_model in radio_models:

        print(f'Radio model name - {radio_model.name}')

        print(f'Max. length of the radio serial number - {radio_model.serial_max_len}')
        print(f'Regex pattern for the radio serial number - {radio_model.serial_regex_pattern}')

        # is extra field specified?
        if radio_model.extra_max_len > 0:
            print(f'Max. length of the radio extra data - {radio_model.extra_max_len}')
            print(f'Regex pattern for the radio extra data - {radio_model.extra_regex_pattern}')

        print()

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v1.1.5
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// get the list of the supported radio calculators and their parameters (max. length, regex pattern)
//
myRadioCodeCalculator.list().then((result) => {

    let radio_models = result["radioModels"];

    console.log("Supported radio models " + radio_models.length + "<br>");

    radio_models.forEach(radio_model => {

        console.log("Radio model name - " + radio_model.name + "<br>");

        console.log("Max. length of the radio serial number - " + radio_model.serial_max_len + "<br>");
        console.log("Regex pattern for the radio serial number - " + radio_model.serial_regex_pattern() + "<br>");

        // is extra field specified?
        if (radio_model.extra_max_len > 0)
        {
            console.log("Max. length of the radio extra data - " + radio_model.extra_max_len + "<br>");
            console.log("Regex pattern for the radio extra data - " + radio_model.extra_regex_pattern() + "<br>");
            console.log("<br>");
        }

    });

}).catch((error) => {

    if (error["error"] == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`);
});
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v1.0.0
 * Rust         : 2021
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2026 PELock LLC
 * @license Apache-2.0
 *
 *****************************************************************************/

//
// include Radio Code Calculator API module
//
use radio_code_calculator::{RadioCodeCalculator, RadioCodeCalculatorError, RadioErrors};

#[tokio::main]
async fn main() {
    //
    // create Radio Code Calculator API class instance (we are using our activation key)
    //
    let my_radio_code_calculator =
        RadioCodeCalculator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));

    //
    // get the list of the supported radio calculators and their parameters (max. length, regex pattern)
    //
    match my_radio_code_calculator.list().await {
        Ok(list) => {
            let radio_models = &list.radio_models;

            println!("Supported radio models {}<br>", radio_models.len());

            for radio_model in radio_models {
                println!("Radio model name - {}<br>", radio_model.name);

                println!(
                    "Max. length of the radio serial number - {}<br>",
                    radio_model.serial_max_len
                );
                println!(
                    "Regex pattern for the radio serial number - {}<br>",
                    radio_model.serial_regex_pattern()
                );

                // is extra field specified?
                if radio_model.extra_max_len > 0 {
                    println!(
                        "Max. length of the radio extra data - {}<br>",
                        radio_model.extra_max_len
                    );
                    println!(
                        "Regex pattern for the radio extra data - {:?}<br>",
                        radio_model.extra_regex_pattern()
                    );
                    println!("<br>");
                }
            }
        }
        Err(e) => match e {
            RadioCodeCalculatorError::ApiError(ref v) => {
                if v["error"].as_i64() == Some(RadioErrors::INVALID_LICENSE as i64) {
                    println!("Invalid license key!");
                } else {
                    println!("Something unexpected happen while trying to login to the service (error code {v:?}).");
                }
            },
            RadioCodeCalculatorError::InvalidLicense => println!("Invalid license key!"),
            RadioCodeCalculatorError::Transport(msg) => println!("Connection error: {msg}"),
        },
    }
}
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v.1.0.0
 * Language     : C#
 * Dependencies : RadioCodeCalculator (NuGet / project reference)
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

var myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

try
{
    var (radioModels, _) = await myRadioCodeCalculator.ListAsync();

    Console.WriteLine("Supported radio models " + radioModels.Count + "<br>");

    foreach (var radio_model in radioModels)
    {
        Console.WriteLine("Radio model name - " + radio_model.Name + "<br>");

        Console.WriteLine("Max. length of the radio serial number - " + radio_model.SerialMaxLen + "<br>");
        Console.WriteLine("Regex pattern for the radio serial number - " + radio_model.SerialRegexPattern() + "<br>");

        if (radio_model.ExtraMaxLen > 0)
        {
            Console.WriteLine("Max. length of the radio extra data - " + radio_model.ExtraMaxLen + "<br>");
            Console.WriteLine("Regex pattern for the radio extra data - " + radio_model.ExtraRegexPattern() + "<br>");
            Console.WriteLine("<br>");
        }
    }
}
catch (RadioApiException ex)
{
    if (ex.ErrorCode == RadioErrors.InvalidLicense)
        Console.WriteLine("Invalid license key!");
    else
        Console.WriteLine($"Something unexpected happen while trying to login to the service (error code {ex.ErrorCode}).");
}
/******************************************************************************
 * Radio Code Calculator API usage example.
 *
 * Download the list of supported radio code calculators.
 *
 * Version      : v1.1.6
 * Language     : Go
 * Author       : Bartosz Wójcik
 * Homepage     : https://www.pelock.com
 *
 *****************************************************************************/

package main

import (
	"context"
	"fmt"
	"os"

	radiocodecalculator "github.com/PELock/Radio-Code-Calculator-Go"
)

func main() {
	client := radiocodecalculator.New("ABCD-ABCD-ABCD-ABCD")
	errCode, models, err := client.List(context.Background())
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	if errCode == radiocodecalculator.ErrorInvalidLicense {
		fmt.Println("Invalid license key!")
		os.Exit(1)
	}
	if errCode != radiocodecalculator.ErrorSuccess {
		fmt.Printf("Something unexpected happen while trying to talk to the service (error code %d).\n", errCode)
		os.Exit(1)
	}
	fmt.Printf("Supported radio models %d\n", len(models))
	for _, m := range models {
		fmt.Printf("Radio model name - %s\n", m.Name)
		fmt.Printf("Max. length of the radio serial number - %d\n", m.SerialMaxLen)
		fmt.Printf("Regex pattern for the radio serial number - %s\n", m.SerialRegexPattern())
		if m.ExtraMaxLen > 0 {
			fmt.Printf("Max. length of the radio extra data - %d\n", m.ExtraMaxLen)
			fmt.Printf("Regex pattern for the radio extra data - %s\n", m.ExtraRegexPattern())
		}
	}
}
/******************************************************************************
 * Radio Code Calculator API - WebApi interface usage example
 *
 * Download the list of supported radio code calculators.
 *
 * Version        : v1.1.6
 * Language       : Java
 * Author         : Bartosz Wójcik
 * Web page       : https://www.pelock.com
 *
 *****************************************************************************/

import com.pelock.radiocode.RadioApiResult;
import com.pelock.radiocode.RadioCodeCalculator;
import com.pelock.radiocode.RadioErrors;
import com.pelock.radiocode.RadioModel;

public class RadioCodeCalculatorList {

  public static void main(String[] args) throws Exception {
    RadioCodeCalculator client = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");
    RadioApiResult result = client.list();

    if (result.getError() == RadioErrors.INVALID_LICENSE) {
      System.out.println("Invalid license key!");
      return;
    }
    if (result.getError() != RadioErrors.SUCCESS) {
      System.out.println("Something unexpected happen while trying to talk to the service (error code " + result.getError() + ").");
      return;
    }

    System.out.println("Supported radio models " + result.getModels().size());
    for (RadioModel radioModel : result.getModels()) {
      System.out.println("Radio model name - " + radioModel.name);
      System.out.println("Max. length of the radio serial number - " + radioModel.serialMaxLen);
      System.out.println("Regex pattern for the radio serial number - " + radioModel.serialRegexPattern());
      if (radioModel.extraMaxLen > 0) {
        System.out.println("Max. length of the radio extra data - " + radioModel.extraMaxLen);
        System.out.println("Regex pattern for the radio extra data - " + radioModel.extraRegexPattern());
      }
    }
  }
}
################################################################################
#
# Radio Code Calculator WebApi interface usage example.
#
# List supported radio calculators.
#
# Version        : v1.0.0
# Language       : PowerShell
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
################################################################################

using module RadioCodeCalculator

$myRadioCodeCalculator = New-RadioCodeCalculator -ApiKey 'ABCD-ABCD-ABCD-ABCD'
$apiError, $radioModels = $myRadioCodeCalculator.List()

if ($apiError -eq [RadioErrors]::SUCCESS) {
    Write-Host ("Supported radio models {0}" -f $radioModels.Count)
    foreach ($radioModel in $radioModels) {
        Write-Host ("Radio model name - {0}" -f $radioModel.name)
        Write-Host ("Max. length of the radio serial number - {0}" -f $radioModel.serial_max_len)
        Write-Host ("Regex pattern for the radio serial number - {0}" -f $radioModel.serial_regex_pattern())
        if ($radioModel.extra_max_len -gt 0) {
            Write-Host ("Max. length of the radio extra data - {0}" -f $radioModel.extra_max_len)
            Write-Host ("Regex pattern for the radio extra data - {0}" -f $radioModel.extra_regex_pattern())
        }
    }
}
elseif ($apiError -eq [RadioErrors]::INVALID_LICENSE) {
    Write-Host 'Invalid license key!'
}
else {
    Write-Host ("Something unexpected happen while trying to talk to the service (error code {0})." -f $apiError)
}
# frozen_string_literal: true

###############################################################################
#
# Radio Code Calculator — list models
#
# Version        : v1.1.6
# Language       : Ruby
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
###############################################################################

require "radio-code-calculator"

error, models = RadioCodeCalculator.new("ABCD-ABCD-ABCD-ABCD").list
if error == RadioErrors::SUCCESS
  puts "Supported radio models #{models.length}"
  models.each do |m|
    puts "Radio model name - #{m.name}"
    puts "Max. length of the radio serial number - #{m.serial_max_len}"
    puts "Regex pattern for the radio serial number - #{m.serial_regex_pattern}"
    if m.extra_max_len.positive?
      puts "Max. length of the radio extra data - #{m.extra_max_len}"
      puts "Regex pattern for the radio extra data - #{m.extra_regex_pattern}"
    end
  end
elsif error == RadioErrors::INVALID_LICENSE
  warn "Invalid license key!"
else
  warn "Something unexpected happen while trying to talk to the service (error code #{error})."
end

Pobieranie parametrów wybranego kalkulatora radiowego

Możliwe jest pobranie parametrów wybranego kalkulatora

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v1.1.5
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// query information about the radio model
//
list($error, $radio_model) = $myRadioCodeCalculator->info("ford-m-series");

if ($error === RadioErrors::SUCCESS)
{
	echo "Radio model name - " . $radio_model->name . "<br>";

	echo "Max. length of the radio serial number - " . $radio_model->serial_max_len . "<br>";
	echo "Regex pattern for the radio serial number - " . $radio_model->serial_regex_pattern() . "<br>";

	// is extra field specified?
	if ($radio_model->extra_max_len > 0)
	{
		echo "Max. length of the radio extra data - " . $radio_model->extra_max_len . "<br>";
		echo "Regex pattern for the radio extra data - " . $radio_model->extra_regex_pattern() . "<br>";
		echo "<br>";
	}
}
elseif ($error == RadioErrors::INVALID_LICENSE)
    echo "Invalid license key!";
else
    echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to get information about the
# specific radio calculator and its parameters (max. length & regex pattern).
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# query information about the radio model
#
error, radioModel = myRadioCodeCalculator.info("ford-m-series")

if error == RadioErrors.SUCCESS:

    print(f'Radio model name - {radioModel.name}')

    print(f'Max. length of the radio serial number - {radioModel.serial_max_len}')
    print(f'Regex pattern for the radio serial number - {radioModel.serial_regex_pattern}')

    # is extra field specified?
    if radioModel.extra_max_len > 0:
        print(f'Max. length of the radio extra data - {radioModel.extra_max_len}')
        print(f'Regex pattern for the radio extra data - {radioModel.extra_regex_pattern}')

    print()

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v1.1.5
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// query information about the radio model
//
myRadioCodeCalculator.info("ford-m-series").then((result) => {

    let radio_model = result["radioModel"];

    console.log("Radio model name - " + radio_model.name + "<br>");

    console.log("Max. length of the radio serial number - " + radio_model.serial_max_len + "<br>");
    console.log("Regex pattern for the radio serial number - " + radio_model.serial_regex_pattern() + "<br>");

    // is extra field specified?
    if (radio_model.extra_max_len > 0)
    {
        console.log("Max. length of the radio extra data - " + radio_model.extra_max_len + "<br>");
        console.log("Regex pattern for the radio extra data - " + radio_model.extra_regex_pattern() + "<br>");
        console.log("<br>");
    }

}).catch((error) => {
    if (error.error == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error["error"]}).`);
});
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v1.0.0
 * Rust         : 2021
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2026 PELock LLC
 * @license Apache-2.0
 *
 *****************************************************************************/

//
// include Radio Code Calculator API module
//
use radio_code_calculator::{RadioCodeCalculator, RadioCodeCalculatorError, RadioErrors};

#[tokio::main]
async fn main() {
    //
    // create Radio Code Calculator API class instance (we are using our activation key)
    //
    let my_radio_code_calculator =
        RadioCodeCalculator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));

    //
    // query information about the radio model
    //
    match my_radio_code_calculator.info("ford-m-series").await {
        Ok(info) => {
            let radio_model = &info.radio_model;

            println!("Radio model name - {}<br>", radio_model.name);

            println!(
                "Max. length of the radio serial number - {}<br>",
                radio_model.serial_max_len
            );
            println!(
                "Regex pattern for the radio serial number - {}<br>",
                radio_model.serial_regex_pattern()
            );

            // is extra field specified?
            if radio_model.extra_max_len > 0 {
                println!(
                    "Max. length of the radio extra data - {}<br>",
                    radio_model.extra_max_len
                );
                println!(
                    "Regex pattern for the radio extra data - {:?}<br>",
                    radio_model.extra_regex_pattern()
                );
                println!("<br>");
            }
        }
        Err(e) => match e {
            RadioCodeCalculatorError::ApiError(v) => {
                if v["error"].as_i64() == Some(RadioErrors::INVALID_LICENSE as i64) {
                    println!("Invalid license key!");
                } else {
                    println!(
                        "Something unexpected happen while trying to login to the service (error code {:?}).",
                        v["error"]
                    );
                }
            },
            RadioCodeCalculatorError::InvalidLicense => println!("Invalid license key!"),
            RadioCodeCalculatorError::Transport(msg) => println!("Connection error: {msg}"),
        },
    }
}
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v.1.0.0
 * Language     : C#
 * Dependencies : RadioCodeCalculator (NuGet / project reference)
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

var myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

try
{
    var (radio_model, _) = await myRadioCodeCalculator.InfoAsync("ford-m-series");

    Console.WriteLine("Radio model name - " + radio_model.Name + "<br>");

    Console.WriteLine("Max. length of the radio serial number - " + radio_model.SerialMaxLen + "<br>");
    Console.WriteLine("Regex pattern for the radio serial number - " + radio_model.SerialRegexPattern() + "<br>");

    if (radio_model.ExtraMaxLen > 0)
    {
        Console.WriteLine("Max. length of the radio extra data - " + radio_model.ExtraMaxLen + "<br>");
        Console.WriteLine("Regex pattern for the radio extra data - " + radio_model.ExtraRegexPattern() + "<br>");
        Console.WriteLine("<br>");
    }
}
catch (RadioApiException ex)
{
    if (ex.ErrorCode == RadioErrors.InvalidLicense)
        Console.WriteLine("Invalid license key!");
    else
        Console.WriteLine($"Something unexpected happen while trying to login to the service (error code {ex.ErrorCode}).");
}
/******************************************************************************
 * Radio Code Calculator API usage example.
 *
 * Download the parameters of the selected radio calculator.
 *
 * Version      : v1.1.6
 * Language     : Go
 * Author       : Bartosz Wójcik
 * Homepage     : https://www.pelock.com
 *
 *****************************************************************************/

package main

import (
	"context"
	"fmt"
	"os"

	radiocodecalculator "github.com/PELock/Radio-Code-Calculator-Go"
)

func main() {
	client := radiocodecalculator.New("ABCD-ABCD-ABCD-ABCD")
	errCode, model, err := client.Info(context.Background(), "ford-m-series")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	switch errCode {
	case radiocodecalculator.ErrorSuccess:
		fmt.Printf("Radio model name - %s\n", model.Name)
		fmt.Printf("Max. length of the radio serial number - %d\n", model.SerialMaxLen)
		fmt.Printf("Regex pattern for the radio serial number - %s\n", model.SerialRegexPattern())
		if model.ExtraMaxLen > 0 {
			fmt.Printf("Max. length of the radio extra data - %d\n", model.ExtraMaxLen)
			fmt.Printf("Regex pattern for the radio extra data - %s\n", model.ExtraRegexPattern())
		}
	case radiocodecalculator.ErrorInvalidLicense:
		fmt.Println("Invalid license key!")
	default:
		fmt.Printf("Something unexpected happen while trying to login to the service (error code %d).\n", errCode)
	}
}
/******************************************************************************
 * Radio Code Calculator API - WebApi interface usage example
 *
 * Download the parameters of the selected radio calculator.
 *
 * Version        : v1.1.6
 * Language       : Java
 * Author         : Bartosz Wójcik
 * Web page       : https://www.pelock.com
 *
 *****************************************************************************/

import com.pelock.radiocode.RadioApiResult;
import com.pelock.radiocode.RadioCodeCalculator;
import com.pelock.radiocode.RadioErrors;
import com.pelock.radiocode.RadioModel;

public class RadioCodeCalculatorInfo {

  public static void main(String[] args) throws Exception {
    RadioCodeCalculator client = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");
    RadioApiResult result = client.info("ford-m-series");

    if (result.getError() == RadioErrors.SUCCESS) {
      RadioModel radioModel = result.getModel();
      System.out.println("Radio model name - " + radioModel.name);
      System.out.println("Max. length of the radio serial number - " + radioModel.serialMaxLen);
      System.out.println("Regex pattern for the radio serial number - " + radioModel.serialRegexPattern());
      if (radioModel.extraMaxLen > 0) {
        System.out.println("Max. length of the radio extra data - " + radioModel.extraMaxLen);
        System.out.println("Regex pattern for the radio extra data - " + radioModel.extraRegexPattern());
      }
    } else if (result.getError() == RadioErrors.INVALID_LICENSE) {
      System.out.println("Invalid license key!");
    } else {
      System.out.println("Something unexpected happen while trying to login to the service (error code " + result.getError() + ").");
    }
  }
}
################################################################################
#
# Radio Code Calculator WebApi interface usage example.
#
# Download the parameters of the selected radio calculator.
#
# Version        : v1.0.0
# Language       : PowerShell
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
################################################################################

using module RadioCodeCalculator

$myRadioCodeCalculator = New-RadioCodeCalculator -ApiKey 'ABCD-ABCD-ABCD-ABCD'
$apiError, $radioModel = $myRadioCodeCalculator.Info('ford-m-series')

if ($apiError -eq [RadioErrors]::SUCCESS) {
    Write-Host ("Radio model name - {0}" -f $radioModel.name)
    Write-Host ("Max. length of the radio serial number - {0}" -f $radioModel.serial_max_len)
    Write-Host ("Regex pattern for the radio serial number - {0}" -f $radioModel.serial_regex_pattern())
    if ($radioModel.extra_max_len -gt 0) {
        Write-Host ("Max. length of the radio extra data - {0}" -f $radioModel.extra_max_len)
        Write-Host ("Regex pattern for the radio extra data - {0}" -f $radioModel.extra_regex_pattern())
    }
}
elseif ($apiError -eq [RadioErrors]::INVALID_LICENSE) {
    Write-Host 'Invalid license key!'
}
else {
    Write-Host ("Something unexpected happen while trying to login to the service (error code {0})." -f $apiError)
}
# frozen_string_literal: true

###############################################################################
#
# Radio Code Calculator — calculator parameters
#
# Version        : v1.1.6
# Language       : Ruby
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
###############################################################################

require "radio-code-calculator"

error, radio_model = RadioCodeCalculator.new("ABCD-ABCD-ABCD-ABCD").info("ford-m-series")
if error == RadioErrors::SUCCESS
  puts "Radio model name - #{radio_model.name}"
  puts "Max. length of the radio serial number - #{radio_model.serial_max_len}"
  puts "Regex pattern for the radio serial number - #{radio_model.serial_regex_pattern}"
  if radio_model.extra_max_len.positive?
    puts "Max. length of the radio extra data - #{radio_model.extra_max_len}"
    puts "Regex pattern for the radio extra data - #{radio_model.extra_regex_pattern}"
  end
elsif error == RadioErrors::INVALID_LICENSE
  warn "Invalid license key!"
else
  warn "Something unexpected happen while trying to login to the service (error code #{error})."
end

Sprawdzanie klucza aktywacyjnego

Sprawdzając status klucza aktywacyjnego, uzyskamy informacje o właścicielu licencji, jej typie oraz dacie wygaśnięcia licencji.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.1.5
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// login to the service
//
list($error, $result) = $myRadioCodeCalculator->login();

//
// result[] array holds the information about the license
//
// result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
// result["license"]["userName"] - user name/company name of the license owner
// result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
// result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
//
if ($error == RadioErrors::SUCCESS)
{
    echo "License activation status - " . ($result["license"]["activationStatus"] ? "True" : "False") . "<br>";
    echo "License owner - " . $result["license"]["userName"];
    echo "License type - " . ($result["license"]["type"] == 0 ? "Personal" : "Company") . "<br>";
    echo "Expiration date - " . $result["license"]["expirationDate"] . "<br>";
}
else if ($error == RadioErrors::INVALID_LICENSE)
    echo "Invalid license key!";
else
    echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example we will verify our activation key status.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# login to the service
#
error, result = myRadioCodeCalculator.login()

#
# result[] array holds the information about the license
#
# result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
# result["license"]["userName"] - user name/company name of the license owner
# result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
# result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
#
if error == RadioErrors.SUCCESS:
    print(f'License activation status - {"True" if result["license"]["activationStatus"] else "False"}')
    print(f'License owner - {result["license"]["userName"]}')
    print(f'License type - {"Personal" if result["license"]["type"] == 0 else "Company"}')
    print(f'Expiration date - {result["license"]["expirationDate"]}')

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.1.5
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// login to the service
//
myRadioCodeCalculator.login().then((result) => {

    //
    // result[] array holds the information about the license
    //
    // result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
    // result["license"]["userName"] - user name/company name of the license owner
    // result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
    // result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
    //
    console.log("License activation status - " + (result["license"]["activationStatus"] ? "True" : "False") + "<br>");
    console.log("License owner - " + result["license"]["userName"]);
    console.log("License type - " + (result["license"]["type"] == 0 ? "Personal" : "Company") + "<br>");
    console.log("Expiration date - " + result["license"]["expirationDate"] + "<br>");

}).catch((error) => {

    if (error["error"] == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`);
});
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.0.0
 * Rust         : 2021
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2026 PELock LLC
 * @license Apache-2.0
 *
 *****************************************************************************/

//
// include Radio Code Calculator API module
//
use radio_code_calculator::{RadioCodeCalculator, RadioCodeCalculatorError, RadioErrors};

#[tokio::main]
async fn main() {
    //
    // create Radio Code Calculator API class instance (we are using our activation key)
    //
    let my_radio_code_calculator =
        RadioCodeCalculator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));

    //
    // login to the service
    //
    match my_radio_code_calculator.login().await {
        Ok(result) => {
            //
            // result[] array holds the information about the license
            //
            // result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
            // result["license"]["userName"] - user name/company name of the license owner
            // result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
            // result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
            //
            let license = &result["license"];
            println!(
                "License activation status - {}<br>",
                if license["activationStatus"].as_bool().unwrap_or(false) {
                    "True"
                } else {
                    "False"
                }
            );
            println!("License owner - {}", license["userName"]);
            println!(
                "License type - {}<br>",
                if license["type"].as_i64() == Some(0) {
                    "Personal"
                } else {
                    "Company"
                }
            );
            println!(
                "Expiration date - {}<br>",
                license["expirationDate"]
            );
        }
        Err(e) => match e {
            RadioCodeCalculatorError::ApiError(ref v) => {
                if v["error"].as_i64() == Some(RadioErrors::INVALID_LICENSE as i64) {
                    println!("Invalid license key!");
                } else {
                    println!("Something unexpected happen while trying to login to the service (error code {v:?}).");
                }
            },
            RadioCodeCalculatorError::InvalidLicense => println!("Invalid license key!"),
            RadioCodeCalculatorError::Transport(msg) => println!("Connection error: {msg}"),
        },
    }
}
/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v.1.0.0
 * Language     : C#
 * Dependencies : RadioCodeCalculator (NuGet / project reference)
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2024 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

var myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

try
{
    var result = await myRadioCodeCalculator.LoginAsync();

    //
    // result holds the information about the license
    //
    // result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
    // result["license"]["userName"] - user name/company name of the license owner
    // result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
    // result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
    //
    var license = result["license"];
    var activation = license?["activationStatus"]?.GetValue<bool>() ?? false;
    var type = license?["type"]?.GetValue<int>() ?? 0;

    Console.WriteLine("License activation status - " + (activation ? "True" : "False") + "<br>");
    Console.WriteLine("License owner - " + license?["userName"]?.ToString());
    Console.WriteLine("License type - " + (type == 0 ? "Personal" : "Company") + "<br>");
    Console.WriteLine("Expiration date - " + license?["expirationDate"]?.ToString() + "<br>");
}
catch (RadioApiException ex)
{
    if (ex.ErrorCode == RadioErrors.InvalidLicense)
        Console.WriteLine("Invalid license key!");
    else
        Console.WriteLine($"Something unexpected happen while trying to login to the service (error code {ex.ErrorCode}).");
}
/******************************************************************************
 * Radio Code Calculator API usage example.
 *
 * Checking activation key.
 *
 * Version      : v1.1.6
 * Language     : Go
 * Author       : Bartosz Wójcik
 * Homepage     : https://www.pelock.com
 *
 *****************************************************************************/

package main

import (
	"context"
	"fmt"
	"os"

	radiocodecalculator "github.com/PELock/Radio-Code-Calculator-Go"
)

func main() {
	client := radiocodecalculator.New("ABCD-ABCD-ABCD-ABCD")
	errCode, result, err := client.Login(context.Background())
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	if errCode == radiocodecalculator.ErrorInvalidLicense {
		fmt.Println("Invalid license key!")
		os.Exit(1)
	}
	if errCode != radiocodecalculator.ErrorSuccess {
		fmt.Printf("Something unexpected happen while trying to login to the service (error code %d).\n", errCode)
		os.Exit(1)
	}
	license, _ := result["license"].(map[string]any)
	fmt.Println("License activation status -", license["activationStatus"])
	fmt.Println("License owner -", license["userName"])
	fmt.Println("License type -", license["type"])
	fmt.Println("Expiration date -", license["expirationDate"])
}
/******************************************************************************
 * Radio Code Calculator API - WebApi interface usage example
 *
 * Checking activation key.
 *
 * Version        : v1.1.6
 * Language       : Java
 * Author         : Bartosz Wójcik
 * Web page       : https://www.pelock.com
 *
 *****************************************************************************/

import com.fasterxml.jackson.databind.JsonNode;
import com.pelock.radiocode.RadioApiResult;
import com.pelock.radiocode.RadioCodeCalculator;
import com.pelock.radiocode.RadioErrors;

public class RadioCodeCalculatorLogin {

  public static void main(String[] args) throws Exception {
    RadioCodeCalculator client = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");
    RadioApiResult result = client.login();

    if (result.getError() == RadioErrors.SUCCESS) {
      JsonNode license = result.getBody().path("license");
      System.out.println("License activation status - " + license.path("activationStatus").asText());
      System.out.println("License owner - " + license.path("userName").asText());
      System.out.println("License type - " + license.path("type").asText());
      System.out.println("Expiration date - " + license.path("expirationDate").asText());
    } else if (result.getError() == RadioErrors.INVALID_LICENSE) {
      System.out.println("Invalid license key!");
    } else {
      System.out.println("Something unexpected happen while trying to login to the service (error code " + result.getError() + ").");
    }
  }
}
################################################################################
#
# Radio Code Calculator WebApi interface usage example.
#
# Verify activation key status.
#
# Version        : v1.0.0
# Language       : PowerShell
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
################################################################################

using module RadioCodeCalculator

$myRadioCodeCalculator = New-RadioCodeCalculator -ApiKey 'ABCD-ABCD-ABCD-ABCD'
$apiError, $result = $myRadioCodeCalculator.Login()

if ($apiError -eq [RadioErrors]::SUCCESS) {
    $active = if ($result.license.activationStatus) { 'True' } else { 'False' }
    $type = if ($result.license.type -eq 0) { 'Personal' } else { 'Company' }
    Write-Host ("License activation status - {0}" -f $active)
    Write-Host ("License owner - {0}" -f $result.license.userName)
    Write-Host ("License type - {0}" -f $type)
    Write-Host ("Expiration date - {0}" -f $result.license.expirationDate)
}
elseif ($apiError -eq [RadioErrors]::INVALID_LICENSE) {
    Write-Host 'Invalid license key!'
}
else {
    Write-Host ("Something unexpected happen while trying to login to the service (error code {0})." -f $apiError)
}
# frozen_string_literal: true

###############################################################################
#
# Radio Code Calculator — login
#
# Version        : v1.1.6
# Language       : Ruby
# Author         : Bartosz Wójcik
# Web page       : https://www.pelock.com
#
###############################################################################

require "radio-code-calculator"

error, result = RadioCodeCalculator.new("ABCD-ABCD-ABCD-ABCD").login
if error == RadioErrors::SUCCESS
  license = result["license"]
  puts "License activation status - #{license["activationStatus"]}"
  puts "License owner - #{license["userName"]}"
  puts "License type - #{license["type"]}"
  puts "Expiration date - #{license["expirationDate"]}"
elsif error == RadioErrors::INVALID_LICENSE
  warn "Invalid license key!"
else
  warn "Something unexpected happen while trying to login to the service (error code #{error})."
end

Masz pytania?

Jeśli masz jakieś pytania dotyczące Kalkulatora Kodów Do Radia oraz jego pakietów SDK, masz jakieś uwagi lub pytania dotyczące generowania kodów radiowych, albo coś jest niejasne, napisz do mnie, chętnie odpowiem na każde Twoje pytanie.