Skip to content

Commit 46ce0f5

Browse files
author
Shailesh Mishra
authored
Merge branch 'main' into next
2 parents 8fce576 + eedd295 commit 46ce0f5

15 files changed

Lines changed: 185 additions & 199 deletions

File tree

.github/workflows/sca-scan.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: Source Composition Analysis Scan
22
on:
33
pull_request:
4-
types: [opened, synchronize, reopened]
4+
types: [ opened, synchronize, reopened ]
55
jobs:
66
security:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master
1010
- name: Run Snyk to check for vulnerabilities
11-
uses: snyk/actions/node@master
11+
uses: snyk/actions/maven@master
1212
env:
1313
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1414
with:
15-
args: --all-projects --fail-on=all
15+
args: --fail-on=all

README.md

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,90 +8,79 @@ Before using the **Marketplace** SDK, ensure the following:
88

99
1. Java JDK 1.8 or above should be installed on your machine.
1010
2. You have a valid Contentstack account with access to the Contentstack Marketplace.
11-
3. You have obtained the necessary credentials, including the organization UID, to interact with the Marketplace API.
11+
3. You have obtained the necessary credentials like **organization UID** and **authtoken**, to interact with the Marketplace API.
1212

1313
## Installation
1414

1515
To use the Marketplace SDK in your Java project, follow these steps:
1616

1717
1. Download the contentstack-java SDK and its dependencies from the Contentstack Maven repository. Add the following dependencies to your project's pom.xml file:
1818

19-
```xml
20-
<!-- https://mvnrepository.com/artifact/com.contentstack.sdk/marketplace -->
21-
<dependencies>
22-
<dependency>
23-
<groupId>com.contentstack.sdk</groupId>
24-
<artifactId>marketplace</artifactId>
25-
<version>x.x.x</version> <!-- Replace 'x.x.x' with the latest version available -->
26-
</dependency>
27-
</dependencies>
28-
```
19+
```xml
20+
<!-- https://mvnrepository.com/artifact/com.contentstack.sdk/marketplace -->
21+
<dependencies>
22+
<dependency> <groupId>com.contentstack.sdk</groupId>
23+
<artifactId>marketplace</artifactId>
24+
<version>x.x.x</version> <!-- Replace 'x.x.x' with the latest version available -->
25+
</dependency>
26+
</dependencies>
27+
28+
29+
```
2930

3031
2. Save the pom.xml file.
3132

3233
3. Ensure you have internet connectivity to download the SDK and its dependencies from the central Maven repository.
3334

3435
## How to Use
3536

36-
1. Import the required packages:
37+
1. Initialize the Marketplace class with your organization UID:
3738

38-
```java
39+
```java
3940
import com.contentstack.sdk.marketplace.Marketplace;
40-
import com.contentstack.sdk.marketplace.apps.App;
41-
import com.contentstack.sdk.marketplace.auths.Auth;
42-
import com.contentstack.sdk.marketplace.installations.Installation;
43-
import com.contentstack.sdk.marketplace.request.AppRequest;
44-
import org.jetbrains.annotations.NotNull;
45-
import retrofit2.Retrofit;
46-
```
41+
Marketplace marketplace = new Marketplace
42+
.Builder(TestClient.ORGANIZATION_UID) // Required
43+
.host(HOST) // Optional
44+
.authtoken("test") // Optional
45+
.login("test@email.com", "*********") // Optional
46+
.region(Region.AZURE_EU) // Optional
47+
.build();
48+
```
4749

48-
2. Initialize the Marketplace class with your organization UID:
49-
50-
```java
51-
// Replace 'YOUR_ORG_ID' with your Contentstack organization UID
52-
String organizationUid = "YOUR_ORG_ID";
53-
Marketplace marketplace = new Marketplace(organizationUid);
54-
```
55-
56-
3. Use the various methods available in the Marketplace class to interact with the Marketplace API:
50+
2. Use the various methods available in the Marketplace class to interact with the Marketplace API:
5751

5852
### Retrieve an instance of the App class:
59-
60-
```java
61-
// Get an instance of the App class
62-
App app = marketplace.app();
63-
64-
// Alternatively, you can pass the app UID to retrieve a specific app
65-
String appUid = "APP_UID";
66-
App specificApp = marketplace.app(appUid);
67-
```
53+
Get an instance of the App class
54+
```java
55+
import com.contentstack.sdk.marketplace.apps.App;
56+
App app = marketplace.app();
57+
// Alternatively, you can pass the app UID to retrieve a specific app
58+
App specificApp = marketplace.app("APP_UID");
59+
```
6860

6961
### Retrieve an instance of the Auth class:
7062

7163
```java
72-
// Get an instance of the Auth class
73-
Auth auth = marketplace.authorizations();
74-
```
64+
import com.contentstack.sdk.marketplace.auths.Auth;
65+
// Get an instance of the Auth class
66+
Auth auth = marketplace.authorizations();
67+
```
7568

7669
### Retrieve an instance of the Installation class:
77-
70+
Get an instance of the Installation class
7871
```java
79-
// Get an instance of the Installation class
80-
Installation installation = marketplace.installation();
81-
82-
// Alternatively, you can pass the installation ID to retrieve a specific installation
83-
String installationId = "INSTALLATION_ID";
84-
Installation specificInstallation = marketplace.installation(installationId);
85-
```
72+
import com.contentstack.sdk.marketplace.installations.Installation;
73+
Installation installation = marketplace.installation();
74+
OR
75+
Installation specificInstallation = marketplace.installation("INSTALLATION_ID");
76+
```
8677

