-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create integrated numbers flow (#25)
* Demo app chaining request from the Numbers API * feat: Adding helper for auto-pagination: getting a Stream --------- Co-authored-by: Antoine Sein <[email protected]>
- Loading branch information
Showing
9 changed files
with
495 additions
and
105 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
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
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
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
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
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,68 @@ | ||
package com.sinch.sample; | ||
|
||
import com.sinch.sdk.models.Configuration; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
import java.util.logging.LogManager; | ||
import java.util.logging.Logger; | ||
|
||
public class Utils { | ||
|
||
private static final String SINCH_KEY_ID = "SINCH_KEY_ID"; | ||
private static final String SINCH_KEY_SECRET = "SINCH_KEY_SECRET"; | ||
private static final String SINCH_PROJECT_ID = "SINCH_PROJECT_ID"; | ||
|
||
public static Logger initializeLogger(String className) { | ||
try (InputStream logConfigInputStream = | ||
Utils.class.getClassLoader().getResourceAsStream("logging.properties")) { | ||
if (logConfigInputStream != null) { | ||
LogManager.getLogManager().readConfiguration(logConfigInputStream); | ||
} else { | ||
throw new RuntimeException("The file 'logging.properties' couldn't be loaded."); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException(e.getMessage()); | ||
} | ||
return Logger.getLogger(className); | ||
} | ||
|
||
public static Properties loadProperties(Logger logger) { | ||
Properties properties = new Properties(); | ||
|
||
try (InputStream input = | ||
Utils.class.getClassLoader().getResourceAsStream("config.properties")) { | ||
if (input != null) { | ||
properties.load(input); | ||
} else { | ||
logger.severe("'config.properties' file could not be loaded"); | ||
} | ||
} catch (IOException e) { | ||
logger.severe("Error loading properties from 'config.properties'"); | ||
} | ||
return properties; | ||
} | ||
|
||
public static Configuration loadConfiguration(Logger logger) { | ||
Properties properties = loadProperties(logger); | ||
|
||
String keyId = | ||
null != System.getenv(SINCH_KEY_ID) | ||
? System.getenv(SINCH_KEY_ID) | ||
: properties.getProperty(SINCH_KEY_ID); | ||
String keySecret = | ||
null != System.getenv(SINCH_KEY_SECRET) | ||
? System.getenv(SINCH_KEY_SECRET) | ||
: properties.getProperty(SINCH_KEY_SECRET); | ||
String projectId = | ||
null != System.getenv(SINCH_PROJECT_ID) | ||
? System.getenv(SINCH_PROJECT_ID) | ||
: properties.getProperty(SINCH_PROJECT_ID); | ||
|
||
return Configuration.builder() | ||
.setKeyId(keyId) | ||
.setKeySecret(keySecret) | ||
.setProjectId(projectId) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.