Skip to content

Commit a5791b5

Browse files
committed
Added notifications. Fixed comments
1 parent b931849 commit a5791b5

10 files changed

+108
-20
lines changed

Imgur.php

+14
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,24 @@ function comment($id)
139139
return $comment;
140140
}
141141

142+
/**
143+
* Messages wrapper
144+
* @return Message
145+
*/
142146
function message()
143147
{
144148
$msg = new Message($this->conn, $this->api_endpoint);
145149
return $msg;
146150
}
147151

152+
/**
153+
* Notifications wrapper
154+
* @return mixed
155+
*/
156+
function notification()
157+
{
158+
$notification = new Notification($this->conn, $this->api_endpoint);
159+
return $notification;
160+
}
161+
148162
}

classes/Authorize.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class Authorize
2121
*/
2222
protected $conn;
2323
/**
24-
* @var
24+
* @var string
2525
*/
2626
protected $access_token;
2727
/**
28-
* @var
28+
* @var string
2929
*/
3030
protected $refresh_token;
3131
/**

classes/Comment.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class Comment
2020
protected $id;
2121

2222
/**
23-
* @param $id
23+
* @param string $id
2424
* @param $connection
25-
* @param $endpoint
25+
* @param string $endpoint
2626
*/
2727
function __construct($id, $connection, $endpoint)
2828
{

classes/Connect.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ class Connect
1212
{
1313

1414
/**
15-
* @var
15+
* @var array
1616
*/
1717
protected $options;
1818
/**
19-
* @var
19+
* @var string
2020
*/
2121
protected $api_key;
2222
/**
23-
* @var
23+
* @var string
2424
*/
2525
protected $api_secret;
2626
/**
27-
* @var
27+
* @var string
2828
*/
2929
protected $api_endpoint;
3030
/**
31-
* @var
31+
* @var string
3232
*/
3333
protected $access_token;
3434
/**
35-
* @var
35+
* @var string
3636
*/
3737
protected $refresh_token;
3838
/**
@@ -42,8 +42,8 @@ class Connect
4242

4343
/**
4444
* Constructor
45-
* @param $api_key
46-
* @param $api_secret
45+
* @param string $api_key
46+
* @param string $api_secret
4747
*/
4848
function __construct($api_key, $api_secret)
4949
{

classes/Gallery.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Gallery
1818
/**
1919
* Cosntructor
2020
* @param $connection
21-
* @param $endpoint
21+
* @param string $endpoint
2222
*/
2323
function __construct($connection, $endpoint)
2424
{
@@ -174,7 +174,7 @@ function votes($id, $type = "image")
174174

175175
/**
176176
* Vote on Image | ALbum. Votes can be either up or down.
177-
* @param $id
177+
* @param string $id
178178
* @param string $type
179179
* @param string $vote
180180
* @return mixed
@@ -200,6 +200,7 @@ function comments($id, $type)
200200
}
201201

202202
/**
203+
* Get a comment to an image in gallery
203204
* @param $image_id
204205
* @param $type
205206
* @param $comment_id

classes/Image.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ class Image
1515
*/
1616
protected $conn;
1717
/**
18-
* @var
18+
* @var string
1919
*/
2020
protected $endpoint;
2121
/**
22-
* @var
22+
* @var string
2323
*/
2424
protected $id;
2525

2626
/**
27-
* @param $id
27+
* @param string $id
2828
* @param $connection
29-
* @param $endpoint
29+
* @param string $endpoint
3030
*/
3131
function __construct($id, $connection, $endpoint)
3232
{

classes/Message.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function get_thread($id)
9191

9292
/**
9393
* Create a new mesage
94-
* @param $options
94+
* @param array $options
9595
* @return mixed
9696
*/
9797
function create($options)

classes/Notification.php

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* PHP Imgur wrapper 0.1
4+
* Imgur API wrapper for easy use.
5+
* @author Vadim Kr.
6+
* @copyright (c) 2013 bndr
7+
* @license http://creativecommons.org/licenses/by-sa/3.0/legalcode
8+
*/
9+
class Notification
10+
{
11+
12+
/**
13+
* @var
14+
*/
15+
protected $conn;
16+
17+
/**
18+
* @param $connection
19+
* @param $endpoint
20+
*/
21+
function __construct($connection, $endpoint)
22+
{
23+
$this->conn = $connection;
24+
$this->endpoint = $endpoint;
25+
}
26+
27+
/**
28+
* Get all notifications. Either new or all notifications.
29+
* @param boolean $new
30+
* @return mixed
31+
*/
32+
function all($new)
33+
{
34+
$uri = $this->endpoint . "/notification?new=" . ($new == true) ? "true" : "false";
35+
36+
return $this->conn->request($uri);
37+
}
38+
39+
/**
40+
* Get single notification data
41+
* @param string $id
42+
* @return mixed
43+
*/
44+
function single($id)
45+
{
46+
$uri = $this->endpoint . "/notification/" . $id;
47+
48+
return $this->conn->request($uri);
49+
}
50+
51+
/**
52+
* Mark notification as read by id
53+
* @param string $id
54+
* @return mixed
55+
*/
56+
function mark_as_read($id)
57+
{
58+
$uri = $this->endpoint . "/notification";
59+
60+
return $this->conn->request($uri, array("mark_as_read" => true), "PUT");
61+
}
62+
63+
64+
}

classes/Upload.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Upload
1212
{
1313

1414
/**
15-
* @var Connection $conn;
15+
* @var Connect $conn;
1616
*/
1717
protected $conn;
1818
/**

examples.php

+9
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,12 @@
9393
$imgur->upload()->file("/path/to/file", $postfields); //Postfields look in http://api.imgur.com/endpoints/image#image-upload
9494
$imgur->upload()->string("base64encodedstring,$postfields");
9595
$imgur->upload()->url("http://urlofimage.com", $postfields);
96+
97+
98+
/*-----------------------------------------------------------------------------------*/
99+
/* Notifications
100+
/*-----------------------------------------------------------------------------------*/
101+
102+
$imgur->notification()->all();
103+
$imgur->notification()->single($id);
104+
$imgur->notification()->mark_as_read($id);

0 commit comments

Comments
 (0)