• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Bynder / bynder-java-sdk / 7130807638

07 Dec 2023 04:07PM UTC coverage: 38.562%. First build
7130807638

push

github

web-flow
API-1822 [BE] [SDK] Implement Sample Files for JAVA-SDK Functionality Testing (#114)

* API-1822 setup sample files for java sdk api calls

* API-1822 add upload sample, smart filters sample, usage sample

* API-1822 add metaproperties sample, update logging for samples, setup methods for collection sample

* API-1822 update collections sample with share, add media, remove media

* API-1822 resolve package name

* API-1822 setup asset usage sample

* API-1822 use OAuth for client, add testasset image for upload

* API-1822 add media removal, add README, add null checks for collections

* API-1822 update readme for sample files

* API-1822 get derivatives for portal

* API-1822 update readme for derivatives method

* API-1822 cleanup

* API-1822 add System.exit(0) to terminate processes

* API-1822 cleanup

0 of 351 new or added lines in 8 files covered. (0.0%)

708 of 1836 relevant lines covered (38.56%)

0.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/bynder/sdk/sample/BrandsSample.java
1
package com.bynder.sdk.sample;
2

3
import com.bynder.sdk.configuration.Configuration;
4
import com.bynder.sdk.configuration.HttpConnectionSettings;
5
import com.bynder.sdk.configuration.OAuthSettings;
6
import com.bynder.sdk.model.Brand;
7
import com.bynder.sdk.service.BynderClient;
8
import com.bynder.sdk.service.asset.AssetService;
9
import com.bynder.sdk.service.oauth.OAuthService;
10
import com.bynder.sdk.util.Utils;
11

12
import java.awt.*;
13
import java.io.IOException;
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import java.net.URL;
17

18
import java.util.Arrays;
19
import java.util.List;
20
import java.util.Properties;
21
import java.util.Scanner;
22

23
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
25

26

NEW
27
public class BrandsSample {
×
NEW
28
    private static final Logger LOG = LoggerFactory.getLogger(BrandsSample.class);
×
29

30
    public static void main(final String[] args) throws URISyntaxException, IOException {
31
        /**
32
         * Loads app.properties file under src/main/resources
33
         */
NEW
34
        Properties appProperties = Utils.loadConfig("app");
×
35

36

37
        // Initialize BynderClient with OAuth
NEW
38
        OAuthSettings oAuthSettings = new OAuthSettings(appProperties.getProperty("CLIENT_ID"), appProperties.getProperty("CLIENT_SECRET"), new URI(appProperties.getProperty("REDIRECT_URI")));
×
NEW
39
        BynderClient client = BynderClient.Builder.create(
×
NEW
40
                new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL")))
×
NEW
41
                        .setOAuthSettings(oAuthSettings)
×
NEW
42
                        .setHttpConnectionSettings(new HttpConnectionSettings()).build());
×
NEW
43
        List<String> scopes = Arrays.asList("offline", "asset:read", "asset:write", "asset.usage:read",
×
44
                "asset.usage:write", "collection:read", "collection:write", "meta.assetbank:read",
45
                "meta.assetbank:write", "meta.workflow:read");
46

47
        // Initialize OAuthService
NEW
48
        OAuthService oauthService = client.getOAuthService();
×
NEW
49
        URL authorizationUrl = oauthService.getAuthorizationUrl("state example", scopes);
×
50

51
        // Open browser with authorization URL
NEW
52
        Desktop desktop = Desktop.getDesktop();
×
NEW
53
        desktop.browse(authorizationUrl.toURI());
×
54

55
        // Ask for the code returned in the redirect URI
NEW
56
        System.out.println("Insert the code: ");
×
NEW
57
        Scanner scanner = new Scanner(System.in);
×
NEW
58
        String code = scanner.nextLine();
×
NEW
59
        scanner.close();
×
60

61
        // Get the access token
NEW
62
        oauthService.getAccessToken(code, scopes).blockingSingle();
×
63

64
        // Initialize asset service
NEW
65
        AssetService assetService = client.getAssetService();
×
66

67
        // Call the API to request for brands
NEW
68
        List<Brand> brands = assetService.getBrands().blockingSingle().body();
×
NEW
69
        if (brands != null && !brands.isEmpty()) {
×
NEW
70
            for (Brand brand : brands) {
×
NEW
71
                LOG.info("Brand ID: " + brand.getId());
×
NEW
72
                LOG.info("Brand Name: " + brand.getName());
×
NEW
73
                LOG.info("Brand Description: " + brand.getDescription());
×
NEW
74
            }
×
75
        }
NEW
76
        System.exit(0);
×
NEW
77
    }
×
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc