Skip to content

Commit

Permalink
Merchant Details updated (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: Ahmed Bally <ahmedbaly87@gmail.com>
  • Loading branch information
nabiloo19 and ahmedbally authored Mar 30, 2022
1 parent 7ca62da commit e43fd8e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,26 @@ try {
$user = $provider->getResourceOwner($token);

/**
* {
* "id": 181690847,
* "name": "eman elsbay",
* "email": "user@salla.sa",
* "mobile": "555454545",
* "role": "user",
* "created_at": "2018-04-28 17:46:25",
* "store": {
* "id": 633170215,
* "owner_id": 181690847,
* "owner_name": "eman elsbay",
* "username": "good-store",
* "name": "متجر الموضة",
* "avatar": "https://cdn.salla.sa/XrXj/g2aYPGNvafLy0TUxWiFn7OqPkKCJFkJQz4Pw8WsS.jpeg",
* "store_location": "26.989000873354787,49.62477639657287",
* "plan": "special",
* "status": "active",
* "created_at": "2019-04-28 17:46:25"
* }
* }
*/
* {
* "id": 1771165749,
* "name": "Test User",
* "email": "testuser@email.partners",
* "mobile": "+966500000000",
* "role": "user",
* "created_at": "2021-12-31 11:36:57",
* "merchant": {
* "id": 1803665367,
* "username": "dev-j8gtzhp59w3irgsw",
* "name": "dev-j8gtzhp59w3irgsw",
* "avatar": "https://i.ibb.co/jyqRQfQ/avatar-male.webp",
* "store_location": "26.989000873354787,49. 62477639657287",
* "plan": "special",
* "status": "active",
* "domain": "https://salla.sa/YOUR-DOMAIN-NAME",
* "created_at": "2021-12-31 11:36:57"
* }
* }
*/
var_export($user->toArray());

echo 'User ID: '.$user->getId()."<br>";
Expand Down
22 changes: 12 additions & 10 deletions src/Provider/SallaUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,29 @@ public function getCreatedAt()
*/
public function getStoreId()
{
return $this->getResponseValue('data.store.id');
return $this->getResponseValue('data.merchant.id');
}

/**
* Get store owner id.
*
* @return string|null
* @deprecated it will be removed next version
*/
public function getStoreOwnerID()
{
return $this->getResponseValue('data.store.owner_id');
return $this->getResponseValue('data.merchant.owner_id');
}

/**
* Get store owner name.
*
* @return string|null
* @deprecated it will be removed next version
*/
public function getStoreOwnerName()
{
return $this->getResponseValue('data.store.owner_name');
return $this->getResponseValue('data.merchant.owner_name');
}

/**
Expand All @@ -113,7 +115,7 @@ public function getStoreOwnerName()
*/
public function getStoreUsername()
{
return $this->getResponseValue('data.store.username');
return $this->getResponseValue('data.merchant.username');
}

/**
Expand All @@ -123,7 +125,7 @@ public function getStoreUsername()
*/
public function getStoreName()
{
return $this->getResponseValue('data.store.name');
return $this->getResponseValue('data.merchant.name');
}

/**
Expand All @@ -133,7 +135,7 @@ public function getStoreName()
*/
public function getStoreAvatar()
{
return $this->getResponseValue('data.store.avatar');
return $this->getResponseValue('data.merchant.avatar');
}

/**
Expand All @@ -143,7 +145,7 @@ public function getStoreAvatar()
*/
public function getStoreLocation()
{
return $this->getResponseValue('data.store.store_location');
return $this->getResponseValue('data.merchant.store_location');
}

/**
Expand All @@ -153,7 +155,7 @@ public function getStoreLocation()
*/
public function getStorePlan()
{
return $this->getResponseValue('data.store.plan');
return $this->getResponseValue('data.merchant.plan');
}

/**
Expand All @@ -163,7 +165,7 @@ public function getStorePlan()
*/
public function getStoreStatus()
{
return $this->getResponseValue('data.store.status');
return $this->getResponseValue('data.merchant.status');
}

/**
Expand All @@ -174,7 +176,7 @@ public function getStoreStatus()
*/
public function getStoreCreatedAt()
{
return new \DateTime($this->getResponseValue('data.store.created_at'));
return new \DateTime($this->getResponseValue('data.merchant.created_at'));
}

/**
Expand Down
18 changes: 13 additions & 5 deletions test/src/SallaUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ public function testUserDefaults()
'created_at' => '2018-04-28 17:46:25',
'store'=>[
'id'=>'11111',
'owner_id'=> '12345',
'owner_name'=> 'mock name',
'username'=> 'mock_name',
'name'=> 'mock name',
'avatar'=>'mock_avatar',
'store_location'=>'mock_location',
'plan'=>'mock_plan',
'status'=>'mock_status',
'created_at'=>'2018-04-28 17:46:25',
]
],
'merchant'=>[
'id'=>'11111',
'username'=> 'mock_name',
'name'=> 'mock name',
'avatar'=>'mock_avatar',
'store_location'=>'mock_location',
'plan'=>'mock_plan',
'status'=>'mock_status',
'created_at'=>'2018-04-28 17:46:25',
],
]]);

$this->assertEquals(12345, $user->getId());
Expand All @@ -41,8 +49,8 @@ public function testUserDefaults()
$this->assertEquals('user', $user->getRole());
$this->assertEquals( '2018-04-28 17:46:25', $user->getCreatedAt()->format('Y-m-d H:i:s'));
$this->assertEquals(11111, $user->getStoreId());
$this->assertEquals(12345, $user->getStoreOwnerID());
$this->assertEquals('mock name', $user->getStoreOwnerName());
$this->assertEquals(null, $user->getStoreOwnerID());
$this->assertEquals(null, $user->getStoreOwnerName());
$this->assertEquals('mock_name', $user->getStoreUsername());
$this->assertEquals('mock name', $user->getStoreName());
$this->assertEquals('mock_avatar', $user->getStoreAvatar());
Expand Down

0 comments on commit e43fd8e

Please sign in to comment.