123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // FKBrandSubscribeRequest.m
- // FirstLink
- //
- // Created by ascii on 16/4/25.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKBrandSubscribeRequest.h"
- @implementation FKBrandSubscribeRequest
- + (void)requestBrandWithCategoryID:(NSString *)categoryID
- subscribe:(NSString *)subscribe
- identify:(int)identify
- delegate:(id<FLNetworkDelegate>)delegate {
- NSString *urlString = [NSString stringWithFormat:@"%@/link-site/api/search/search_brand_by_category.json", [[FKServerUtil sharedInstance] apiServer]];
- NSString *itemJson = [FLRequestHelper JSONStringWithKeys:@[@"front_category_id", @"subscribe"]
- values:@[[FLStringHelper replaceNilWithEmpty:categoryID], [FLStringHelper replaceNilWithEmpty:subscribe]]];
-
- NSMutableDictionary *para = [NSMutableDictionary dictionary];
- [para setValue:itemJson forKey:@"search_json"];
- [para addEntriesFromDictionary:[FLRequestHelper commonParamater]];
-
- [[FLDataCenter sharedDataCenter] POST:urlString para:para identify:identify delegate:delegate];
- }
- + (void)requestMyBrand:(int)identify delegate:(id<FLNetworkDelegate>)delegate {
- NSString *urlString = [NSString stringWithFormat:@"%@/link-site/api/subscribe/my_subscribe_brands.json", [[FKServerUtil sharedInstance] apiServer]];
-
- [[FLDataCenter sharedDataCenter] POST:urlString para:[FLRequestHelper commonParamater] identify:identify delegate:delegate];
- }
- + (void)requestCreateSubscribe:(NSArray *)ids identify:(int)identify delegate:(id<FLNetworkDelegate>)delegate {
- NSString *urlString = [NSString stringWithFormat:@"%@/link-site/api/subscribe/create_subscribe.json", [[FKServerUtil sharedInstance] apiServer]];
-
- NSString *itemJson = [FKBrandSubscribeRequest subscribeJSONString:ids];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setValue:[FLStringHelper replaceNilWithEmpty:itemJson] forKey:@"subscribe_json"];
- [dict addEntriesFromDictionary:[FLRequestHelper commonParamater]];
-
- [[FLDataCenter sharedDataCenter] POST:urlString para:dict identify:identify delegate:delegate];
- }
- + (void)requestCancelSubscribe:(NSArray *)ids identify:(int)identify delegate:(id<FLNetworkDelegate>)delegate {
- NSString *urlString = [NSString stringWithFormat:@"%@/link-site/api/subscribe/cancel_subscribe.json", [[FKServerUtil sharedInstance] apiServer]];
-
- NSString *itemJson = [FKBrandSubscribeRequest subscribeJSONString:ids];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setValue:[FLStringHelper replaceNilWithEmpty:itemJson] forKey:@"subscribe_json"];
- [dict addEntriesFromDictionary:[FLRequestHelper commonParamater]];
-
- [[FLDataCenter sharedDataCenter] POST:urlString para:dict identify:identify delegate:delegate];
- }
- + (NSString *)subscribeJSONString:(NSArray *)ids {
- NSMutableArray *mutableArray = [NSMutableArray array];
- NSMutableDictionary *dict;
-
- for (NSString *value in ids) {
- dict = [NSMutableDictionary dictionary];
- [dict setValue:@"14" forKey:@"type"];
- [dict setValue:value forKey:@"value"];
-
- [mutableArray addObject:dict];
- }
-
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:mutableArray
- options:NSJSONWritingPrettyPrinted
- error:&error];
-
- if (!jsonData) {
- return nil;
- }
-
- return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
- @end
|