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

Bynder / bynder-java-sdk / 7116807269

06 Dec 2023 03:41PM UTC coverage: 38.562%. First build
7116807269

Pull #114

github

ahongbynder
API-1822 add System.exit(0) to terminate processes
Pull Request #114: API-1822 [BE] [SDK] Implement Sample Files for JAVA-SDK Functionality Testing

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.model.oauth.Token;
8
import com.bynder.sdk.service.BynderClient;
9
import com.bynder.sdk.service.asset.AssetService;
10
import com.bynder.sdk.service.oauth.OAuthService;
11
import com.bynder.sdk.util.Utils;
12

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

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

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

27

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

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

37

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

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

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

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

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

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

68
        // Call the API to request for brands
NEW
69
        List<Brand> brands = assetService.getBrands().blockingSingle().body();
×
NEW
70
        if (brands != null && !brands.isEmpty()) {
×
NEW
71
            for (Brand brand : brands) {
×
NEW
72
                LOG.info("Brand ID: " + brand.getId());
×
NEW
73
                LOG.info("Brand Name: " + brand.getName());
×
NEW
74
                LOG.info("Brand Description: " + brand.getDescription());
×
NEW
75
            }
×
76
        }
NEW
77
        System.exit(0);
×
NEW
78
    }
×
79
}
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