summaryrefslogtreecommitdiff
path: root/Juick/Model/Attachment.m
blob: 006b72ee175734bb3912bbc5455c13be4dc9189f (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
//
//  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 {
    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;
}

@end