123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // JSWeiboModel.m
- // ModelBenchmark
- //
- // Created by ibireme on 15/9/18.
- // Copyright (c) 2015 ibireme. All rights reserved.
- //
- #import "JSWeiboModel.h"
- #import "DateFormatter.h"
- @implementation JSWeiboPictureMetadata
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"cut_type" : @"cutType" }];
- }
- +(BOOL)propertyIsOptional:(NSString*)propertyName {
- return YES;
- }
- @end
- @implementation JSWeiboPicture
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{
- @"pic_id" : @"picID",
- @"keep_size" : @"keepSize",
- @"photo_tag" : @"photoTag",
- @"object_id" : @"objectID",
- @"middleplus" : @"middlePlus"
- }];
- }
- +(BOOL)propertyIsOptional:(NSString*)propertyName {
- return YES;
- }
- @end
- @implementation JSWeiboURL
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{
- @"ori_url" : @"oriURL",
- @"url_title" : @"urlTitle",
- @"url_type_pic" : @"urlTypePic",
- @"url_type" : @"urlType",
- @"short_url" : @"shortURL",
- @"actionlog" : @"actionLog",
- @"page_id" : @"pageID",
- @"storage_type" : @"storageType"
- }];
- }
- +(BOOL)propertyIsOptional:(NSString*)propertyName {
- return YES;
- }
- @end
- @implementation JSWeiboUser
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{
- @"id" : @"userID",
- @"idstr" : @"idString",
- @"gender" : @"genderString",
- @"bi_followers_count" : @"biFollowersCount",
- @"profile_image_url" : @"profileImageURL",
- @"class" : @"uclass",
- @"verified_contact_email" : @"verifiedContactEmail",
- @"statuses_count" : @"statusesCount",
- @"geo_enabled" : @"geoEnabled",
- @"follow_me" : @"followMe",
- @"cover_image_phone" : @"coverImagePhone",
- @"description" : @"desc",
- @"followers_count" : @"followersCount",
- @"verified_contact_mobile" : @"verifiedContactMobile",
- @"avatar_large" : @"avatarLarge",
- @"verified_trade" : @"verifiedTrade",
- @"profile_url" : @"profileURL",
- @"cover_image" : @"coverImage",
- @"online_status" : @"onlineStatus",
- @"badge_top" : @"badgeTop",
- @"verified_contact_name" : @"verifiedContactName",
- @"screen_name" : @"screenName",
- @"verified_source_url" : @"verifiedSourceURL",
- @"pagefriends_count" : @"pagefriendsCount",
- @"vverified_reason" : @"erifiedReason",
- @"friends_count" : @"friendsCount",
- @"block_app" : @"blockApp",
- @"has_ability_tag" : @"hasAbilityTag",
- @"avatar_hd" : @"avatarHD",
- @"credit_score" : @"creditScore",
- @"created_at" : @"createdAt",
- @"block_word" : @"blockWord",
- @"allow_all_act_msg" : @"allowAllActMsg",
- @"verified_state" : @"verifiedState",
- @"verified_reason_modified" : @"verifiedReasonModified",
- @"allow_all_comment" : @"allowAllComment",
- @"verified_level" : @"verifiedLevel",
- @"verified_reason_url" : @"verifiedReasonURL",
- @"favourites_count" : @"favouritesCount",
- @"verified_type" : @"verifiedType",
- @"verified_source" : @"verifiedSource",
- @"user_ability" : @"userAbility"}];
- }
- +(BOOL)propertyIsOptional:(NSString*)propertyName {
- return YES;
- }
- @end
- @implementation JSWeiboStatus
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{
- @"id" : @"statusID",
- @"created_at" : @"createdAt",
- @"attitudes_status" : @"attitudesStatus",
- @"in_reply_to_screen_name" : @"inReplyToScreenName",
- @"source_type" : @"sourceType",
- @"comments_count" : @"commentsCount",
- @"recom_state" : @"recomState",
- @"source_allowclick" : @"sourceAllowClick",
- @"biz_feature" : @"bizFeature",
- @"mblogtypename" : @"mblogTypeName",
- @"url_struct" : @"urlStruct",
- @"mblogtype" : @"mblogType",
- @"in_reply_to_status_id" : @"inReplyToStatusId",
- @"pic_ids" : @"picIds",
- @"reposts_count" : @"repostsCount",
- @"attitudes_count" : @"attitudesCount",
- @"darwin_tags" : @"darwinTags",
- @"userType" : @"userType",
- @"pic_infos" : @"picInfos",
- @"in_reply_to_user_id" : @"inReplyToUserId"
- }];
- }
- +(BOOL)propertyIsOptional:(NSString*)propertyName {
- return YES;
- }
- @end
- /**
- JSONModel use a global transformer to transform value...
- But how to create a custom transformer for a specified model ?!!!!
- */
- @interface JSONValueTransformer(CustomDate)
- -(NSDate*)__NSDateFromNSString:(NSString*)string;
- @end
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wincomplete-implementation"
- @implementation JSONValueTransformer (CustomDate)
- - (NSDate *)NSDateFromNSString:(NSString *)string {
- if (string.length == 30) {
- return [[DateFormatter weiboDataFormatter] dateFromString:string];
- } else {
- return [self __NSDateFromNSString:string];
- }
- }
- @end
- #pragma clang diagnostic pop
|