GSMService.pl
INTERFEJS REST API DLA PROGRAMISTÓW - BIBLIOTEKI SDK
W celu ułatwienia procesu integracji dowolnej aplikacji/systemu z Bramką SMS za pośrednictwem REST API, przygotowaliśmy gotowe biblioteki w najpopularniejszych językach programowania.

Biblioteka SDK dla PHP (ver. ≥ 8.2)

Packagist Version License

Instalacja:

                                    composer require "gsmservice-pl/messaging-sdk-php"
                                

Przykłady użycia:

												
declare(strict_types=1);
require 'vendor/autoload.php';

use Gsmservice\Gateway;
use Gsmservice\Gateway\Models\Components;

$security = '<YOUR API ACCESS TOKEN>';

$sdk = Gateway\Client::builder()->setSecurity($security)->build();

$request = new Components\SmsMessage(
		recipients: '+48999999999',
		message: 'To jest treść wiadomości',
		sender: 'Bramka SMS',
		type: Components\SmsType::SmsPro,
		unicode: true,
	);

$response = $sdk->outgoing->sms->send(
	request: $request
);

if ($response->messages !== null) {
	// handle response
}
												
											
												
declare(strict_types=1);
require 'vendor/autoload.php';

use Gsmservice\Gateway;

$security = '<YOUR API ACCESS TOKEN>';

$sdk = Gateway\Client::builder()->setSecurity($security)->build();

$response = $sdk->outgoing->getByIds(
    ids: [
        43456,
    ]
);

if ($response->messages !== null) {
    // handle response
}
												
											
												
declare(strict_types=1);
require 'vendor/autoload.php';

use Gsmservice\Gateway;
use Gsmservice\Gateway\Models\Components;

$security = '<YOUR API ACCESS TOKEN>';

$sdk = Gateway\Client::builder()->setSecurity($security)->build();

$request = [
    new Components\SmsMessage(
        recipients: new Components\PhoneNumberWithCid(
            nr: '+48999999999',
            cid: 'my-id-1113',
        ),
        message: 'To jest treść wiadomości',
        sender: 'Bramka SMS',
        type: Components\SmsType::SmsPro,
        unicode: true,
    ),
];

$response = $sdk->outgoing->sms->getPrice(
    request: $request
);

if ($response->prices !== null) {
    // handle response
}
												
											
												
declare(strict_types=1);
require 'vendor/autoload.php';

use Gsmservice\Gateway;

$security = '<YOUR API ACCESS TOKEN>';

$sdk = Gateway\Client::builder()->setSecurity($security)->build();

$response = $sdk->accounts->get();

if ($response->accountResponse !== null) {
    // handle response
}
												
											

Instalacja:

                                npm add @gsmservice-pl/messaging-sdk-typescript
                            

Przykłady użycia:

												
import { Client } from "@gsmservice-pl/messaging-sdk-typescript";

const client = new Client({
  bearer: process.env["GATEWAY_API_BEARER"] ?? "",
});

async function run() {
  const result = await client.outgoing.sms.send(
    {
      recipients: "+48999999999",
      message: "To jest treść wiadomości",
      sender: "Bramka SMS",
      type: 1,
      unicode: true,
    },
  );

  // Handle the result
  console.log(result);
}
												
											
												
import { Client } from "@gsmservice-pl/messaging-sdk-typescript";

const client = new Client({
  bearer: process.env["GATEWAY_API_BEARER"] ?? "",
});

async function run() {
  const result = await client.outgoing.getByIds({
    ids: [
      43456,
    ],
  });

  // Handle the result
  console.log(result);
}

run();
												
											
												
import { Client } from "@gsmservice-pl/messaging-sdk-typescript";

const client = new Client({
  bearer: process.env["GATEWAY_API_BEARER"] ?? "",
});

