use of org.applause.lang.applauseDsl.RESTSpecification in project applause by applause.
the class EntityDataAccessModuleFileCompiler method compilePUTMethod.
public CharSequence compilePUTMethod(final DataSourceAccessMethod it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("static NSString *const ");
String _urlConstantForRESTMethod = this.urlConstantForRESTMethod(it);
_builder.append(_urlConstantForRESTMethod, "");
_builder.append(" = @\"");
RESTSpecification _restSpecification = it.getRestSpecification();
RESTURL _path = _restSpecification.getPath();
String _value = this._rESTURLExtensions.value(_path);
_builder.append(_value, "");
_builder.append("\";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("- (void)");
String _name = it.getName();
_builder.append(_name, "");
_builder.append(":(void (^)(");
String _parameterList = this._entityDataAccessExtensions.parameterList(it);
_builder.append(_parameterList, "");
_builder.append(", NSError *error))block");
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("NSDictionary *elementDictionary = [self attributes];");
_builder.newLine();
_builder.append("\t");
_builder.append("[[");
Entity _resourceType = this._entityDataAccessExtensions.resourceType(it);
String _apiClientClassName = this._aPIClientClassExtensions.apiClientClassName(_resourceType);
_builder.append(_apiClientClassName, " ");
_builder.append(" sharedClient] PUT:");
String _urlConstantForRESTMethod_1 = this.urlConstantForRESTMethod(it);
_builder.append(_urlConstantForRESTMethod_1, " ");
_builder.append(" parameters:elementDictionary success:^(NSURLSessionDataTask *task, id responseObject)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
Entity _resourceType_1 = this._entityDataAccessExtensions.resourceType(it);
String _typeName = this._typeExtensions.typeName(_resourceType_1);
_builder.append(_typeName, " ");
_builder.append(" *postedElement = responseObject;");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(postedElement, nil);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(nil, error);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}];");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
Aggregations