Skip to content

Commit f630b01

Browse files
author
Alex Belenky
committed
Add docs
1 parent 459fdaf commit f630b01

File tree

1 file changed

+94
-9
lines changed

1 file changed

+94
-9
lines changed

src/CommentsClient.php

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ class CommentsClient {
1515
protected $doNotStore;
1616
protected $clientToken;
1717
protected $sessionId;
18+
protected $attributeScores;
19+
protected $communityId;
1820

1921
public function __construct(string $token) {
2022
$this->token = $token;
2123
}
2224

25+
/**
26+
* Make an Analyze Comment request
27+
*
28+
* @return CommentsResponse
29+
* @throws CommentsException
30+
*/
2331
public function analyze(): CommentsResponse {
2432
$data = [];
2533
$fields = [
@@ -36,50 +44,127 @@ public function analyze(): CommentsResponse {
3644
return $this->request('analyze', $data);
3745
}
3846

39-
public function suggestScore() {
47+
/**
48+
*
49+
*
50+
* @return CommentsResponse
51+
* @throws CommentsException
52+
*/
53+
public function suggestScore(): CommentsResponse {
4054
//TODO
4155
}
4256

57+
/**
58+
* The text to score. This is assumed to be utf8 raw text of the text to be checked.
59+
*
60+
* @example ['text' => string, 'type' => string]
61+
* @param array $comment
62+
*/
4363
public function comment(array $comment): void {
4464
$this->comment = $comment;
4565
}
4666

47-
public function languages(array $languages): void {
48-
$this->languages = $languages;
49-
}
50-
67+
/**
68+
* A list of objects providing the context for comment
69+
*
70+
* @example ['entries': [{'text': string, 'type': string}]
71+
* @param array $context
72+
*/
5173
public function context(array $context): void {
5274
$this->context = $context;
5375
}
5476

77+
/**
78+
* A list of ISO 631-1 two-letter language codes specifying the language(s) that comment is in
79+
*
80+
* @example [string]
81+
* @param array $languages
82+
*/
83+
public function languages(array $languages): void {
84+
$this->languages = $languages;
85+
}
86+
87+
/**
88+
* A map from model's attribute name to a configuration object
89+
*
90+
* @example [string: {'scoreType': string, 'scoreThreshold': float},]
91+
* @param array $requestedAttributes
92+
*/
5593
public function requestedAttributes(array $requestedAttributes): void {
5694
$this->requestedAttributes = $requestedAttributes;
5795
}
5896

97+
/**
98+
* A boolean value that indicates if the request should return spans that describe the scores for each part of the
99+
* text
100+
* @example bool
101+
* @param bool $spanAnnotations
102+
*/
59103
public function spanAnnotations(bool $spanAnnotations): void {
60104
$this->spanAnnotations = $spanAnnotations;
61105
}
62106

107+
/**
108+
* Whether the API is permitted to store comment and context from this request
109+
*
110+
* @example bool
111+
* @param bool $doNotStore
112+
*/
63113
public function doNotStore(bool $doNotStore): void {
64114
$this->doNotStore = $doNotStore;
65115
}
66116

117+
/**
118+
* An opaque token that is echoed back in the response
119+
*
120+
* @example string
121+
* @param string $clientToken
122+
*/
67123
public function clientToken(string $clientToken) {
68124
$this->clientToken = $clientToken;
69125
}
70126

127+
/**
128+
* An opaque session id
129+
*
130+
* @example string
131+
* @param string $sessionId
132+
*/
71133
public function sessionId(string $sessionId) {
72134
$this->sessionId = $sessionId;
73135
}
74136

75-
public function attributeScores() {
76-
//TODO
137+
/**
138+
* A map from model attribute name to per-attribute score objects
139+
*
140+
* @example [string: {
141+
* 'summaryScore': {'value': float,'type': string},
142+
* 'spanScores': [{'begin': int,'end': int,'score': {'value': float,'type': string}}]
143+
* }]
144+
* @param array $attributeScores
145+
*/
146+
public function attributeScores(array $attributeScores) {
147+
$this->attributeScores = $attributeScores;
77148
}
78149

79-
public function communityId() {
80-
//TODO
150+
/**
151+
* Opaque identifier associating this score suggestion with a particular community
152+
*
153+
* @example string
154+
* @param string $communityId
155+
*/
156+
public function communityId(string $communityId) {
157+
$this->communityId = $communityId;
81158
}
82159

160+
/**
161+
* Send request to API
162+
*
163+
* @param string $method
164+
* @param array $data
165+
* @return CommentsResponse
166+
* @throws CommentsException
167+
*/
83168
protected function request(string $method, array $data): CommentsResponse {
84169
$client = new Client(['defaults' => [
85170
'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'],

0 commit comments

Comments
 (0)