コード例 #1
0
    def test_create_swift_id_parameter(self):
        request_object = DataObject("$postRequest", {
            "title": "string"
        })
        self.assertIsNone(SwiftParameter.create_id_parameter("/post/", request_object))
        self.assertIsNotNone(SwiftParameter.create_id_parameter("/post/:id/", request_object))

        request_object = DataObject("$postUpdateRequest", {
            "id": "int,primarykey",
            "title": "string"
        })
        self.assertIsNone(SwiftParameter.create_id_parameter("/post/:id/", request_object))
コード例 #2
0
ファイル: test_parameters.py プロジェクト: yeti/signals
    def test_create_swift_id_parameter(self):
        request_object = DataObject("$postRequest", {"title": "string"})
        self.assertIsNone(
            SwiftParameter.create_id_parameter("/post/", request_object))
        self.assertIsNotNone(
            SwiftParameter.create_id_parameter("/post/:id/", request_object))

        request_object = DataObject("$postUpdateRequest", {
            "id": "int,primarykey",
            "title": "string"
        })
        self.assertIsNone(
            SwiftParameter.create_id_parameter("/post/:id/", request_object))
コード例 #3
0
    def method_parameters(api):
        parameters = []

        # Create request object parameters
        request_object = iOSTemplateMethods.get_api_request_object(api)
        if request_object:
            parameters.extend(
                SwiftParameter.generate_field_parameters(request_object))
            parameters.extend(
                SwiftParameter.generate_relationship_parameters(
                    request_object))

        # Add id parameter if we need it
        id_parameter = SwiftParameter.create_id_parameter(
            api.url_path, request_object)
        if id_parameter:
            parameters.append(id_parameter)

        # Add required RestKit parameters
        parameters.extend([
            SwiftParameter(name="success", swift_type="RestKitSuccess"),
            SwiftParameter(name="failure", swift_type="RestKitError")
        ])

        return SwiftTemplateMethods.create_parameter_signature(parameters)
コード例 #4
0
    def method_name(api):
        # First create camel cased name from snake case
        method_name_string = ""
        for part in re.split(r'[/_]+', api.url_path):
            if part in [":id", "theID"]:
                continue
            else:
                method_name_string += part.capitalize()

        first_parameter_name = "Success"
        request_object = iOSTemplateMethods.get_api_request_object(api)
        if request_object and len(request_object.properties()) > 0:
            first_field = request_object.properties()[0]
            first_parameter_name = get_proper_name(first_field.name, capitalize_first=True)
        elif ObjCParameter.create_id_parameter(api.url_path, request_object) is not None:
            first_parameter_name = "TheID"
        elif SwiftParameter.create_id_parameter(api.url_path, request_object) is not None:
            first_parameter_name = "TheID"

        return "{}With{}".format(method_name_string, first_parameter_name)
コード例 #5
0
    def method_name(api):
        # First create camel cased name from snake case
        method_name_string = ""
        for part in re.split(r'[/_]+', api.url_path):
            if part in [":id", "theID"]:
                continue
            else:
                method_name_string += part.capitalize()

        first_parameter_name = "Success"
        request_object = iOSTemplateMethods.get_api_request_object(api)
        if request_object and len(request_object.properties()) > 0:
            first_field = request_object.properties()[0]
            first_parameter_name = get_proper_name(first_field.name,
                                                   capitalize_first=True)
        elif ObjCParameter.create_id_parameter(api.url_path,
                                               request_object) is not None:
            first_parameter_name = "TheID"
        elif SwiftParameter.create_id_parameter(api.url_path,
                                                request_object) is not None:
            first_parameter_name = "TheID"

        return "{}With{}".format(method_name_string, first_parameter_name)
コード例 #6
0
    def method_parameters(api):
        parameters = []

        # Create request object parameters
        request_object = iOSTemplateMethods.get_api_request_object(api)
        if request_object:
            parameters.extend(SwiftParameter.generate_field_parameters(request_object))
            parameters.extend(SwiftParameter.generate_relationship_parameters(request_object))

        # Add id parameter if we need it
        id_parameter = SwiftParameter.create_id_parameter(api.url_path, request_object)
        if id_parameter:
            parameters.append(id_parameter)

        # Add required RestKit parameters
        parameters.extend([
            SwiftParameter(name="success",
                           swift_type="RestKitSuccess"),

            SwiftParameter(name="failure",
                           swift_type="RestKitError")
        ])

        return SwiftTemplateMethods.create_parameter_signature(parameters)