|
| 1 | +# OST PHP SDK |
| 2 | +The official [OST PHP SDK](https://dev.ost.com/). |
| 3 | + |
| 4 | +## Requirements |
| 5 | + |
| 6 | +To use this SDK, developers will need to: |
| 7 | +1. Sign-up on [https://kit.ost.com](https://kit.ost.com). |
| 8 | +2. Launch a branded token economy with the OST KIT Economy Planner. |
| 9 | +3. Obtain an API Key and API Secret from [https://kit.ost.com/developer-api-console](https://kit.ost.com/developer-api-console). |
| 10 | + |
| 11 | +## Documentation |
| 12 | + |
| 13 | +[https://dev.ost.com/](https://dev.ost.com/) |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Install Composer: |
| 18 | + |
| 19 | +```bash |
| 20 | +> curl -sS https://getcomposer.org/installer | php |
| 21 | +``` |
| 22 | + |
| 23 | +Install the latest stable version of the SDK: |
| 24 | + |
| 25 | +```bash |
| 26 | +> php composer.phar require ostdotcom/ost-sdk-php |
| 27 | +``` |
| 28 | + |
| 29 | +## Example Usage |
| 30 | + |
| 31 | +Require the Composer autoloader: |
| 32 | + |
| 33 | +```php |
| 34 | +require 'vendor/autoload.php'; |
| 35 | +``` |
| 36 | + |
| 37 | +Initialize the SDK object: |
| 38 | + |
| 39 | +```php |
| 40 | + |
| 41 | +$params = array(); |
| 42 | +$params['apiKey']=API_KEY; |
| 43 | +$params['apiSecret']=API_SECRET; |
| 44 | +$params['apiBaseUrl']='https://sandboxapi.ost.com/v1/'; |
| 45 | + |
| 46 | +$ostObj = new OSTSdk($params); |
| 47 | + |
| 48 | +``` |
| 49 | + |
| 50 | +### Users Module |
| 51 | + |
| 52 | +```php |
| 53 | +$userService = $ostObj->services->users; |
| 54 | +``` |
| 55 | + |
| 56 | +Create a new user: |
| 57 | + |
| 58 | +```php |
| 59 | +$createUserParams = array(); |
| 60 | +$createUserParams['name'] = 'Test'; |
| 61 | +$response = $userService->create($createUserParams)->wait(); |
| 62 | +var_dump($response); |
| 63 | +``` |
| 64 | + |
| 65 | +Edit an existing user: |
| 66 | + |
| 67 | +```php |
| 68 | +$editUserParams = array(); |
| 69 | +$editUserParams['name'] = 'Bob'; |
| 70 | +$editUserParams['id'] = '867a5ea0-d8c1-4137-9be1-39c4549969ed'; |
| 71 | +$response = $userService->edit($editUserParams)->wait(); |
| 72 | +var_dump($response); |
| 73 | +``` |
| 74 | + |
| 75 | +Get a user: |
| 76 | + |
| 77 | +```php |
| 78 | +$getUserParams = array(); |
| 79 | +$getUserParams['id'] = '7ac1da33-b1d2-4f03-b39c-fbac0f1e2b92'; |
| 80 | +$response = $userService->get($getUserParams)->wait(); |
| 81 | +var_dump($response); |
| 82 | +``` |
| 83 | + |
| 84 | +Get a list of users and other data: |
| 85 | + |
| 86 | +```php |
| 87 | +$listUserParams = array(); |
| 88 | +$listUserParams['page_no'] = '1'; |
| 89 | +$listUserParams['limit'] = '5'; |
| 90 | +$listUserParams['id'] = 'a3b87254-21b7-4eaf-a2be-c368fd65c7b6,fb8e284d-e9c4-4432-a78e-74766e206d73'; |
| 91 | +$response = $userService->getList($listUserParams)->wait(); |
| 92 | +var_dump($response); |
| 93 | +``` |
| 94 | + |
| 95 | +### Airdrops Module |
| 96 | + |
| 97 | +```php |
| 98 | +$airdropService = $ostObj->services->airdrops; |
| 99 | +``` |
| 100 | + |
| 101 | +Airdrop branded tokens to users: |
| 102 | + |
| 103 | +```php |
| 104 | +$airdropParams = array(); |
| 105 | +$airdropParams['airdropped'] = 'false'; |
| 106 | +$airdropParams['amount'] = '1'; |
| 107 | +$airdropParams['user_ids'] = 'f87346e4-61f6-4d55-8cb8-234c65437b01'; |
| 108 | +$response = $airdropService->execute($airdropParams)->wait(); |
| 109 | +var_dump($response); |
| 110 | +``` |
| 111 | + |
| 112 | +Get Airdrop Status: |
| 113 | + |
| 114 | +```php |
| 115 | +$getairdropStatusParams = array(); |
| 116 | +$getairdropStatusParams['id'] = '7ac1da33-b1d2-4f03-b39c-fbac0f1e2b92'; |
| 117 | +$response = $airdropService->get($getairdropStatusParams)->wait(); |
| 118 | +var_dump($response); |
| 119 | +``` |
| 120 | + |
| 121 | +List Airdrop: |
| 122 | + |
| 123 | +```php |
| 124 | +$listAirdropParams = array(); |
| 125 | +$listAirdropParams['page_no'] = '1'; |
| 126 | +$listAirdropParams['limit'] = '11'; |
| 127 | +$listAirdropParams['current_status'] = 'processing,complete'; |
| 128 | +$response = $airdropService->getList($listAirdropParams)->wait(); |
| 129 | +var_dump($response); |
| 130 | +``` |
| 131 | + |
| 132 | +### Actions Module |
| 133 | + |
| 134 | +```php |
| 135 | +$actionService = $ostObj->services->actions; |
| 136 | +``` |
| 137 | + |
| 138 | +Create an action: |
| 139 | + |
| 140 | +```php |
| 141 | +$createParams = array(); |
| 142 | +$createParams['name'] = 'Like'; |
| 143 | +$createParams['kind'] = 'user_to_user'; |
| 144 | +$createParams['currency'] = 'USD'; |
| 145 | +$createParams['arbitrary_amount'] = 'false'; |
| 146 | +$createParams['amount'] = '1'; |
| 147 | +$createParams['commission_percent'] = '1.1'; |
| 148 | +$response = $actionService->create($createParams)->wait(); |
| 149 | +var_dump($response); |
| 150 | +``` |
| 151 | + |
| 152 | +Edit an existing action: |
| 153 | + |
| 154 | +```php |
| 155 | +$editParams = array(); |
| 156 | +$editParams['name'] = 'Temp'; |
| 157 | +$editParams['id'] = '22880'; |
| 158 | +$response = $actionService->edit($editParams)->wait(); |
| 159 | +var_dump($response); |
| 160 | +``` |
| 161 | + |
| 162 | +Get a list of existing actions and other data: |
| 163 | + |
| 164 | +```php |
| 165 | +$listParams = array(); |
| 166 | +$listParams['page_no'] = '1'; |
| 167 | +$listParams['limit'] = '11'; |
| 168 | +$listParams['id'] = '22880'; |
| 169 | +$response = $actionService->getList($listParams)->wait(); |
| 170 | +var_dump($response); |
| 171 | +``` |
| 172 | + |
| 173 | +Get Action Detail: |
| 174 | + |
| 175 | +```php |
| 176 | +$getActionParams = array(); |
| 177 | +$getActionParams['id'] = '22880'; |
| 178 | +$response = $actionService->get($getActionParams)->wait(); |
| 179 | +var_dump($response); |
| 180 | +``` |
| 181 | + |
| 182 | + |
| 183 | +### Transactions Module |
| 184 | + |
| 185 | +```php |
| 186 | +$transactionService = $ostObj->services->transactions; |
| 187 | +``` |
| 188 | + |
| 189 | +Get Transaction Detail: |
| 190 | + |
| 191 | +```php |
| 192 | +$getParams = array(); |
| 193 | +$getParams['id'] = 'ee50f777-1d39-4196-adf8-3021ecc9d852'; |
| 194 | +$response = $transactionService->get($getParams)->wait(); |
| 195 | +var_dump($response); |
| 196 | +``` |
| 197 | + |
| 198 | +Get Transaction List: |
| 199 | + |
| 200 | +```php |
| 201 | +$listParams = array(); |
| 202 | +$listParams['page_no'] = '1'; |
| 203 | +$listParams['limit'] = '11'; |
| 204 | +$listParams['id'] = 'ee50f777-1d39-4196-adf8-3021ecc9d852'; |
| 205 | +$response = $transactionService->getList($listParams)->wait(); |
| 206 | +var_dump($response); |
| 207 | +``` |
| 208 | + |
| 209 | +Execute a Transaction: |
| 210 | + |
| 211 | +```php |
| 212 | +$executeParams = array(); |
| 213 | +$executeParams['from_user_id'] = 'f87346e4-61f6-4d55-8cb8-234c65437b01'; |
| 214 | +$executeParams['to_user_id'] = 'c07bd853-e893-4400-b7e8-c358cfa05d85'; |
| 215 | +$executeParams['action_id'] = '20145'; |
| 216 | +$response = $transactionService->execute($executeParams)->wait(); |
| 217 | +var_dump($response); |
| 218 | +``` |
| 219 | + |
| 220 | +### Token Module |
| 221 | + |
| 222 | +```php |
| 223 | +$tokenService = $ostObj->services->token; |
| 224 | +``` |
| 225 | + |
| 226 | +Get Token Detail: |
| 227 | + |
| 228 | +```php |
| 229 | +$getParams = array(); |
| 230 | +$response = $tokenService->get($getParams)->wait(); |
| 231 | +var_dump($response); |
| 232 | +``` |
| 233 | + |
| 234 | +### Transfers Module |
| 235 | + |
| 236 | +```php |
| 237 | +$transferService = $ostObj->services->transfers; |
| 238 | +``` |
| 239 | + |
| 240 | +Get Transfer Detail: |
| 241 | + |
| 242 | +```php |
| 243 | +$getParams = array(); |
| 244 | +$getParams['id'] = 'ad03a99e-e7c4-4f5a-9fab-ef9a3e422621'; |
| 245 | +$response = $transferService->get($getParams)->wait(); |
| 246 | +var_dump($response); |
| 247 | +``` |
| 248 | + |
| 249 | +Get Transfer List: |
| 250 | + |
| 251 | +```php |
| 252 | +$listParams = array(); |
| 253 | +$listParams['page_no'] = '1'; |
| 254 | +$listParams['limit'] = '11'; |
| 255 | +$response = $transferService->getList($listParams)->wait(); |
| 256 | +var_dump($response); |
| 257 | +``` |
| 258 | + |
| 259 | +Execute a Transfer: |
| 260 | + |
| 261 | +```php |
| 262 | +$executeParams = array(); |
| 263 | +$executeParams['to_address'] = '0xF65E3C06b973a226f9e9B2960d7acdB8fdF9a331'; |
| 264 | +$executeParams['amount'] = '1'; |
| 265 | +$response = $transferService->execute($executeParams)->wait(); |
| 266 | +var_dump($response); |
| 267 | +``` |
0 commit comments