GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (b10c57)
by milkmeowo
02:58
created

Client   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 215
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 215
rs 10
c 0
b 0
f 0
wmc 16
1
<?php
2
namespace AliyunMNS;
3
4
use AliyunMNS\Queue;
5
use AliyunMNS\Config;
6
use AliyunMNS\Http\HttpClient;
7
use AliyunMNS\AsyncCallback;
8
use AliyunMNS\Model\AccountAttributes;
9
use AliyunMNS\Requests\CreateQueueRequest;
10
use AliyunMNS\Responses\CreateQueueResponse;
11
use AliyunMNS\Requests\ListQueueRequest;
12
use AliyunMNS\Responses\ListQueueResponse;
13
use AliyunMNS\Requests\DeleteQueueRequest;
14
use AliyunMNS\Responses\DeleteQueueResponse;
15
use AliyunMNS\Requests\CreateTopicRequest;
16
use AliyunMNS\Responses\CreateTopicResponse;
17
use AliyunMNS\Requests\DeleteTopicRequest;
18
use AliyunMNS\Responses\DeleteTopicResponse;
19
use AliyunMNS\Requests\ListTopicRequest;
20
use AliyunMNS\Responses\ListTopicResponse;
21
use AliyunMNS\Requests\GetAccountAttributesRequest;
22
use AliyunMNS\Responses\GetAccountAttributesResponse;
23
use AliyunMNS\Requests\SetAccountAttributesRequest;
24
use AliyunMNS\Responses\SetAccountAttributesResponse;
25
26
/**
27
 * Please refer to
28
 * https://docs.aliyun.com/?spm=#/pub/mns/api_reference/api_spec&queue_operation
29
 * for more details
30
 */
