bap/connect

Connect BAP Platform for laravel 5.*

v1.0.7 2016-12-05 08:03 UTC

README

#Connect Platform for BAP Service

Install

Add the following line to composer.json file and run composer update

{
      "require": {
        "bap/connect": "1.*"
      } 
}

Or install with CLI:

    composer require bap/connect

Open up config/app.php and add the following to the provires key.

    Bap\ConnectPlatform\ConnectPlatformServiceProvide::class

You can register the ConnectPlatform Facade aliases key with:

     'ConnectPlatform'  => Bap\ConnectPlatform\ConnectPlatformFacade::class

Configuration

You'll need to publish all vendor assets:

    php artisan vendor:publish --provider="Bap\ConnectPlatform\ConnectPlatformServiceProvide"

And also run migrations

    php artisan migrate

And add PLATFORM_URL to .env

    PLATFORM_URL=my_url
    PLATFORM_GRANT=grant
    PLATFORM_CLIENT_ID=CLIENT_ID
    PLATFORM_CLIENT_SECRET=CLIENT_SECRET
    PLATFORM_SCOPE=SCOPE

Add relation devices and contract

...
use Bap\ConnectPlatform\Traits\WithDevices;
use Bap\ConnectPlatform\Contracts\WithDevicesInterface;

class User extends Model implements AuthenticatableContract,
                                    AuthorizableContract,
                                    CanResetPasswordContract,
                                    WithDevicesInterface
{
    use Authenticatable,
        Authorizable,
        CanResetPassword,
        RelationDevices;

Usage

  • Add middleware jwt auth in construsctor method Controller:
    public function __constructor()
    {
        $this->middleware('jwt.auth');
    }
  • Or app/Http/routes.php
    Route::post('me', ['before' => 'jwt-auth', function() {
        // Todo
    }]);
  • Add device to options claims for jwt

Profile

Get profile

Get user profile from Platform with options $attributes = ['id', 'username', 'telephone']

<?php
use ConnectPlatform;
   
ConnectPlatform::profile(array $attributes);

OR

<?php
app('platform')->profile(array $attribuites);

Friend

Get list a friend

ConnectPlatform::getFriends($uid);

Get list a friend has been block

ConnectPlatform::getBlockFriends($uid);

Get list ID friend waiting request

ConnectPlatform::getListIdFriendWaiting($uid);

Get list ID friend request

ConnectPlatform::getListIdFriendRequest($uid);

Get relation

ConnectPlatform::getRelation($uid, $friendUID)

Check list user is friend

ConnectPlatform::isFriends($uid, array $uids)

Check relation list friend

ConnectPlatform::checkListFriends($uid, array $uids)

Send friend request

ConnectPlatform::sendFriendRequest($uid, $friendUid);

Approve friend request

ConnectPlatform::approveFriendRequest($uid, $friendUid);
With $uids is list USER ID of platform

Search

Search Telephone

ConnectPlatform::searchTelephone($uid, array $params);
With $params = ['phone_code' => '', 'telephone' => '']

Coin

Get asset

ConnectPlatform::getCoin($uid);

Get History

ConnectPlatform::getHistoryCoin($uid, $action);

With $action in array ['request', 'payment', 'withdraw']

Exchange

ConnectPlatform::exchange($uid, $action, array $params);

With $action in array ['money_coin', 'coin_money'] and $params = ['src' => '' , 'des' => '']

Request

ConnectPlatform::requestCoin($uid, $coin);

Withdraw money

ConnectPlatform::withDrawMoney($uid, $money);

Get token payment

ConnectPlatform::getPaymentToken($uid);

Send payment

ConnectPlatform::requestPayment($uid, array $params);

With $params = ['item_id' => '' , 'item_cat_id' => '', 'item_value' => '', 'token' => '']

#####With $uid is ID of platform

#Config file You can change model, list devices, timeout request at config file.