cfxmarkets / php-public-models
This package provides all of CFX's public data objects.
Requires
- php: >=5.4.0
- cfxmarkets/php-jsonapi-objects: ^1.4.10 | ^2.0.0
- cfxmarkets/php-persistence: ^0.4.3 || ^0.3.3 || ^0.5.0 || ^0.6.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.0.0
- phpunit/phpunit: >=4.8.0
- v1.x-dev
- v1.25.0
- v1.24.0
- v1.23.1
- v1.23.0
- v1.22.0
- v1.21.2
- v1.21.1
- v1.21.0
- v1.20.0
- v1.19.0
- v1.18.5
- v1.18.4
- v1.18.3
- v1.18.2
- v1.18.1
- v1.18.0
- v1.17.1
- v1.17.0
- v1.16.3
- v1.16.2
- v1.16.1
- v1.16.0
- v1.15.2
- v1.15.1
- v1.15.0
- v1.14.x-dev
- v1.14.0
- v1.13.0
- v1.12.3
- v1.12.2
- v1.12.1
- v1.12.0
- v1.11.x-dev
- v1.11.4
- v1.11.3
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.6
- v1.10.5
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.2-RC1
- v1.10.1
- v1.10.0
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.6.0-rc1
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.5.0-rc2
- v1.5.0-rc1
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2024-11-07 04:05:24 UTC
README
This library represents the current set of CFX's public PHP data models. This README will focus on the (very little) general business information surrounding the classes this library provides. For an in-depth discussion of each Resource class's business logic, see the API Docs. (You can view that document more easily by pasting its contents into the editor at http://editor.swagger.io.) For an in-depth discussion of CFX's data model implementation, see php-jsonapi-objects and php-persistence.
Installation
This library can be installed using the standard composer process:
composer require cfxmarkets/php-public-models
Overview
Currently, there are two primary data domains that CFX operates in: The Brokerage Domain and the Exchange Domain.
The Brokerage Domain encapsulates objects and operations related to the CFX brokerage house. This includes Users, LegalEntities, OrderIntents, Orders, Addresses, BankAccounts, Assets, AssetIntents, DealRooms, TenderRooms, Tenders, and others. In short, any data that concerns a brokerage will be found in the Brokerage Domain.
The Exchange Domain encapsulates objects and operations related to the CFX exchange. This includes Brokerages, Orders, Assets, and Transactions. (Most of these are currently unimplemented at the time of this writing.)
Usage
Most of the important information in this library exists at the class level. That is, what you'll really want to learn about is 1) what classes exist; and 2) how you can use them. You can get this information most easily by simply browsing the classes themselves. However, if you haven't already, you may want to take a minute and familiarize yourself with the style in which this library was meant to be used, detailed in the following paragraphs and examples.
In general, the classes in this library rely on getters and setters to manipulate their data. They also include a few common update and persistence operations, namely updateFromData
, updateFromResource
, save
, initialize
, and refresh
. You can use these methods (and a few others) on all of CFX's public model classes because these are part of the underlying ResourceInterface
on which our resource objects are based.
Thus, following is a common example of how you might end up using these objects. Assume $cfx
is the CFX Brokerage Client from the php-brokerage-sdk
library.
$user = $cfx->users->get("id=abc123"); $name = $user->getName(); $street1 = $user->getAddress()->getStreet1(); $street2 = $user->getAddress()->getStreet2(); $city = $user->getAddress()->getCity(); $state = $user->getAddress()->getState(); $country = $user->getAddress()->getCountry(); $zip = $user->getAddress()->getZip(); $orderIntent = $cfx->orderIntents->create() ->setType('sell') ->setPriceHigh(2.50) ->setPriceLow(2.10) ->setAsset($cfx->assets->get("id=INVT001")) ->setAssetOwner($user->getPersonEntity()) ->setBankAccount($user->getBankAccounts()[0]) ; // (This is future functionality not implemented at the time of this writing) if ($user->isAtLeast('financial-advisor')) { $orderIntent->setReferralKey($user->getId()); } $orderIntent->save(); ....
Notice here that the majority of these calls are simple getters and setters. The one call that is not (User::isAtLeast
) is not yet implemented, but is a good example of what sorts of functionality might be introduced by non-setter/getter methods.
Beyond that, there's not too much more to point out. From here, you should study up on the API Docs, as mentioned, and start writing code!
Note About API Documentation
We're hoping to launch a site (developers.cfxtrading.com) soon that will allow us to provide more comprehensive API documentation and other resources for developers. While this site is not live yet, you can still generate good API documentation for this library by cloning the library, installing Sami, and running sami.phar update sami.config.php
.