All Downloads are FREE. Search and download functionalities are using the official Maven repository.

objc.apiBodyResponseWithContainer.mustache Maven / Gradle / Ivy

    // {{returnContainer}} container response type
    return [self.apiClient dictionary: requestUrl 
                       method: @"{{httpMethod}}" 
                  queryParams: queryParams 
                         body: bodyDictionary 
                 headerParams: headerParams
                 authSettings: authSettings
           requestContentType: requestContentType
          responseContentType: responseContentType
              completionBlock: ^(NSDictionary *data, NSError *error) {
                if (error) {
                    {{#returnBaseType}}completionBlock(nil, error);{{/returnBaseType}}{{^returnBaseType}}completionBlock(error);{{/returnBaseType}}
                    return;
                }
                {{#isMapContainer}}
                NSDictionary *result = nil;
                if (data) {
                    result = [[NSDictionary alloc]initWithDictionary: data];
                }
                completionBlock(data, nil);
                {{/isMapContainer}}{{#isListContainer}}
                {{#returnBaseType}}if([data isKindOfClass:[NSArray class]]){
                    NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
                    for (NSDictionary* dict in (NSArray*)data) {
                        {{#returnTypeIsPrimitive}}
                        {{returnBaseType}}* d = [[{{{returnBaseType}}} alloc]initWithString: dict];
                        {{/returnTypeIsPrimitive}}
                        {{^returnTypeIsPrimitive}}
                        {{{returnBaseType}}}* d = [[{{{returnBaseType}}} alloc] initWithDictionary:dict error:nil];
                        {{/returnTypeIsPrimitive}}
                        [objs addObject:d];
                    }
                    completionBlock(({{{returnType}}})objs, nil);
                }
                {{/returnBaseType}}
                {{/isListContainer}}
            }];
    




© 2015 - 2025 Weber Informatics LLC | Privacy Policy