GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — contentstack-ios/Contentstack/Taxonomy.m at master · contentstack/contentstack-ios
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Expand file tree/ Copy pathTaxonomy.mMore file actions 90 lines (78 loc) · 3.15 KB / Copy pathTaxonomy.mFile metadata and controls90 lines (78 loc) · 3.15 KB 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 // // Taxonomy.m // Contentstack // // Created by Vikram Kalta on 27/07/2024. // Copyright © 2024 Contentstack. All rights reserved. // #import "Taxonomy.h" #import "CSIOInternalHeaders.h" #import "CSIOConstants.h" #import "CSIOCoreHTTPNetworking.h" #import "CSIOAPIURLs.h" #import "NSObject+Extensions.h" #import "Stack.h" #import "Query.h" @interface Taxonomy () @property (nonatomic, strong, getter=stack) Stack *csStack; @end @implementation Taxonomy -(instancetype)initWithStack:(Stack*)stack { if (self = [super init]) { _csStack = stack; _postParamDictionary = [NSMutableDictionary dictionary]; _headers = [NSMutableDictionary dictionary]; } return self; } -(Entry*)entry { Entry *entry = [[Entry alloc] initWithTaxonomy:self]; return entry; } -(Query*)query { Query *query = [[Query alloc] initWithTaxonomy:self]; return query; } //MARK: - Headers - (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey { [self.headers setObject:headerValue forKey:headerKey]; } - (void)addHeadersWithDictionary:(NSDictionary<NSString *,NSString *> *)headers { [headers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [self.headers setObject:obj forKey:key]; }]; } - (void)removeHeaderForKey:(NSString *)headerKey { if (self.headers[headerKey]) { [self.headers removeObjectForKey:headerKey]; } } //MARK: - Get entries - (void)fetch:(NSDictionary<NSString *, id> * _Nullable)params completion:(void (^)(NSDictionary<NSString *,NSString *> * _Nullable, NSError * _Nullable))completionBlock { NSString *path = [CSIOAPIURLs fetchTaxonomyWithVersion:self.stack.version]; [self.postParamDictionary setObject:_csStack.environment forKey:kCSIO_Environment]; NSMutableDictionary *paramDictionary = [NSMutableDictionary dictionaryWithDictionary:self.postParamDictionary]; for (NSString* key in params) { [paramDictionary setValue:[params valueForKey:key] forKey:key]; } NSURLSessionDataTask *op = [self.stack.network requestForStack:self.stack withURLPath:path requestType:CSIOCoreNetworkingRequestTypeGET params:paramDictionary additionalHeaders:self.stack.stackHeaders completion:^(ResponseType responseType, id responseJSON, NSError *error) { if (completionBlock) { if (error) { completionBlock(nil, error); } else { NSDictionary *responseData = responseJSON; if ([[responseData allKeys] containsObject:@"entries"] && [responseData objectForKey:@"entries"] != nil && [[responseData objectForKey:@"entries"] isKindOfClass:[NSDictionary class]]) { completionBlock([responseData objectForKey:@"entries"], nil); } else { NSError *error = [NSError errorWithDomain:@"Error" code:-4001 userInfo:@{@"error": @"Failed to retrieve data"}]; completionBlock(nil, error); } } } }]; if (op && ![op isKindOfClass:[NSNull class]]) { [self.stack.requestOperationSet addObject:op]; } } @end |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |