Skip to content

Commit 73cf9b7

Browse files
author
David Albrecht
committed
implements changeProfile API call
1 parent 83a8f63 commit 73cf9b7

File tree

4 files changed

+155
-0
lines changed

4 files changed

+155
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ $result = $this->service->getListings([
3939
$result = $this->service->follow(
4040
['guid' => 'a06aa22a38f0e62221ab74464c311bd88305f88c']
4141
);
42+
// change your username
43+
$result = $this->service->changeProfile(
44+
['name' => 'New Name']
45+
);
4246
?>
4347
```
4448
It is necessary to run the login first. After that you can run more api-calls without worrying about the authentication, since the cookie is persisted.

resources/service.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,98 @@
149149
]
150150
]
151151
],
152+
'changeProfile' => [
153+
'httpMethod' => 'POST',
154+
'uri' => 'api/v1/profile',
155+
'responseModel' => 'GetResponse',
156+
'parameters' => [
157+
'name' => [
158+
'type' => 'string',
159+
'location' => 'postField',
160+
'required' => false
161+
],
162+
'location' => [
163+
'type' => 'string',
164+
'location' => 'postField',
165+
'required' => false
166+
],
167+
'handle' => [
168+
'type' => 'string',
169+
'location' => 'postField',
170+
'required' => false
171+
],
172+
'about' => [
173+
'type' => 'string',
174+
'location' => 'postField',
175+
'required' => false
176+
],
177+
'short_description' => [
178+
'type' => 'string',
179+
'location' => 'postField',
180+
'required' => false
181+
],
182+
'nsfw' => [
183+
'type' => 'boolean',
184+
'location' => 'postField',
185+
'required' => false
186+
],
187+
'vendor' => [
188+
'type' => 'boolean',
189+
'location' => 'postField',
190+
'required' => false
191+
],
192+
'moderator' => [
193+
'type' => 'boolean',
194+
'location' => 'postField',
195+
'required' => false
196+
],
197+
'website' => [
198+
'type' => 'string',
199+
'location' => 'postField',
200+
'required' => false
201+
],
202+
'email' => [
203+
'type' => 'string',
204+
'location' => 'postField',
205+
'required' => false
206+
],
207+
'primary_color' => [
208+
'type' => 'string',
209+
'location' => 'postField',
210+
'required' => false
211+
],
212+
'secondary_color' => [
213+
'type' => 'string',
214+
'location' => 'postField',
215+
'required' => false
216+
],
217+
'text_color' => [
218+
'type' => 'string',
219+
'location' => 'postField',
220+
'required' => false
221+
],
222+
'background_color' => [
223+
'type' => 'string',
224+
'location' => 'postField',
225+
'required' => false
226+
],
227+
'avatar' => [
228+
'type' => 'string',
229+
'location' => 'postField',
230+
'required' => false
231+
],
232+
'header' => [
233+
'type' => 'string',
234+
'location' => 'postField',
235+
'required' => false
236+
],
237+
'pgp_key' => [
238+
'type' => 'string',
239+
'location' => 'postField',
240+
'required' => false
241+
]
242+
]
243+
],
152244
],
153245
'models' => [
154246
'GetResponse' => [

tests/OpenBazaar/ClientTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,49 @@ public function testUnfollow()
138138
[]
139139
);
140140
}
141+
public function testChangeFailure()
142+
{
143+
$history = new History();
144+
$client = $this->createClient('change_profile_failure', $history);
145+
$this->setExpectedException('GuzzleHttp\Command\Exception\CommandException', 'Validation errors: [name] must be of type string
146+
[location] must be of type string
147+
[handle] must be of type string
148+
[about] must be of type string
149+
[short_description] must be of type string
150+
[nsfw] must be of type boolean
151+
[vendor] must be of type boolean
152+
[moderator] must be of type boolean
153+
[website] must be of type string
154+
[email] must be of type string
155+
[primary_color] must be of type string
156+
[secondary_color] must be of type string
157+
[text_color] must be of type string
158+
[background_color] must be of type string
159+
[avatar] must be of type string
160+
[header] must be of type string
161+
[pgp_key] must be of type string');
162+
$response = $client->changeProfile(
163+
[
164+
'name' => false,
165+
'location' => false,
166+
'handle' => false,
167+
'about' => false,
168+
'short_description' => false,
169+
'nsfw' => 'string',
170+
'vendor' => 'string',
171+
'moderator' => 'string',
172+
'website' => false,
173+
'email' => false,
174+
'primary_color' => false,
175+
'secondary_color' => false,
176+
'text_color' => false,
177+
'background_color' => false,
178+
'avatar' => false,
179+
'header' => false,
180+
'pgp_key' => false,
181+
]
182+
);
183+
}
141184

142185
protected function createClient($mock, History $history)
143186
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 200 OK
2+
Reproxy-Status: yes
3+
Access-Control-Allow-Origin: *
4+
Cache-Control: public, must-revalidate
5+
Content-Type: application/json
6+
Server: lighttpd
7+
Content-Length: 5103
8+
Date: Mon, 28 Jul 2014 18:40:39 GMT
9+
X-Varnish: 1913846781 1913780733
10+
Age: 259
11+
Via: 1.1 varnish
12+
Connection: close
13+
14+
{
15+
"success": true
16+
}

0 commit comments

Comments
 (0)