async function run() {
  const result = await client.outgoing.sms.getPrice([
    {
      recipients: {
        nr: "+48999999999",
        cid: "my-id-1113",
      },
      message: "To jest treść wiadomości",
      sender: "Bramka SMS",
      type: 1,
      unicode: true,
    },
  ]);

  // Handle the result
  console.log(result);
}

run();
												
											
												
import { Client } from "@gsmservice-pl/messaging-sdk-typescript";

const client = new Client({
  bearer: process.env["GATEWAY_API_BEARER"] ?? "",
});

async function run() {
  const result = await client.accounts.get();

  // Handle the result
  console.log(result);
}

run();
												
											

Instalacja:

									pip install gsmservice-gateway
								

Przykłady użycia:

												
# Synchronous Example
from gsmservice_gateway import Client
import os

s = Client(
    bearer=os.getenv("GATEWAY_API_BEARER", ""),
)

res = s.outgoing.sms.send(request={
        "recipients": +48999999999",
        "message": "To jest treść wiadomości",
        "sender": "Bramka SMS",
        "type": 1,
        "unicode": True,
        "flash": False,
        "date_": None,
    },
)

if res is not None:
    # handle response
    pass
												
											
												
from gsmservice_gateway import Client
import os

s = Client(
    bearer=os.getenv("GATEWAY_API_BEARER", ""),
)

res = s.outgoing.get_by_ids(ids=[
    43456,
])

if res is not None:
    # handle response
    pass
												
											
												
from gsmservice_gateway import Client
import os

s = Client(
    bearer=os.getenv("GATEWAY_API_BEARER", ""),
)

res = s.outgoing.sms.get_price(request=[
    {
        "recipients": {
            "nr": "+48999999999",
            "cid": "my-id-1113",
        },
        "message": "To jest treść wiadomości",
        "sender": "Bramka SMS",
        "type": 1,
        "unicode": True,
    },
])

if res is not None:
    # handle response
    pass
												
											
												
from gsmservice_gateway import Client
import os

s = Client(
    bearer=os.getenv("GATEWAY_API_BEARER", ""),
)

res = s.accounts.get()

if res is not None:
    # handle response
    pass
												
											

Instalacja:

									dotnet add package Gsmservice.Gateway
								

Przykłady użycia:

												
using Gsmservice.Gateway;
using Gsmservice.Gateway.Models.Requests;
using Gsmservice.Gateway.Models.Components;
using System.Collections.Generic;

var sdk = new Client(bearer: "<YOUR API ACCESS TOKEN>");

SendSmsRequestBody req = SendSmsRequestBody.CreateSmsMessage(
	new SmsMessage()
	{
		Recipients = Recipients.CreateStr("+48999999999"),
		Message = "To jest treść wiadomości",
		Sender = "Bramka SMS",
		Type = Gsmservice.Gateway.Models.Components.SmsType.SmsPro,
		Unicode = true,
	}
);

var res = await sdk.Outgoing.Sms.SendAsync(req);
// handle response
												
											
												
using Gsmservice.Gateway;
using Gsmservice.Gateway.Models.Requests;
using System.Collections.Generic;
using Gsmservice.Gateway.Models.Components;

var sdk = new Client(bearer: "<YOUR API ACCESS TOKEN>");

var res = await sdk.Outgoing.GetByIdsAsync(ids: new List<long>() {
    43456,
});

// handle response
												
											
												
using Gsmservice.Gateway;
using Gsmservice.Gateway.Models.Requests;
using Gsmservice.Gateway.Models.Components;
using System.Collections.Generic;

var sdk = new Client(bearer: "<YOUR API ACCESS TOKEN>");

GetSmsPriceRequestBody req = GetSmsPriceRequestBody.CreateArrayOfSmsMessage(
    new List<SmsMessage>() {
        new SmsMessage() {
            Recipients = Recipients.CreatePhoneNumberWithCid(
                new PhoneNumberWithCid() {
                    Nr = "+48999999999",
                    Cid = "my-id-1113",
                }
            ),
            Message = "To jest treść wiadomości",
            Sender = "Bramka SMS",
            Type = Gsmservice.Gateway.Models.Components.SmsType.SmsPro,
            Unicode = true,
        },
    }
);

