From e43fd8ecc0c425a34957c568be0dbfdd588deddc Mon Sep 17 00:00:00 2001 From: Nabil Mohammed Date: Wed, 30 Mar 2022 13:44:19 +0300 Subject: [PATCH] Merchant Details updated (#10) Co-authored-by: Ahmed Bally --- README.md | 41 +++++++++++++++++++------------------- src/Provider/SallaUser.php | 22 ++++++++++---------- test/src/SallaUserTest.php | 18 ++++++++++++----- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 251c3fe..6f6aa99 100644 --- a/README.md +++ b/README.md @@ -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()."
"; diff --git a/src/Provider/SallaUser.php b/src/Provider/SallaUser.php index c6e4408..f1fb24e 100644 --- a/src/Provider/SallaUser.php +++ b/src/Provider/SallaUser.php @@ -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'); } /** @@ -113,7 +115,7 @@ public function getStoreOwnerName() */ public function getStoreUsername() { - return $this->getResponseValue('data.store.username'); + return $this->getResponseValue('data.merchant.username'); } /** @@ -123,7 +125,7 @@ public function getStoreUsername() */ public function getStoreName() { - return $this->getResponseValue('data.store.name'); + return $this->getResponseValue('data.merchant.name'); } /** @@ -133,7 +135,7 @@ public function getStoreName() */ public function getStoreAvatar() { - return $this->getResponseValue('data.store.avatar'); + return $this->getResponseValue('data.merchant.avatar'); } /** @@ -143,7 +145,7 @@ public function getStoreAvatar() */ public function getStoreLocation() { - return $this->getResponseValue('data.store.store_location'); + return $this->getResponseValue('data.merchant.store_location'); } /** @@ -153,7 +155,7 @@ public function getStoreLocation() */ public function getStorePlan() { - return $this->getResponseValue('data.store.plan'); + return $this->getResponseValue('data.merchant.plan'); } /** @@ -163,7 +165,7 @@ public function getStorePlan() */ public function getStoreStatus() { - return $this->getResponseValue('data.store.status'); + return $this->getResponseValue('data.merchant.status'); } /** @@ -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')); } /** diff --git a/test/src/SallaUserTest.php b/test/src/SallaUserTest.php index 7ea8ac5..fc7601c 100644 --- a/test/src/SallaUserTest.php +++ b/test/src/SallaUserTest.php @@ -22,8 +22,6 @@ 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', @@ -31,7 +29,17 @@ public function testUserDefaults() '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()); @@ -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());