File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ public function hydrateEntity($data, $idOrConversation)
4949 return $ idOrConversation ;
5050 }
5151
52+ public function hydrateAll ($ conversations )
53+ {
54+ $ hydrated = [];
55+ foreach ($ conversations as $ conversation ) {
56+ $ hydrated [] = $ this ->hydrateEntity ($ conversation , $ conversation ['id ' ]);
57+ }
58+
59+ return $ hydrated ;
60+ }
61+
5262 /**
5363 * @param null $conversation
5464 * @return $this|Conversation
Original file line number Diff line number Diff line change 1111
1212use Nexmo \Client \ClientAwareInterface ;
1313use Nexmo \Client \ClientAwareTrait ;
14- use Nexmo \Conversations \Conversation ;
1514use Nexmo \Entity \EntityInterface ;
1615use Nexmo \Entity \JsonResponseTrait ;
1716use Nexmo \Entity \JsonSerializableTrait ;
@@ -71,6 +70,20 @@ public function get()
7170 return $ this ;
7271 }
7372
73+ public function getConversations () {
74+ $ response = $ this ->getClient ()->get (
75+ \Nexmo \Client::BASE_API . Collection::getCollectionPath ().'/ ' .$ this ->getId ().'/conversations '
76+ );
77+
78+ if ($ response ->getStatusCode () != '200 ' ){
79+ throw $ this ->getException ($ response );
80+ }
81+
82+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
83+ $ conversationCollection = $ this ->getClient ()->conversation ();
84+
85+ return $ conversationCollection ->hydrateAll ($ data );
86+ }
7487
7588 public function jsonSerialize ()
7689 {
You can’t perform that action at this time.
0 commit comments