var res = await sdk.Outgoing.Sms.GetPriceAsync(req);
// handle response
												
											
												
using Gsmservice.Gateway;
using Gsmservice.Gateway.Models.Components;

var sdk = new Client(bearer: "<YOUR API ACCESS TOKEN>");

var res = await sdk.Accounts.GetAsync();
// handle response
												
											

Instalacja (Gradle):

									implementation 'pl.gsmservice:gateway:1.0.1'
								

Przykłady użycia:

												
package hello.world;

import java.lang.Exception;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;
import pl.gsmservice.gateway.Client;
import pl.gsmservice.gateway.models.components.Recipients;
import pl.gsmservice.gateway.models.components.SmsMessage;
import pl.gsmservice.gateway.models.components.SmsType;
import pl.gsmservice.gateway.models.errors.ErrorResponse;
import pl.gsmservice.gateway.models.operations.SendSmsRequestBody;
import pl.gsmservice.gateway.models.operations.SendSmsResponse;

public class Application {
    public static void main(String[] args) throws ErrorResponse, Exception {

        Client sdk = Client.builder()
            .bearer("<YOUR API ACCESS TOKEN>")
            .build();

        SendSmsRequestBody req = SendSmsRequestBody.of(
			SmsMessage.builder()
				.recipients(Recipients.of("+48999999999"))
				.message("To jest treść wiadomości")
				.sender("Bramka SMS")
				.type(SmsType.SmsPro)
				.unicode(true)
				.build()
		);

        SendSmsResponse res = sdk.outgoing().sms().send()
			.request(req)
			.call();

        if (res.messages().isPresent()) {
            // handle response
        }
    }
}
												
											
												
package hello.world;

import java.lang.Exception;
import java.util.List;
import pl.gsmservice.gateway.Client;
import pl.gsmservice.gateway.models.errors.ErrorResponse;
import pl.gsmservice.gateway.models.operations.GetMessagesResponse;

public class Application {
    public static void main(String[] args) throws ErrorResponse, Exception {

        Client sdk = Client.builder()
			.bearer("<YOUR API ACCESS TOKEN>")
			.build();

        GetMessagesResponse res = sdk.outgoing().getByIds()
			.ids(
				List.of(43456L)
			)
			.call();

        if (res.messages().isPresent()) {
            // handle response
        }
    }
}
												
											
												
package hello.world;

import java.lang.Exception;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;
import pl.gsmservice.gateway.Client;
import pl.gsmservice.gateway.models.components.PhoneNumberWithCid;
import pl.gsmservice.gateway.models.components.Recipients;
import pl.gsmservice.gateway.models.components.SmsMessage;
import pl.gsmservice.gateway.models.components.SmsType;
import pl.gsmservice.gateway.models.errors.ErrorResponse;
import pl.gsmservice.gateway.models.operations.GetSmsPriceRequestBody;
import pl.gsmservice.gateway.models.operations.GetSmsPriceResponse;

public class Application {
    public static void main(String[] args) throws ErrorResponse, Exception {

        Client sdk = Client.builder()
			.bearer("<YOUR API ACCESS TOKEN>")
			.build();

        GetSmsPriceRequestBody req = GetSmsPriceRequestBody.of(List.of(
			SmsMessage.builder()
				.recipients(Recipients.of(PhoneNumberWithCid.builder()
					.nr("+48999999999")
					.cid("my-id-1113")
					.build()))
				.message("To jest treść wiadomości")
				.sender("Bramka SMS")
				.type(SmsType.SmsPro)
				.unicode(true)
				.build()));

        GetSmsPriceResponse res = sdk.outgoing().sms().getPrice()
			.request(req)
			.call();

        if (res.prices().isPresent()) {
            // handle response
        }
    }
}
												
											
												
