Skip to content

Commit

Permalink
Merge pull request #52 from contentstack/fix/cs-44301-function-response
Browse files Browse the repository at this point in the history
Fix: Constructor in Java class files now include missing headers
  • Loading branch information
reeshika-h authored Mar 18, 2024
2 parents 505b2bc + 31ab88c commit 60f6fde
Show file tree
Hide file tree
Showing 26 changed files with 164 additions and 101 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Alias.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public class Alias implements BaseImplementation<Alias> {
// also creates an
// instance of the `AliasService` interface using the provided `Retrofit`
// instance.
protected Alias(Retrofit instance) {
protected Alias(Retrofit instance,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.put("Content-Type", "application/json");
params = new HashMap<>();
this.service = instance.create(AliasService.class);
Expand All @@ -45,8 +46,9 @@ protected Alias(Retrofit instance) {
// The `protected Alias(Retrofit instance, String aliasUid)` constructor is used
// to create an
// instance of the `Alias` class with a specific alias UID.
protected Alias(Retrofit instance, String aliasUid) {
protected Alias(Retrofit instance,Map<String, Object> headers, String aliasUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.put("Content-Type", "application/json");
params = new HashMap<>();
this.uid = aliasUid;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void clearParams() {
* @return Folder
*/
public Folder folder() {
return new Folder(this.instance);
return new Folder(this.instance,this.headers);
}

/**
Expand All @@ -127,7 +127,7 @@ public Folder folder() {
* @return Folder
*/
public Folder folder(@NotNull String folderUid) {
return new Folder(this.instance, folderUid);
return new Folder(this.instance,this.headers, folderUid);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/AuditLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
Expand Down Expand Up @@ -37,14 +38,16 @@ public class AuditLog implements BaseImplementation<AuditLog> {
protected HashMap<String, Object> params;
private String logItemUid;

protected AuditLog(Retrofit retrofit) {
protected AuditLog(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = retrofit.create(AuditLogService.class);
}

protected AuditLog(Retrofit retrofit, String uid) {
protected AuditLog(Retrofit retrofit,Map<String, Object> headers, String uid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.logItemUid = uid;
this.service = retrofit.create(AuditLogService.class);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ public class Branch implements BaseImplementation<Branch> {
private Retrofit instance;
private String baseBranchId;

protected Branch(Retrofit instance) {
protected Branch(Retrofit instance,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.put("Content-Type", "application/json");
this.params = new HashMap<>();
this.service = instance.create(BranchService.class);
}

protected Branch(Retrofit instance, String uid) {
protected Branch(Retrofit instance,Map<String, Object> headers, String uid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.put("Content-Type", "application/json");
this.baseBranchId = uid;
this.params = new HashMap<>();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/contentstack/cms/stack/BulkOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* You can perform bulk operations such as Publish, Unpublished, and Delete on
Expand Down Expand Up @@ -48,8 +49,9 @@ public class BulkOperation implements BaseImplementation<BulkOperation> {
*
* @param retrofit the retrofit
*/
protected BulkOperation(Retrofit retrofit) {
protected BulkOperation(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.retrofit = retrofit;
this.service = this.retrofit.create(BulkOperationService.class);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/DeliveryToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import retrofit2.Call;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
Expand All @@ -31,14 +32,16 @@ public class DeliveryToken implements BaseImplementation<DeliveryToken> {
private String tokenUid;
String ERROR = "Token UID Can Not Be Null OR Empty";

protected DeliveryToken(TokenService service) {
protected DeliveryToken(TokenService service, Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = service;
}

protected DeliveryToken(TokenService service, @NotNull String tokenUid) {
protected DeliveryToken(TokenService service, Map<String, Object> headers, @NotNull String tokenUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.tokenUid = tokenUid;
this.service = service;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ public class Environment implements BaseImplementation<Environment> {
protected final EnvironmentService service;
protected String environment;

protected Environment(Retrofit instance) {
protected Environment(Retrofit instance, Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = instance.create(EnvironmentService.class);
}

protected Environment(Retrofit instance, String environment) {
protected Environment(Retrofit instance, Map<String, Object> headers, String environment) {
this.environment = environment;
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = instance.create(EnvironmentService.class);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Extensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ public class Extensions implements BaseImplementation<Extensions> {
protected HashMap<String, Object> params;
protected String customFieldUid;

protected Extensions(Retrofit retrofit) {
protected Extensions(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = retrofit.create(ExtensionsService.class);
}

protected Extensions(Retrofit retrofit, String fieldUid) {
protected Extensions(Retrofit retrofit,Map<String, Object> headers, String fieldUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.customFieldUid = fieldUid;
this.service = retrofit.create(ExtensionsService.class);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Folder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ public class Folder implements BaseImplementation<Folder> {
protected final AssetService service;
private String folderUid;

protected Folder(Retrofit instance) {
protected Folder(Retrofit instance,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
params = new HashMap<>();
this.service = instance.create(AssetService.class);
}

protected Folder(Retrofit instance, String folderUid) {
protected Folder(Retrofit instance,Map<String, Object> headers, String folderUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
params = new HashMap<>();
this.folderUid = folderUid;
this.service = instance.create(AssetService.class);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/GlobalField.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* A Global field is a reusable field (or group of fields) that you can define
Expand Down Expand Up @@ -37,14 +38,16 @@ public class GlobalField implements BaseImplementation<GlobalField> {
protected HashMap<String, Object> params;
protected String globalFiledUid;

protected GlobalField(Retrofit retrofit) {
protected GlobalField(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = retrofit.create(GlobalFieldService.class);
}

protected GlobalField(Retrofit retrofit, String uid) {
protected GlobalField(Retrofit retrofit,Map<String, Object> headers, String uid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.globalFiledUid = uid;
this.service = retrofit.create(GlobalFieldService.class);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* Labels allow you to group a collection of content within a stack. Using
Expand All @@ -32,15 +33,17 @@ public class Label implements BaseImplementation<Label> {
protected HashMap<String, Object> params;
protected String labelUid;

protected Label(Retrofit retrofit) {
protected Label(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = retrofit.create(LabelService.class);
}

protected Label(Retrofit retrofit, String labelUid) {
protected Label(Retrofit retrofit,Map<String, Object> headers, String labelUid) {
this.labelUid = labelUid;
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = retrofit.create(LabelService.class);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentstack/cms/stack/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ public class Locale implements BaseImplementation<Locale> {
*
* @param client the retrofit client
*/
public Locale(Retrofit client) {
public Locale(Retrofit client,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.localeService = client.create(LocaleService.class);
}

public Locale(Retrofit client, String code) {
public Locale(Retrofit client,Map<String, Object> headers, String code) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.code = code;
this.params = new HashMap<>();
this.localeService = client.create(LocaleService.class);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/ManagementToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import retrofit2.Call;

import java.util.HashMap;
import java.util.Map;

/**
* To authenticate Content Management API (CMA) requests over your stack
Expand All @@ -24,14 +25,16 @@ public class ManagementToken implements BaseImplementation<ManagementToken> {
protected HashMap<String, Object> params;
private String tokenUid;

protected ManagementToken(TokenService service) {
protected ManagementToken(TokenService service,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = service;
}

protected ManagementToken(TokenService service, String tokenUid) {
protected ManagementToken(TokenService service,Map<String, Object> headers, String tokenUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.service = service;
this.tokenUid = tokenUid;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/cms/stack/PublishQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* The Publish Queue displays the historical and current details of activities
Expand Down Expand Up @@ -44,15 +45,17 @@ public class PublishQueue implements BaseImplementation<PublishQueue> {
private String publishQueueUid;
private final Retrofit retrofit;

protected PublishQueue(Retrofit retrofit) {
protected PublishQueue(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.retrofit = retrofit;
this.service = this.retrofit.create(PublishQueueService.class);
}

protected PublishQueue(Retrofit retrofit, String uid) {
protected PublishQueue(Retrofit retrofit,Map<String, Object> headers, String uid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.retrofit = retrofit;
this.publishQueueUid = uid;
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/contentstack/cms/stack/Release.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* You can pin a set of entries and assets (along with the deploy action, i.e.,
Expand Down Expand Up @@ -38,15 +39,17 @@ public class Release implements BaseImplementation<Release> {
protected String releaseUid;
private final Retrofit retrofit;

protected Release(Retrofit retrofit) {
protected Release(Retrofit retrofit,Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.retrofit = retrofit;
this.service = this.retrofit.create(ReleaseService.class);
}

protected Release(Retrofit retrofit, String uid) {
protected Release(Retrofit retrofit,Map<String, Object> headers, String uid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.releaseUid = uid;
this.retrofit = retrofit;
Expand Down Expand Up @@ -254,7 +257,7 @@ public Call<ResponseBody> delete() {
*/
public ReleaseItem item() {
validate();
return new ReleaseItem(this.retrofit, this.releaseUid);
return new ReleaseItem(this.retrofit,this.headers, this.releaseUid);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/contentstack/cms/stack/ReleaseItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import retrofit2.Retrofit;

import java.util.HashMap;
import java.util.Map;

/**
* The Get all items in a Release request retrieves a list of all items (entries
Expand All @@ -29,8 +30,9 @@ public class ReleaseItem implements BaseImplementation<ReleaseItem> {
protected HashMap<String, Object> params;
private final String releaseUid;

protected ReleaseItem(Retrofit retrofit, String releaseUid) {
protected ReleaseItem(Retrofit retrofit,Map<String, Object> headers, String releaseUid) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
this.releaseUid = releaseUid;
this.service = retrofit.create(ReleaseService.class);
Expand Down
Loading

0 comments on commit 60f6fde

Please sign in to comment.