8778
### Create an instance of the AppRequest class:
88-
79+
Get an instance of the AppRequest class
8980
```java
90-
// Get an instance of the AppRequest class
91-
AppRequest appRequest = marketplace.request();
92-
```
93-
94-
**Note:** Replace **YOUR_ORG_ID**, **APP_UID**, and **INSTALLATION_ID** with actual values from your Contentstack organization.
81+
import com.contentstack.sdk.marketplace.request.AppRequest;
82+
AppRequest appRequest = marketplace.request();
83+
```
9584

9685
## License
9786

@@ -102,4 +91,4 @@ Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights
10291
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10392

10493
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105-
```
94+
```

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>marketplace</artifactId>
8-
<version>1.0.0-alpha-SNAPSHOT</version>
8+
<version>1.0.0</version>
99
<description>Contentstack Java Management SDK for Content Management API</description>
1010
<url>https://github.com/contentstack/contentstack-management-java/</url>
1111

@@ -23,7 +23,7 @@
2323
<converter-gson-version>2.9.0</converter-gson-version>
2424
<logging.version>4.10.0</logging.version>
2525
<jococo-plugin.version>0.8.7</jococo-plugin.version>
26-
<lombok-source.version>1.18.28</lombok-source.version>
26+
<lombok-source.version>1.18.30</lombok-source.version>
2727
<junit-jupiter.version>5.10.0</junit-jupiter.version>
2828
<junit-jupiter-engine.version>5.8.0-M1</junit-jupiter-engine.version>
2929
<junit-vintage-engine.version>5.10.0</junit-vintage-engine.version>

src/main/java/com/contentstack/sdk/marketplace/Constants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
public class Constants {
44
final public static String ERROR_NO_ORGANIZATION_UID = "Organization uid could not be empty";
5+
final public static String DEFAULT_HOST = "developerhub-api.contentstack.com";
6+
final public static String MISSING_ORG_ID = "organization uid is required";
7+
58

69
final public static String ORGANIZATION_UID = "organization_uid";
710
final public static String AUTHTOKEN = "authtoken";

src/main/java/com/contentstack/sdk/marketplace/Marketplace.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class Marketplace {
2626
protected final String orgId;
2727
private final String host;
2828

29-
private static final String DEFAULT_HOST = "developerhub-api.contentstack.com";
3029
private final String authtoken;
3130

3231
private Marketplace(String authtoken, String organizationUid, String host, Region region) {
@@ -35,7 +34,7 @@ private Marketplace(String authtoken, String organizationUid, String host, Regio
3534
if (region != null) {
3635
host = region.name().toLowerCase() + "-" + host;
3736
}
38-
this.host = host.isEmpty() ? DEFAULT_HOST : host;
37+
this.host = host.isEmpty() ? Constants.DEFAULT_HOST : host;
3938
this.client = Client.getInstance(this.host);
4039
}
4140

src/main/java/com/contentstack/sdk/marketplace/apps/App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public App(Retrofit client, String authtoken, @NotNull String organizationUid) {
5454
this.params = new HashMap<>();
5555
Objects.requireNonNull(organizationUid, Constants.ERROR_NO_ORGANIZATION_UID);
5656
this.headers.put(Constants.ORGANIZATION_UID, organizationUid);
57-
if (authtoken!=null){
57+
if (authtoken != null) {
5858
this.headers.put(Constants.AUTHTOKEN, authtoken);
5959
}
6060
this.service = client.create(AppService.class);
@@ -83,7 +83,7 @@ public App(Retrofit client, String authtoken, @NotNull String organizationUid, @
8383
this.params = new HashMap<>();
8484
Objects.requireNonNull(organizationUid, ERROR_NO_ORGANIZATION_UID);
8585
this.headers.put(Constants.ORGANIZATION_UID, organizationUid);
86-
if (authtoken!=null){
86+
if (authtoken != null) {
8787
this.headers.put(Constants.AUTHTOKEN, authtoken);
8888
}
8989
Objects.requireNonNull(uid, "Manifest uid is required");

src/main/java/com/contentstack/sdk/marketplace/auths/Auth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Auth(Retrofit clientInstance, String authtoken, String organizationUid) {
3535
this.params = new HashMap<>();
3636
Objects.requireNonNull(organizationUid, "Organization uid could not be empty");
3737
this.headers.put(Constants.ORGANIZATION_UID, organizationUid);
38-
if (authtoken!=null){
38+
if (authtoken != null) {
3939
this.headers.put(Constants.AUTHTOKEN, authtoken);
4040
}
4141
this.service = clientInstance.create(AuthService.class);

src/main/java/com/contentstack/sdk/marketplace/installations/Installation.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class Installation implements BaseImplementation<Installation> {
2020
/**
2121
* The Missing org id.
2222
*/
23-
public final String MISSING_ORG_ID = "organization uid is required";
2423
private String installationId;
2524
private String organisationId;
2625
private InstallationService service;
@@ -59,7 +58,7 @@ public Installation(Retrofit client, String authtoken, @NotNull String organisat
5958
*/
6059
protected void checkOrganisationId(String organisationId) {
6160
if (organisationId.isEmpty()) {
62-
throw new NullPointerException(MISSING_ORG_ID);
61+
throw new NullPointerException(Constants.MISSING_ORG_ID);
6362
}
6463
}
6564

@@ -115,7 +114,7 @@ private void init(Retrofit client, String authtoken, @NotNull String organisatio
115114
this.organisationId = organisationId;
116115
this.client = client;
117116
this.headers.put(Constants.ORGANIZATION_UID, organisationId);
118-
if (authtoken!=null){
117+
if (authtoken != null) {
119118
this.headers.put(Constants.AUTHTOKEN, authtoken);
120119
}
121120
this.service = this.client.create(InstallationService.class);

0 commit comments

Comments
 (0)