|
| 1 | +// |
| 2 | +// Taxonomy.h |
| 3 | +// Contentstack |
| 4 | +// |
| 5 | +// Created by Vikram Kalta on 27/07/2024. |
| 6 | +// Copyright © 2024 Contentstack. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <Foundation/Foundation.h> |
| 10 | +#import "ContentstackDefinitions.h" |
| 11 | + |
| 12 | +@class Query; |
| 13 | + |
| 14 | +BUILT_ASSUME_NONNULL_BEGIN |
| 15 | + |
| 16 | +@interface Taxonomy : NSObject |
| 17 | + |
| 18 | +- (instancetype)init UNAVAILABLE_ATTRIBUTE; |
| 19 | + |
| 20 | +//MARK: - Manually set headers |
| 21 | +/**--------------------------------------------------------------------------------------- |
| 22 | + * @name Manually set headers |
| 23 | + * --------------------------------------------------------------------------------------- |
| 24 | + */ |
| 25 | + |
| 26 | +/** |
| 27 | +Set a header for ContentType |
| 28 | + |
| 29 | + //Obj-C |
| 30 | + [contentTypeObj setHeader:@"MyValue" forKey:@"My-Custom-Header"]; |
| 31 | + //Swift |
| 32 | + contentTypeObj.setHeader("MyValue", forKey: "My-Custom-Header") |
| 33 | +@param headerValue The header key |
| 34 | +@param headerKey The header value |
| 35 | +*/ |
| 36 | +- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey; |
| 37 | +/** |
| 38 | +Set a header for ContentType |
| 39 | + |
| 40 | + //Obj-C |
| 41 | + [contentTypeObj addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}]; |
| 42 | + |
| 43 | + //Swift |
| 44 | + contentTypeObj.addHeadersWithDictionary(["My-Custom-Header":"MyValue"]) |
| 45 | + |
| 46 | + |
| 47 | + @param headers The headers as dictionary which needs to be added to the application |
| 48 | + */ |
| 49 | +- (void)addHeadersWithDictionary:(NSDictionary<NSString *, NSString *> *)headers; |
| 50 | +/** |
| 51 | +Removes a header from this ContentType. |
| 52 | + |
| 53 | + //Obj-C |
| 54 | + [contentTypeObj removeHeaderForKey:@"My-Custom-Header"]; |
| 55 | + |
| 56 | + //Swift |
| 57 | + contentTypeObj.removeHeaderForKey("My-Custom-Header") |
| 58 | + |
| 59 | + @param headerKey The header key that needs to be removed |
| 60 | + */ |
| 61 | +- (void)removeHeaderForKey:(NSString *)headerKey; |
| 62 | +//MARK: - Query |
| 63 | +/**--------------------------------------------------------------------------------------- |
| 64 | + * @name Query |
| 65 | + * --------------------------------------------------------------------------------------- |
| 66 | + */ |
| 67 | + |
| 68 | +/** |
| 69 | +Represents a Query on 'ContentType' which can be executed to retrieve entries that pass the query condition |
| 70 | + //Obj-C |
| 71 | + Query *queryObj = [contentTypeObj query]; |
| 72 | + |
| 73 | + //Swift |
| 74 | + var queryObj:Query = contentTypeObj.query() |
| 75 | + |
| 76 | + @return Returns new Query instance |
| 77 | + */ |
| 78 | +- (Query*)query; |
| 79 | + |
| 80 | +//MARK: - Content-Type Schema |
| 81 | +/**--------------------------------------------------------------------------------------- |
| 82 | + * @name ContentType Schema |
| 83 | + * --------------------------------------------------------------------------------------- |
| 84 | + */ |
| 85 | +/** |
| 86 | + Gets ContentType Schema defination. |
| 87 | + |
| 88 | + //Obj-C |
| 89 | + |
| 90 | + ContentType * contentType = [stack contentTypeWithName:@"<content_type_id>"] |
| 91 | + [contentType fetch:params completion:^(NSDictionary * _Nullable contentType, NSError * _Nullable error) { |
| 92 | + |
| 93 | + }]; |
| 94 | + |
| 95 | + //Swift |
| 96 | + |
| 97 | + let contentType = stack.contentTypeWithName("<content_type_id>") |
| 98 | + contentType.fetch(params, { (contentType, error) in |
| 99 | + |
| 100 | + }) |
| 101 | + @param completionBlock block to be called once operation is done. |
| 102 | + */ |
| 103 | +- (void)fetch:(NSDictionary<NSString *, id> * _Nullable)params completion:(void (^)(NSDictionary<NSString *, NSString *> * |
| 104 | + BUILT_NULLABLE_P contentType, |
| 105 | + NSError * BUILT_NULLABLE_P error))completionBlock; |
| 106 | +@end |
| 107 | + |
| 108 | +BUILT_ASSUME_NONNULL_END |
0 commit comments