summaryrefslogtreecommitdiff
path: root/Juick/Model/Attachment.m
blob: e0de2ca293edf573cfc6177f2c99648b035d89d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
//  Attachment.m
//  Juick
//
//  Created by Vitaly Takmazov on 15/10/2017.
//  Copyright © 2017 com.juick. All rights reserved.
//

#import "Attachment.h"

@implementation Attachment

+(Attachment *) fromJSON:(NSDictionary *)jsonData {
    if (jsonData[@"url"]) {
        Attachment *attachment = [Attachment new];
        attachment.url = jsonData[@"url"];
        attachment.width = jsonData[@"width"];
        attachment.height = jsonData[@"height"];
        if (jsonData[@"small"]) {
            attachment.small = [Attachment fromJSON:jsonData[@"small"]];
        }
        if (jsonData[@"medium"]) {
            attachment.medium = [Attachment fromJSON:jsonData[@"medium"]];
        }
        if (jsonData[@"thumbnail"]) {
            attachment.thumbnail = [Attachment fromJSON:jsonData[@"thumbnail"]];
        }
        return attachment;
    }
    return nil;
}

@end