combindma/yotpo-api

This package is abandoned and no longer maintained. No replacement package was suggested.

This is my package yotpo-api

1.0.12 2021-10-04 21:38 UTC

This package is auto-updated.

Last update: 2023-04-05 01:05:54 UTC


README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require combindma/yotpo-api

You can publish the config file with:

php artisan vendor:publish --provider="Combindma\YotpoApi\YotpoApiServiceProvider" --tag="yotpo-config"

This is the contents of the published config file:

return [
    /*
    * Enable or disable Yotpo api. Useful for local development when runing tests.
    */
    'api_enabled' => env('YOTPO_API_ENABLED', false),

    /*
   * Enable or disable Yotpo Loyalty. Useful for local development when runing tests.
   */
    'loyalty_enabled' => env('YOTPO_LOYALTY_ENABLED', false),

    /*
    * Core API V3 Credentials
    */
    'app_key' => env('YOTPO_APP_KEY'),
    'secret_key' => env('YOTPO_SECRET_KEY'),

    /*
    * Loyalty & Referrals API Credentials
    */
    'loyalty_api_key' => env('LOYALTY_API_KEY'),
    'loyalty_guid_key' => env('LOYALTY_GUID_KEY'),

    /*
     * CDNs
     * */
    'loyalty_js_sdk_url' => env('LOYALTY_JS_SDK_URL'),
    'loyalty_modules_loader_url' => env('LOYALTY_MODULES_LOADER_URL'),

    /*
     * Refer link used by Loyalty Program
     * */
    'refer_link' => 'http://rwrd.io',

    /*
     * Default currency code you want to use. Make sure to have the same in your Yotpo Loyalty admin: https://loyalty.yotpo.com/general-settings
     * */
    'currency' => env('YOTPO_DEFAULT_CURRENCY', 'MAD'),

    /*
    * Default country code you want to use. This is important for API requests when submitting the phone number
    * */
    'country' => env('YOTPO_DEFAULT_COUNTRY', 'MA')
];

Usage

  • You should create a free account in https://yotpo.com and add your credentials in .env file
  • You must add Combindma\YotpoApi\Traits\YotpoCustomer to user model or implement yours. Just be sure to have the same structure (same array keys).
  • You must add Combindma\YotpoApi\Traits\YotpoPurchase to order model or implement yours. Just be sure to have the same structure (same array keys).

For further documentation

Example of use: create a customer in loyality program

use Combindma\YotpoApi\Facades\YotpoApi;

//yotpoApiData is implemented in Combindma\YotpoApi\Traits\YotpoCustomer. You can create yours.
YotpoApi::createOrUpdateLoyaltyCustomer($user->yotpoApiData());

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.