1<?php
2namespace Kunnu\Dropbox\Models;
3
4class FileMetadata extends BaseModel
5{
6
7    /**
8     * A unique identifier of the file
9     *
10     * @var string
11     */
12    protected $id;
13
14    /**
15     * The last component of the path (including extension).
16     *
17     * @var string
18     */
19    protected $name;
20
21    /**
22     * A unique identifier for the current revision of a file.
23     * This field is the same rev as elsewhere in the API and
24     * can be used to detect changes and avoid conflicts.
25     *
26     * @var string
27     */
28    protected $rev;
29
30    /**
31     * The file size in bytes.
32     *
33     * @var int
34     */
35    protected $size;
36
37    /**
38     * The lowercased full path in the user's Dropbox.
39     *
40     * @var string
41     */
42    protected $path_lower;
43
44    /**
45     * Additional information if the file is a photo or video.
46     *
47     * @var \Kunnu\Dropbox\Models\MediaInfo
48     */
49    protected $media_info;
50
51    /**
52     * Set if this file is contained in a shared folder.
53     *
54     * @var \Kunnu\Dropbox\Models\FileSharingInfo
55     */
56    protected $sharing_info;
57
58    /**
59     * The cased path to be used for display purposes only.
60     *
61     * @var string
62     */
63    protected $path_display;
64
65    /**
66     * For files, this is the modification time set by the
67     * desktop client when the file was added to Dropbox.
68     *
69     * @var string
70     */
71    protected $client_modified;
72
73    /**
74     * The last time the file was modified on Dropbox.
75     *
76     * @var string
77     */
78    protected $server_modified;
79
80    /**
81     * This flag will only be present if
82     * include_has_explicit_shared_members is true in
83     * list_folder or get_metadata. If this flag is present,
84     * it will be true if this file has any explicit shared
85     * members. This is different from sharing_info in that
86     * this could be true in the case where a file has explicit
87     * members but is not contained within a shared folder.
88     *
89     * @var bool
90     */
91    protected $has_explicit_shared_members;
92
93
94    /**
95     * Create a new FileMetadata instance
96     *
97     * @param array $data
98     */
99    public function __construct(array $data)
100    {
101        parent::__construct($data);
102        $this->id = $this->getDataProperty('id');
103        $this->rev = $this->getDataProperty('rev');
104        $this->name = $this->getDataProperty('name');
105        $this->size = $this->getDataProperty('size');
106        $this->path_lower = $this->getDataProperty('path_lower');
107        $this->path_display = $this->getDataProperty('path_display');
108        $this->client_modified = $this->getDataProperty('client_modified');
109        $this->server_modified = $this->getDataProperty('server_modified');
110        $this->has_explicit_shared_members = $this->getDataProperty('has_explicit_shared_members');
111
112        //Make MediaInfo
113        $mediaInfo = $this->getDataProperty('media_info');
114        if (is_array($mediaInfo)) {
115            $this->media_info = new MediaInfo($mediaInfo);
116        }
117
118        //Make SharingInfo
119        $sharingInfo = $this->getDataProperty('sharing_info');
120        if (is_array($sharingInfo)) {
121            $this->sharing_info = new FileSharingInfo($sharingInfo);
122        }
123    }
124
125    /**
126     * Get the 'id' property of the file model.
127     *
128     * @return string
129     */
130    public function getId()
131    {
132        return $this->id;
133    }
134
135    /**
136     * Get the 'name' property of the file model.
137     *
138     * @return string
139     */
140    public function getName()
141    {
142        return $this->name;
143    }
144
145    /**
146     * Get the 'rev' property of the file model.
147     *
148     * @return string
149     */
150    public function getRev()
151    {
152        return $this->rev;
153    }
154
155    /**
156     * Get the 'size' property of the file model.
157     *
158     * @return int
159     */
160    public function getSize()
161    {
162        return $this->size;
163    }
164
165    /**
166     * Get the 'path_lower' property of the file model.
167     *
168     * @return string
169     */
170    public function getPathLower()
171    {
172        return $this->path_lower;
173    }
174
175    /**
176     * Get the 'media_info' property of the file model.
177     *
178     * @return \Kunnu\Dropbox\Models\MediaInfo
179     */
180    public function getMediaInfo()
181    {
182        return $this->media_info;
183    }
184
185    /**
186     * Get the 'sharing_info' property of the file model.
187     *
188     * @return \Kunnu\Dropbox\Models\FileSharingInfo
189     */
190    public function getSharingInfo()
191    {
192        return $this->sharing_info;
193    }
194
195    /**
196     * Get the 'path_display' property of the file model.
197     *
198     * @return string
199     */
200    public function getPathDisplay()
201    {
202        return $this->path_display;
203    }
204
205    /**
206     * Get the 'client_modified' property of the file model.
207     *
208     * @return string
209     */
210    public function getClientModified()
211    {
212        return $this->client_modified;
213    }
214
215    /**
216     * Get the 'server_modified' property of the file model.
217     *
218     * @return string
219     */
220    public function getServerModified()
221    {
222        return $this->server_modified;
223    }
224
225    /**
226     * Get the 'has_explicit_shared_members' property of the file model.
227     *
228     * @return bool
229     */
230    public function hasExplicitSharedMembers()
231    {
232        return $this->has_explicit_shared_members;
233    }
234}
235