Skip to content

Commit 5f76b6a

Browse files
committed
Client unpack response payload
1 parent 16479f3 commit 5f76b6a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/RESTClient.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ public function predictAsync(Dataset $dataset) : PromiseInterface
122122

123123
return $this->client->sendAsync($request)
124124
->then([$this, 'parseResponseBody'], [$this, 'onError'])
125-
->then([$this, 'unpackPayload']);
125+
->then([$this, 'unpackPayload'])
126+
->then(function ($data) {
127+
return $data['predictions'];
128+
});
126129
}
127130

128131
/**
@@ -148,7 +151,10 @@ public function probaAsync(Dataset $dataset) : PromiseInterface
148151

149152
return $this->client->sendAsync($request)
150153
->then([$this, 'parseResponseBody'], [$this, 'onError'])
151-
->then([$this, 'unpackPayload']);
154+
->then([$this, 'unpackPayload'])
155+
->then(function ($data) {
156+
return $data['probabilities'];
157+
});
152158
}
153159

154160
/**
@@ -174,7 +180,10 @@ public function scoreAsync(Dataset $dataset) : PromiseInterface
174180

175181
return $this->client->sendAsync($request)
176182
->then([$this, 'parseResponseBody'], [$this, 'onError'])
177-
->then([$this, 'unpackPayload']);
183+
->then([$this, 'unpackPayload'])
184+
->then(function ($data) {
185+
return $data['scores'];
186+
});
178187
}
179188

180189
/**

0 commit comments

Comments
 (0)