GithubHelp home page GithubHelp logo

rclient's Introduction

Roketin Client Template

Latest Version License Total Downloads

RClient is standard client application to Roketin API to accelerate connecting and integrating basic feature of Roketin Engine API to client's website.

API Documentation

Documentation for the Roketin API can be found on the Documentation.

Installation

Laravel 5

"require": {
    "laravel/framework": "5.0.*",
    "sukorenomw/rclient": "dev-master"
}

Next, run the Composer update command from the Terminal:

composer update

or

composer update "sukorenomw/rclient"

CONFIGURATION

  1. Open config/app.php and addd this line to your Service Providers Array
  Roketin\Providers\RoketinServiceProvider::class,
  1. Open config/app.php and addd this line to your Aliases
    'Roketin' => Roketin\Facades\RoketinFacade::class
  1. Publish the config using the following command:

    $ php artisan vendor:publish --provider="Roketin\Providers\RoketinServiceProvider"

  2. Create an .env file based on .env.example file and change the value based on client credentials

  APP_ENV=local
  APP_DEBUG=true
  APP_KEY=somestringrandom
  APP_URL=http://localhost

  ROKETIN_API=http://dev.roketin.com/api/v2.2/
  ROKETIN_PUBLIC=http://dev.roketin.com/

  ROKETIN_TOKEN=aBCd1234
  ROKETIN_USERNAME=roketin
  ROKETIN_RX=4241639264053293060625251241576152575759

  VERITRANS_SERVER=494DKU0E71241K7BC15597DACA94D1F43
  VERITRANS_ENVIRONMENT=sandbox

HOW TO USE

Basic

You can call a Roketin Object by using: Roketin::model()->get()

    use Roketin;
    
    $menus = Roketin::menus()->get();
    $posts = Roketin::posts()->get();
    $products = Roketin::products()->get();
    etc..

Fethcing single object with id/slug/etc:

    /*
     * Same as fetching object, but in singular form (without 's')
     * the second argument can be id or slug or etc ..
     * this is dynamic function call to Roketin Engine API
     */
    
    $home = Roketin::menu('home')->get();
    $post = Roketin::post('latest-update')->get();

Conditions

Fetching object with simple where conditions:

    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()->where('title','like','vacation')->get();
    
    //NOTE : 
    //It doesn't need to add % if using 'like' operator

Fetching object with simple orWhere conditions:

    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()
                        ->where('title','like','vacation')
                        ->orWhere('title','like','holiday')
                        ->get();
    
    //NOTE : 
    //It doesn't need to add % if using 'like' operator

Advance where orWhere grouping conditions:

    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()
                        ->where('title','like','vacation')
                        ->orWhere('title','like','holiday')
                        ->where('date','>=','2016-04-10')
                        ->where('date','<=','2016-04-18')
                        ->get();
    
    //NOTE : 
    //It will result query grouping 
    // (title like vacation or title like holiday) 
    // AND 
    // (date >= 2016-04-10 and date <= 2016-04-18 )

Sorting

Fetch a Roketin Object API by sorting on it's field:

    /*
     * sorting object before fetch
     * 
     * @param $field
     * @param $direction (optional) default is ASC
     * /

    $posts = Roketin::posts()->sortBy('created_at')->get();
    $posts = Roketin::posts()->sortBy('created_at','DESC')->get();

Grouping

Fetch a Roketin Object API by grouping on it's field:

    /*
     * grouping object before fetch
     * 
     * @param $field
     * /

    $posts = Roketin::posts()->groupBy('created_at')->get();

Pagination

Paginating fetch object

    /*
     * paginate object before fetch
     * 
     * @param $size default value is 10
     * @param $page (optional)
     * /

    $posts = Roketin::posts()->paginate(10)->get();
    $posts = Roketin::posts()->paginate(10,2)->get();

Shipping

Get all available countries:

    $countries = Roketin::shipping()->countries()

Get all available provinces (currently available in Indonesia only):

    $province = Roketin::shipping()->province()

Get all available city (currently available in Indonesia only):

    /*
     * @param $provinceid
     */

    $cities = Roketin::shipping()->province(9)->cities()

Calculate shipping costs:

    /*
     * @param $destination = city id
     * @param $courier = JNE/TIKI/POS
     * @param $weight = item weight in KG (optional) default value 1
     * @param $origin = city id
     */

    $costs = Roketin::shipping()->cost(23, 'JNE')

