1+ <?php
2+ namespace Ctct \Components \Library ;
3+
4+ use Ctct \Components \Component ;
5+
6+ /**
7+ * Represents a single File in a Constant Contact Library
8+ *
9+ * @package Components
10+ * @subpackage Library
11+ * @author Constant Contact
12+ */
13+ class File extends Component {
14+ /**
15+ * The ID of the file
16+ * @var String
17+ */
18+ public $ id ;
19+
20+ /**
21+ * The name of the file
22+ * @var String
23+ */
24+ public $ name ;
25+
26+ /**
27+ * The file's description
28+ * @var String
29+ */
30+ public $ description ;
31+
32+ /**
33+ * The name of the folder that the file is in
34+ * @var String
35+ */
36+ public $ folder ;
37+
38+ /**
39+ * The ID of the folder that the file is in
40+ * @var String
41+ */
42+ public $ folder_id ;
43+
44+ /**
45+ * Is this file an image?
46+ * @var Boolean
47+ */
48+ public $ is_image ;
49+
50+ /**
51+ * Type of the file, must be one of "JPG", "GIF", "PDF", "PNG", "DOC", "XLS", "PPT", "DOCX", "XLSX", "PPTX"
52+ * @var String
53+ */
54+ public $ type ;
55+
56+ /**
57+ * File's height in pixels, if File is an image
58+ * @var int
59+ */
60+ public $ height ;
61+
62+ /**
63+ * File's width in pixels, if File is an image
64+ * @var int
65+ */
66+ public $ width ;
67+
68+ /**
69+ * File's size in bytes
70+ * @var int
71+ */
72+ public $ size ;
73+
74+ /**
75+ * URL of the image hosted by Constant Contact
76+ * @var String
77+ */
78+ public $ url ;
79+
80+ /**
81+ * Source of the image, must be one of "ALL", "MY_COMPUTER", "STOCK_IMAGE", "FACEBOOK", "INSTAGRAM", "SHUTTERSTOCK", "MOBILE"
82+ * @var String
83+ */
84+ public $ source ;
85+
86+ /**
87+ * Status of the file, must be one of "ACTIVE", "PROCESSING", "UPLOADED", "VIRUS_FOUND", "FAILED", "DELETED"
88+ * @var String
89+ */
90+ public $ status ;
91+
92+ /**
93+ * Thumbnail of the file, if File is an image
94+ * @var Thumbnail
95+ */
96+ public $ thumbnail ;
97+
98+ /**
99+ * Date the file was created, in ISO-8601 format
100+ * @var String
101+ */
102+ public $ created_date ;
103+
104+ /**
105+ * Date the file was last modified, in ISO-8601 format
106+ * @var String
107+ */
108+ public $ modified_date ;
109+
110+ public static function create (array $ props ) {
111+ $ file = new File ();
112+
113+ $ file ->id = parent ::getValue ($ props , "id " );
114+ $ file ->name = parent ::getValue ($ props , "name " );
115+ $ file ->description = parent ::getValue ($ props , "description " );
116+ $ file ->folder = parent ::getValue ($ props , "folder " );
117+ $ file ->folder_id = parent ::getValue ($ props , "folder_id " );
118+ $ file ->is_image = parent ::getValue ($ props , "is_image " );
119+ $ file ->type = parent ::getValue ($ props , "file_type " );
120+ $ file ->height = parent ::getValue ($ props , "height " );
121+ $ file ->width = parent ::getValue ($ props , "width " );
122+ $ file ->size = parent ::getValue ($ props , "size " );
123+ $ file ->url = parent ::getValue ($ props , "url " );
124+ $ file ->source = parent ::getValue ($ props , "source " );
125+ $ file ->status = parent ::getValue ($ props , "status " );
126+ if (array_key_exists ("thumbnail " , $ props )) {
127+ $ file ->thumbnail = Thumbnail::create ($ props ['thumbnail ' ]);
128+ }
129+ $ file ->created_date = parent ::getValue ($ props , "created_date " );
130+ $ file ->modified_date = parent ::getValue ($ props , "modified_date " );
131+
132+ return $ file ;
133+ }
134+
135+ /**
136+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
137+ * @return String
138+ */
139+ public function toJson () {
140+ unset($ this ->created_date );
141+ unset($ this ->modified_date );
142+ unset($ this ->status );
143+ return json_encode ($ this );
144+ }
145+ }
0 commit comments