Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.crowdin.client.filereferences;

import com.crowdin.client.core.CrowdinApi;
import com.crowdin.client.core.model.ResponseList;
import com.crowdin.client.core.model.ResponseObject;
import com.crowdin.client.filereferences.model.FileReference;
import com.crowdin.client.filereferences.model.AddFileReferenceRequest;
import com.fasterxml.jackson.core.type.TypeReference;

public class FileReferencesApi extends CrowdinApi {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a new API resource. Please follow the API docs structure and include the new methods in the sourcefiles resource


public FileReferencesApi(com.crowdin.client.core.model.Credentials credentials) {
super(credentials);
}

/**
* List File References
*/
public ResponseList<FileReference> listFileReferences(Long projectId) {
Comment on lines +16 to +19
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new methods should be documented according to the code style used for the rest of the project resources

String url = String.format("%s/projects/%d/file-references", this.url, projectId);
return this.httpClient.get(url, new TypeReference<ResponseList<FileReference>>() {});
}

/**
* Get File Reference by ID
*/
public ResponseObject<FileReference> getFileReference(Long projectId, Long fileReferenceId) {
String url = String.format("%s/projects/%d/file-references/%d", this.url, projectId, fileReferenceId);
return this.httpClient.get(url, new TypeReference<ResponseObject<FileReference>>() {});
}

/**
* Add File Reference
*/
public ResponseObject<FileReference> addFileReference(Long projectId, AddFileReferenceRequest request) {
String url = String.format("%s/projects/%d/file-references", this.url, projectId);
return this.httpClient.post(url, request, new TypeReference<ResponseObject<FileReference>>() {});
}

/**
* Delete File Reference
*/
public void deleteFileReference(Long projectId, Long fileReferenceId) {
String url = String.format("%s/projects/%d/file-references/%d", this.url, projectId, fileReferenceId);
this.httpClient.delete(url);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.crowdin.client.filereferences.model;

import lombok.Data;

/**
* Request body for creating a new File Reference.
*/
@Data
public class AddFileReferenceRequest {
private String name; // Name of the reference
private String type; // Type of the reference (e.g., "file" or "asset")
private Long fileId; // ID of the file this reference points to
}
Comment on lines +5 to +13
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the project's code style for request models

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import com.crowdin.client.filereferences.model.AddFileReferenceRequest;

package com.crowdin.client.filereferences.model;

import lombok.Data;

@Data
public class FileReference {
private Long id;
private String name;
private String type;
private Long projectId;
}
Loading