Order

Create sales order:

    /*
     * @param array $generalData
     * @param array $customerData
     * @param array $products
     */
     
     $generalData = [
            "notes"         => "some string here",
            "is_email_only" => true,
     ];

     $customerData = [
            "first_name" => "Sukoreno",
            "last_name"  => "Mukti",
            "phone"      => "+6281910513704",
            "email"      => "[email protected]",
     ];

     $products = [
         [
             "id"         => "2623",
             "qty"        => "1",
             "sku"        => "ADVHEL001",
             "price_type" => "retail_price",
         ],
     ];                                 
    $order = Roketin::order()->create([], 'JNE')

Note:

  • For detailed attribute, see sales order API documentation HERE

Confirm payment order:

    /*
     * @param $invoice_number
     * @param $payment_type
     * @param $total
     * @param $customer_name
     * @param $transaction_number
     * @param Image $image
     * @param null $bank_account
     * @param null $paid_date
     */
     
    //you can create image for bank transfer that 
    //showing transfer is success
    //by using Image::make()
    $img = Image::make(Input::file('image'))
    
    $payment = Roketin::order()
                ->confirm('SI16041300058', 
                          'TRANSFER', 
                          '150000', 
                          'Sukoreno Mukti', 
                          'TRX-123', 
                          $img, 
                          '0853909090')

Void an Sales Order and it's invoice:

    /*
     * @param $invoice_number
     */

    $order = Roketin::order()->void('ASD02262016')

Subscribe

Submit a subscription email:

    /*
     * @param $email
     */

    $subscribe = Roketin::subscribe('[email protected]')

Message

Send a message to Roketin Engine Inbox:

    /*
     * @param $sender_name
     * @param $sender_email
     * @param $sender_phone
     * @param $message_title
     * @param $message_body
     */

    $msg = Roketin::message()
                    ->send(
                    'reno',
                    '[email protected]',
                    '123123',
                    'test mesage',
                    'hai')

Vouchers

Check validity of a voucher:

    /*
     * @param $code
     * @param $voucher_type (optional), default = null
     * voucher type can be giftvoucher (voucher in 
     * exchange to money nominal) or
     * other (voucher to exchange to free product)
     * default is voucher_type is other
     */

    $check = Roketin::voucher()->check('AS123D')

invalidate a voucher (use voucher):

    /*
     * @param $voucher_code
     * @param $voucher_type (optional) default is other
     * @param $used_by (optional) default is logged in user
     */

    $check = Roketin::voucher()->invalidate('AS123D')

User

Register new user:

    /*
     * @param $first_name
     * @param $last_name
     * @param $email
     * @param $phone
     * @param $password
     * @param $password_confirmation
     * @return user object
     */

    $user = Roketin::user()->register('first_name', 'last_name', 'email', 'phone', 'password', 'password_confirmation');

User activation:

    /*
     * @param $token
     * @return true if success activation
     * @return error object if present
     */

    $activation = Roketin::user()->activate('token');

Resend activation code to email:

    /*
     * @param $email
     * @return true if success activation
     * @return error object if present
     */

    $resend = Roketin::user()->resendActivation('[email protected]');

Forgot password (generate and send token to user email):

    /*
     * @param $email
     * @return true if success activation
     * @return error object if present
     */

    Roketin::user()->forgot('[email protected]');

Reset password:

    /*
     * @param $token
     * @param $password
     * @param $password_confirmation
     * @return true if success activation
     * @return error object if present
     */

    Roketin::user()->resetPassword('token','asdf','asdf');

Login:

    /*
     * @param $email
     * @param $password
     * @param $type (optional) default = user, available = vendor
     * @return true if success activation
     * @return error object if present
     */

    Roketin::auth()->login('[email protected]','asdf');

Current User:

    /*
     * @return user object
     */

    Roketin::auth()->user();

Update user data:

    /*
     * @return user object
     */

    Roketin::user()->update(['first_name' => 'John']);

Note:

  • For detailed attribute, see sales order API documentation HERE

Get transaction history data:

    /*
     * @return user object
     */

    Roketin::user()->transactionHistory()->get();

Note:

  • you can also use where(), orWhere(), etc query with this method

Logout:

    /*
     * @return boolean
     */

    Roketin::auth()->logout();

rclient's People

Contributors

sukorenomw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.