31
class Client
32
{
33
    private $client;
34
35
    /**
36
     * Please refer to http://www.aliyun.com/product/mns for more details
37
     *
38
     * @param endPoint: the host url
39
     *               could be "http://$accountId.mns.cn-hangzhou.aliyuncs.com"
40
     *               accountId could be found in aliyun.com
41
     * @param accessId: accessId from aliyun.com
42
     * @param accessKey: accessKey from aliyun.com
43
     * @param securityToken: securityToken from aliyun.com
44
     * @param config: necessary configs
45
     */
46
    public function __construct($endPoint, $accessId,
47
        $accessKey, $securityToken = NULL, Config $config = NULL)
48
    {
49
        $this->client = new HttpClient($endPoint, $accessId,
50
            $accessKey, $securityToken, $config);
51
    }
52
53
    /**
54
     * Returns a queue reference for operating on the queue
55
     * this function does not create the queue automatically.
56
     *
57
     * @param string $queueName:  the queue name
58
     * @param bool $base64: whether the message in queue will be base64 encoded
59
     *
60
     * @return Queue $queue: the Queue instance
61
     */
62
    public function getQueueRef($queueName, $base64 = TRUE)
63
    {
64
        return new Queue($this->client, $queueName, $base64);
65
    }
66
67
    /**
68
     * Create Queue and Returns the Queue reference
69
     *
70
     * @param CreateQueueRequest $request:  the QueueName and QueueAttributes
71
     *
72
     * @return CreateQueueResponse $response: the CreateQueueResponse
73
     *
74
     * @throws QueueAlreadyExistException if queue already exists
75
     * @throws InvalidArgumentException if any argument value is invalid
76
     * @throws MnsException if any other exception happends
77
     */
78
    public function createQueue(CreateQueueRequest $request)
79
    {
80
        $response = new CreateQueueResponse($request->getQueueName());
81
        return $this->client->sendRequest($request, $response);
82
    }
83
84
    /**
85
     * Create Queue and Returns the Queue reference
86
     * The request will not be sent until calling MnsPromise->wait();
87
     *
88
     * @param CreateQueueRequest $request:  the QueueName and QueueAttributes
89
     * @param AsyncCallback $callback:  the Callback when the request finishes
90
     *
91
     * @return MnsPromise $promise: the MnsPromise instance
92
     *
93
     * @throws MnsException if any exception happends
94
     */
95
    public function createQueueAsync(CreateQueueRequest $request,
96
        AsyncCallback $callback = NULL)
97
    {
98
        $response = new CreateQueueResponse($request->getQueueName());
99
        return $this->client->sendRequestAsync($request, $response, $callback);
100
    }
101
102
    /**
103
     * Query the queues created by current account
104
     *
105
     * @param ListQueueRequest $request: define filters for quering queues
106
     *
107
     * @return ListQueueResponse: the response containing queueNames
108
     */
109
    public function listQueue(ListQueueRequest $request)
110
    {
111
        $response = new ListQueueResponse();
112
        return $this->client->sendRequest($request, $response);
113
    }
114
115
    public function listQueueAsync(ListQueueRequest $request,
116
        AsyncCallback $callback = NULL)
117
    {
118
        $response = new ListQueueResponse();
119
        return $this->client->sendRequestAsync($request, $response, $callback);
120
    }
121
122
    /**
123
     * Delete the specified queue
124
     * the request will succeed even when the queue does not exist
125
     *
126
     * @param $queueName: the queueName
127
     *
128
     * @return DeleteQueueResponse
129
     */
130
    public function deleteQueue($queueName)
131
    {
132
        $request = new DeleteQueueRequest($queueName);
133
        $response = new DeleteQueueResponse();
134
        return $this->client->sendRequest($request, $response);
135
    }
136
137
    public function deleteQueueAsync($queueName,
138
        AsyncCallback $callback = NULL)
139
    {
140
        $request = new DeleteQueueRequest($queueName);
141
        $response = new DeleteQueueResponse();
142
        return $this->client->sendRequestAsync($request, $response, $callback);
143
    }
144
145
    // API for Topic
146
    /**
147
     * Returns a topic reference for operating on the topic
148
     * this function does not create the topic automatically.
149
     *
150
     * @param string $topicName:  the topic name
151
     *
152
     * @return Topic $topic: the Topic instance
153
     */
154
    public function getTopicRef($topicName)
155
    {
156
        return new Topic($this->client, $topicName);
157
    }
158
159
    /**
160
     * Create Topic and Returns the Topic reference
161
     *
162
     * @param CreateTopicRequest $request:  the TopicName and TopicAttributes
163
     *
164
     * @return CreateTopicResponse $response: the CreateTopicResponse
165
     *
166
     * @throws TopicAlreadyExistException if topic already exists
167
     * @throws InvalidArgumentException if any argument value is invalid
168
     * @throws MnsException if any other exception happends
169
     */
170
    public function createTopic(CreateTopicRequest $request)
171
    {
172
        $response = new CreateTopicResponse($request->getTopicName());
173
        return $this->client->sendRequest($request, $response);
174
    }
175
176
    /**
177
     * Delete the specified topic
178
     * the request will succeed even when the topic does not exist
179
     *
180
     * @param $topicName: the topicName
181
     *
182
     * @return DeleteTopicResponse
183
     */
184
    public function deleteTopic($topicName)
185
    {
186
        $request = new DeleteTopicRequest($topicName);
187
        $response = new DeleteTopicResponse();
188
        return $this->client->sendRequest($request, $response);
189
    }
190
191
    /**
192
     * Query the topics created by current account
193
     *
194
     * @param ListTopicRequest $request: define filters for quering topics
195
     *
196
     * @return ListTopicResponse: the response containing topicNames
197
     */
198
    public function listTopic(ListTopicRequest $request)
199
    {
200
        $response = new ListTopicResponse();
201
        return $this->client->sendRequest($request, $response);
202
    }
203
204
    /**
205
     * Query the AccountAttributes
206
     *
207
     * @return GetAccountAttributesResponse: the response containing topicNames
208
     * @throws MnsException if any exception happends
209
     */
210
    public function getAccountAttributes()
211
    {
212
        $request = new GetAccountAttributesRequest();
213
        $response = new GetAccountAttributesResponse();
214
        return $this->client->sendRequest($request, $response);
215
    }
216
217
    public function getAccountAttributesAsync(AsyncCallback $callback = NULL)
218
    {
219
        $request = new GetAccountAttributesRequest();
220
        $response = new GetAccountAttributesResponse();
221
        return $this->client->sendRequestAsync($request, $response, $callback);
222
    }
223
224
    /**
225
     * Set the AccountAttributes
226
     *
227
     * @param AccountAttributes $attributes: the AccountAttributes to set
228
     *
229
     * @return SetAccountAttributesResponse: the response
230
     *
231
     * @throws MnsException if any exception happends
232
     */
233
    public function setAccountAttributes(AccountAttributes $attributes)
234
    {
235
        $request = new SetAccountAttributesRequest($attributes);
236
        $response = new SetAccountAttributesResponse();
237
        return $this->client->sendRequest($request, $response);
238
    }
239
240
    public function setAccountAttributesAsync(AccountAttributes $attributes,
241
        AsyncCallback $callback = NULL)
242
    {
243
        $request = new SetAccountAttributesRequest($attributes);
244
        $response = new SetAccountAttributesResponse();
245
        return $this->client->sendRequestAsync($request, $response, $callback);
246
    }
247
}
248
249
?>
250