-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API-1822 setup sample files for java sdk api calls
- Loading branch information
1 parent
64acb65
commit 5a3e48d
Showing
8 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.bynder.sdk.sample; | ||
|
||
import com.bynder.sdk.configuration.Configuration; | ||
import com.bynder.sdk.model.Brand; | ||
import com.bynder.sdk.service.BynderClient; | ||
import com.bynder.sdk.service.asset.AssetService; | ||
import com.bynder.sdk.util.Utils; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
public class BrandsSample { | ||
private static final Logger LOG = LoggerFactory.getLogger(BrandsSample.class); | ||
|
||
public static void main(final String[] args) throws URISyntaxException, IOException { | ||
/** | ||
* Loads app.properties file under src/main/resources | ||
*/ | ||
Properties appProperties = Utils.loadConfig("app"); | ||
|
||
|
||
// Initialize BynderClient with a permanent token | ||
BynderClient client = BynderClient.Builder.create( | ||
new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL"))) | ||
.setPermanentToken(appProperties.getProperty("PERMANENT_TOKEN")).build()); | ||
|
||
// Initialize asset service | ||
AssetService assetService = client.getAssetService(); | ||
|
||
// Call the API to request for brands | ||
List<Brand> brands = assetService.getBrands().blockingSingle().body(); | ||
for (Brand brand : brands) { | ||
LOG.info(brand.getName()); | ||
LOG.info(brand.getDescription()); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/bynder/sdk/sample/CollectionsSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.bynder.sdk.sample; | ||
|
||
import com.bynder.sdk.configuration.Configuration; | ||
import com.bynder.sdk.model.Collection; | ||
import com.bynder.sdk.service.BynderClient; | ||
import com.bynder.sdk.service.collection.CollectionService; | ||
import com.bynder.sdk.query.collection.CollectionQuery; | ||
import com.bynder.sdk.query.collection.CollectionCreateQuery; | ||
import com.bynder.sdk.util.Utils; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class CollectionsSample { | ||
private static final Logger LOG = LoggerFactory.getLogger(CollectionsSample.class); | ||
|
||
public static void main(final String[] args) throws URISyntaxException, IOException { | ||
/** | ||
* Loads app.properties file under src/main/resources | ||
*/ | ||
Properties appProperties = Utils.loadConfig("app"); | ||
|
||
|
||
// Initialize BynderClient with a permanent token | ||
BynderClient client = BynderClient.Builder.create( | ||
new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL"))) | ||
.setPermanentToken(appProperties.getProperty("PERMANENT_TOKEN")).build()); | ||
|
||
// Initialize collection service | ||
CollectionService collectionService = client.getCollectionService(); | ||
|
||
// get collections | ||
CollectionQuery collectionQuery = new CollectionQuery(); | ||
List<Collection> collections = collectionService.getCollections(collectionQuery).blockingSingle().body(); | ||
for (Collection collectionResult : collections) { | ||
LOG.info(collectionResult.getId()); | ||
LOG.info(collectionResult.getName()); | ||
LOG.info(collectionResult.getDescription()); | ||
} | ||
|
||
// add collection | ||
CollectionCreateQuery createCollectionQuery = new CollectionCreateQuery("New Collection 1234"); | ||
collectionService.createCollection(createCollectionQuery).blockingSingle(); | ||
// | ||
List<Collection> updatedCollections = collectionService.getCollections(collectionQuery).blockingSingle().body(); | ||
for (Collection collectionResult : collections) { | ||
LOG.info(collectionResult.getId()); | ||
LOG.info(collectionResult.getName()); | ||
LOG.info(collectionResult.getDescription()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.bynder.sdk.sample; | ||
|
||
import com.bynder.sdk.configuration.Configuration; | ||
import com.bynder.sdk.model.Media; | ||
import com.bynder.sdk.model.MediaType; | ||
|
||
import com.bynder.sdk.query.MediaInfoQuery; | ||
import com.bynder.sdk.query.MediaModifyQuery; | ||
import com.bynder.sdk.query.MediaQuery; | ||
import com.bynder.sdk.query.OrderBy; | ||
|
||
import com.bynder.sdk.service.BynderClient; | ||
import com.bynder.sdk.service.asset.AssetService; | ||
import com.bynder.sdk.util.Utils; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class MediaSample { | ||
private static final Logger LOG = LoggerFactory.getLogger(MediaSample.class); | ||
|
||
public static void main(final String[] args) throws URISyntaxException, IOException { | ||
/** | ||
* Loads app.properties file under src/main/resources | ||
*/ | ||
Properties appProperties = Utils.loadConfig("app"); | ||
|
||
// Initialize BynderClient with a permanent token | ||
BynderClient client = BynderClient.Builder.create( | ||
new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL"))) | ||
.setPermanentToken(appProperties.getProperty("PERMANENT_TOKEN")).build()); | ||
|
||
// Initialize asset service | ||
AssetService assetService = client.getAssetService(); | ||
|
||
// Call the API to request for media assets | ||
MediaQuery mediaQuery = new MediaQuery().setType(MediaType.IMAGE).setOrderBy(OrderBy.NAME_DESC).setLimit(10).setPage(1); | ||
List<Media> mediaList = assetService.getMediaList(mediaQuery).blockingSingle().body(); | ||
for (Media media : mediaList) { | ||
LOG.info(media.getId()); | ||
LOG.info(media.getName()); | ||
} | ||
|
||
if (!mediaList.isEmpty()) { | ||
// get media info for single asset | ||
String mediaId = mediaList.get(0).getId(); | ||
MediaInfoQuery mediaInfoQuery = new MediaInfoQuery(mediaId); | ||
Media foundMedia = assetService.getMediaInfo(mediaInfoQuery).blockingSingle().body(); | ||
LOG.info("get media info result: "); | ||
LOG.info(foundMedia.getId()); | ||
LOG.info(foundMedia.getName()); | ||
|
||
// modify name of asset | ||
MediaModifyQuery modifyQuery = new MediaModifyQuery(mediaId).setName("New Name"); | ||
assetService.modifyMedia(modifyQuery).blockingSingle(); | ||
|
||
Media updatedFoundMedia = assetService.getMediaInfo(mediaInfoQuery).blockingSingle().body(); | ||
LOG.info("get updated media info result: "); | ||
LOG.info(updatedFoundMedia.getId()); | ||
LOG.info(updatedFoundMedia.getName()); | ||
} | ||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.bynder.sdk.sample; | ||
|
||
import com.bynder.sdk.configuration.Configuration; | ||
import com.bynder.sdk.model.Tag; | ||
import com.bynder.sdk.service.BynderClient; | ||
import com.bynder.sdk.service.asset.AssetService; | ||
import com.bynder.sdk.util.Utils; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class TagsSample { | ||
private static final Logger LOG = LoggerFactory.getLogger(TagsSample.class); | ||
|
||
public static void main(final String[] args) throws URISyntaxException, IOException { | ||
/** | ||
* Loads app.properties file under src/main/resources | ||
*/ | ||
Properties appProperties = Utils.loadConfig("app"); | ||
|
||
// Initialize BynderClient with a permanent token | ||
BynderClient client = BynderClient.Builder.create( | ||
new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL"))) | ||
.setPermanentToken(appProperties.getProperty("PERMANENT_TOKEN")).build()); | ||
|
||
AssetService assetService = client.getAssetService(); | ||
|
||
// get tags | ||
List<Tag> assetTags = assetService.getTags().blockingSingle().body(); | ||
for (Tag assetTag : assetTags) { | ||
LOG.info(assetTag.getId()); | ||
LOG.info(assetTag.getTag()); | ||
} | ||
} | ||
} |
Empty file.
Empty file.