package hello.world;

import java.lang.Exception;
import pl.gsmservice.gateway.Client;
import pl.gsmservice.gateway.models.errors.ErrorResponse;
import pl.gsmservice.gateway.models.operations.GetAccountDetailsResponse;

public class Application {
    public static void main(String[] args) throws ErrorResponse, Exception {

        Client sdk = Client.builder()
			.bearer("<YOUR API ACCESS TOKEN>")
			.build();

        GetAccountDetailsResponse res = sdk.accounts().get()
			.call();

        if (res.accountResponse().isPresent()) {
            // handle response
        }
    }
}
												
											

Instalacja:

									go get github.com/gsmservice-pl/messaging-sdk-go
								

Przykłady użycia:

												
package main

import (
	"context"
	messagingsdkgo "github.com/gsmservice-pl/messaging-sdk-go"
	"github.com/gsmservice-pl/messaging-sdk-go/models/components"
	"log"
	"os"
)

func main() {
	s := messagingsdkgo.New(
		messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")),
	)

	ctx := context.Background()
		res, err := s.Outgoing.Sms.Send(ctx, operations.CreateSendSmsRequestBodySmsMessage(
		components.SmsMessage{
			Recipients: components.CreateRecipientsStr("+48999999999"),
			Message:    "To jest treść wiadomości",
			Sender:     messagingsdkgo.String("Bramka SMS"),
			Type:       components.SmsTypeSmsPro.ToPointer(),
			Unicode:    messagingsdkgo.Bool(true),
		},
	))
	if err != nil {
		log.Fatal(err)
	}
	if res.Messages != nil {
		// handle response
	}
}
												
											
												
package main

import(
	"os"
	messagingsdkgo "github.com/gsmservice-pl/messaging-sdk-go"
	"context"
	"log"
)

func main() {
    s := messagingsdkgo.New(
        messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")),
    )

    ctx := context.Background()
    res, err := s.Outgoing.GetByIds(ctx, []int64{
        43456,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Messages != nil {
        // handle response
    }
}
												
											
												
package main

import(
	"os"
	messagingsdkgo "github.com/gsmservice-pl/messaging-sdk-go"
	"context"
	"github.com/gsmservice-pl/messaging-sdk-go/models/components"
	"log"
)

func main() {
    s := messagingsdkgo.New(
        messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")),
    )

    ctx := context.Background()
    res, err := s.Outgoing.Sms.GetPrice(ctx, operations.CreateGetSmsPriceRequestBodyArrayOfSmsMessage(
        []components.SmsMessage{
            components.SmsMessage{
                Recipients: components.CreateRecipientsPhoneNumberWithCid(
                    components.PhoneNumberWithCid{
                        Nr: "+48999999999",
                        Cid: messagingsdkgo.String("my-id-1113"),
                    },
                ),
                Message: "To jest treść wiadomości",
                Sender: messagingsdkgo.String("Bramka SMS"),
                Type: components.SmsTypeSmsPro.ToPointer(),
                Unicode: messagingsdkgo.Bool(true),
            },
        },
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.Prices != nil {
        // handle response
    }
}
												
											
												
package main

import(
	"os"
	messagingsdkgo "github.com/gsmservice-pl/messaging-sdk-go"
	"context"
	"log"
)

func main() {
    s := messagingsdkgo.New(
        messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")),
    )

    ctx := context.Background()
    res, err := s.Accounts.Get(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.AccountResponse != nil {
        // handle response
    }
}
												
											
Wszelkie znaki i nazwy firmowe zastrzeżone są przez ich wlaścicieli i zostały użyte wyłącznie w celach informacyjnych.
Dotpay
Płatności obsługuje: 
  • Twitter
  • Facebook
odwiedź nas na: