Skip to content

Commit

Permalink
fix: some function
Browse files Browse the repository at this point in the history
  • Loading branch information
aungmyokyaw97 committed Dec 1, 2023
1 parent b80356d commit 86b72f5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[SmileOne](https://www.smile.one/)
## About
This package is specifically designed for the [Smile.one](https://www.smile.one/) , offering a simple and efficient method to purchase Smile One products using Laravel.
Note - Currently, this package is intended for Mobile Legends Product from [SmileOne](https://www.smile.one/)
## Installation
```shel
composer require aungmyokyaw/smile-one
Expand All @@ -12,4 +13,19 @@ You will need to publish the configuration file to your application. You can do
php artisan vendor:publish --tag="smileone-config"
```
After publishing the package's configuration file, you will find the file at `config/smileone.php`. You will need to fill out the necessary data in this file to use the package.
## Usage samples
## Usage samples
```
SmileOne::setProduct(#ProductName)->getProductList(); // Get Product Points List
// Replace '#ProductName' with your actual product name.
// Example : SmileOne::setProduct('mobilelegends')->getProductList();
SmileOne::setProduct(#ProductName)->getPoints(); // Get Total Available SmilePoints With Product
SmileOne::setProduct('mobilelegends')->getProduct(); // Get Main Product
SmileOne::setProduct(#ProductName,#ProductId)->setUser(#UserID,#UserZoneID)->checkProductPoints(); // Check Points with User ID
SmileOne::setProduct(#ProductName,#ProductId)->setUser(#UserID,#UserZoneID)->purchase(); // Product Purchase
```
39 changes: 20 additions & 19 deletions src/SmileOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,38 @@ private function getConfigData($key){
return !empty($this->config[$key]) ? $this->config[$key] : throw SmileOneException::configError($key);
}

public function getProductList(String $product){
public function setProduct(String $product,String $productid = null){
$this->product = $product;
$this->productid = $productid;
return $this;
}

public function setUser(String $userid,String $zoneid){
$this->userid = $userid;
$this->zoneid = $zoneid;
return $this;
}

public function getProductList(){
return $this->productPriceList();
}

public function getProduct(String $product){
$this->product = $product;
public function getProduct(){
return $this->productAvailable();
}

public function getQueryPoints(String $product){
$this->product = $product;
return $this->productPoints();
}

public function role(String $product,String $productid){
$this->product = $product;
$this->productid = $productid;
public function checkProductPoints(){
return $this->roleQuery();
}

public function purchase(String $product,String $productid){
$this->product = $product;
$this->productid = $productid;
return $this->postPurchase();
public function getPoints(){
return $this->productPoints();
}

public function user(String $userid,String $zoneid){
$this->userid = $userid;
$this->zoneid = $zoneid;
return $this;
public function purchase(){
return $this->postPurchase();
}



}
23 changes: 10 additions & 13 deletions src/Traits/SmileOneTrait.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

namespace Amk\SmileOne\Traits;
use Amk\Tmh\Exceptions\SmileOneException;
use Illuminate\Support\Facades\Http;

trait SmileOneTrait{
Expand All @@ -22,21 +21,11 @@ public function productPoints(){
}

public function roleQuery(){
$data['product'] = $this->product;
$data['productid'] = $this->productid;
$data['userid'] = $this->userid;
$data['zoneid'] = $this->zoneid;

return $this->callSmileOne($data,$this->getFullURL(config('smileone.API_URL.role-query')));
return $this->callSmileOne($this->formParam(),$this->getFullURL(config('smileone.API_URL.role-query')));
}

public function postPurchase(){
$data['product'] = $this->product;
$data['productid'] = $this->productid;
$data['userid'] = $this->userid;
$data['zoneid'] = $this->zoneid;

return $this->callSmileOne($data,$this->getFullURL(config('smileone.API_URL.purchase')));
return $this->callSmileOne($this->formParam(),$this->getFullURL(config('smileone.API_URL.purchase')));
}

public function callSmileOne($body,$url){
Expand Down Expand Up @@ -72,6 +61,14 @@ public function getFullURL($data){
return config('smileone.domain').$data;
}

private function formParam(){
$data['product'] = $this->product;
$data['productid'] = $this->productid;
$data['userid'] = $this->userid;
$data['zoneid'] = $this->zoneid;
return $data;
}




Expand Down

0 comments on commit 86b72f5

Please # to comment.