codemojo / startkit
Pluggable components as service for your PHP application
Requires
- php: >=5.2.0
- dev-master
- v0.1.940
- v0.1.939
- v0.1.938
- v0.1.937
- v0.1.936
- v0.1.935
- v0.1.934
- v0.1.933
- v0.1.932
- v0.1.931
- v0.1.93
- v0.1.92
- v0.1.91
- v0.1.90
- v0.1.89
- v0.1.88
- v0.1.87
- v0.1.86
- v0.1.85
- v0.1.84
- v0.1.83
- v0.1.82
- v0.1.81
- v0.1.71
- v0.1.54
- v0.1.53
- v0.1.52
- v0.1.51
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.2-alpha
- v0.1.1
- v0.1.1-alpha
- v0.1
- v0.1-alpha
This package is not auto-updated.
Last update: 2024-12-21 21:08:32 UTC
README
About
Welcome to the CodeMojo SDK (Startup Development Toolkit). CodeMojo helps you to rapidly deploy application components as pluggable services for your PHP application allowing you to cut development time ramp up productivity.
Using the SDK is straight forward and simple. The SDK consist of four main services
Download the PHP SDK here
Download the Sample Application here
See the Wiki for additional documentation
See the Dashboard walkthrough for insights on how to use the dashboard
Installation & Usage
Stock/Vanilla PHP
Download the SDK and include the autoload.php
to your source code
Composer
Simply add the following to your composer.json
{ "require": { "codemojo/startkit": "0.1.*" } }
Example
Once you have enabled and configured the Loyalty module from your CodeMojo dashboard, you can use it as simple as shown below. More documentation on dashboard.
require_once '../sdk/autoload.php'; const CLIENT_ID = 'sample@codemojo.io'; const CLIENT_SECRET = 'PLB6DHP7VcykRDdvloi2X9tEq3FvsIBhtdn7UdeQ'; // Create an instance of Authentication Service $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::LOCAL, function($type, $message){ switch($type){ case Exceptions::AUTHENTICATION_EXCEPTION: echo 'Authentication Exception'; break; case Exceptions::BALANCE_EXHAUSTED_EXCEPTION: echo 'Low balance'; break; case Exceptions::FIELDS_MISSING_EXCEPTION: echo 'Fields missing'; break; case Exceptions::QUOTA_EXCEPTION: echo 'Quota Exhausted Exception'; break; case Exceptions::TOKEN_EXCEPTION: echo 'Invalid token Exception'; break; default: echo 'Error ' . $message; break; } }); // Create an instance of Loyalty Service - If you have more than one wallet service, // you can optionally pass in the wallet instance as the second argument $loyaltyService = new LoyaltyService($authService); // Credit points to user - You can have different set of rules based on the platform // For example, you can promote your android app by saying Get 5% more cashback when you transact through the Android app $status = $loyaltyService->addLoyaltyPoints("user1@codemojo.io", 1500, "android", "", 7, "Cashback for Order no. 1231"); // Get the balance in the wallet $balance = $loyaltyService->getBalance("user1@codemojo.io"); // Check how much maximum can be redeemed by the user for the given (current) transaction value // Again, you can have different set of rules for redemption based on the platform $maximumRedemption = $loyaltyService->maximumRedemption("user1@codemojo.io",8500); // Redeem amount // (user_id, redemption_amount, current_transaction_value, platform) $loyaltyService->redeem("user1@codemojo.io", 500, 8500, "android");
For more details on the methods & parameters available for each service, take a look at the individual service pages.