dfreudenberger / lemon-markets-client

php 8 client for the lemon.markets api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lemon.markets php client

This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be found here https://docs.lemon.markets/api-endpoints/.

The API is not yet stable, therefore the client is subject to change too.

The client encapsules the basic operations from the API and maps the various responses to strongly typed models.

Installation

Since the API is changing quite frequently there won't be released versions. For now, you need to depend on the master (or a specific commit).

composer require dfreudenberger/lemon-markets-client dev-master

Usage

Make sure your composer dependencies are available to your code.

require_once 'vendor/autoload.php';

Set up the TokenClient. The client performs the request against the authentication API to retrieve an access token, given your client-id and client-secret. On top of it you need to configure the TokenCache. Even though this wouldn't be necessary it will reduce the amount of authentication requests sent to a minimum.

$tokenClient = new TokenClient('YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');
$tokenCache = new TokenCache($tokenClient);

Last but not least, the client itself needs to be initiated.

$client = new LemonMarketsClient($tokenCache);

Examples

Place and activate an order

<?php
require_once 'vendor/autoload.php';

$tokenClient = new TokenClient('YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');
$tokenCache = new TokenCache($tokenClient);
$client = new LemonMarketsClient($tokenCache);

$placedOrder = $client->placeOrder(new PlaceOrderCommand(
    isin: 'US29786A1060',
    validUntil: strval(time() + 3600),
    side: PlaceOrderCommand::SIDE_BUY,
    quantity: 1
));
print_r($placedOrder);

$activation = $client->activateOrder($placedOrder->uuid);
print_r($activation);

๐Ÿค Contributing

  1. Fork it dfreudenberger/lemon-markets-client
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Running tests locally

Unit tests should exist for all critical parts of the code base. In order to run the test suite, just execute the following command in the root directory of the repository.

composer test

๐Ÿ“ License

This project is licensed under the MIT License.

About

php 8 client for the lemon.markets api


Languages

Language:PHP 100.0%