Skip to content

Commit

Permalink
Merge pull request #136 from alexanderjordanbaker/UrlSelectionMethod
Browse files Browse the repository at this point in the history
Update BaseAppStoreServerAPIClient to move URL selection to a method
  • Loading branch information
alexanderjordanbaker authored Feb 1, 2025
2 parents 7c8b5c2 + 9af9a6d commit 4dd1e78
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-prb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: sudo -E env "PATH=$PATH" bash -c "ulimit -l 65536 && ulimit -a && ./gradlew --no-daemon --parallel clean test"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.java }}
path: '**/build/test-results/test/TEST-*.xml'
2 changes: 1 addition & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
./gradlew --no-daemon --parallel publish"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.java }}
path: '**/build/test-results/test/TEST-*.xml'
2 changes: 1 addition & 1 deletion .github/workflows/ci-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
|| exit 1) || exit 0"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.java }}
path: '**/build/test-results/test/TEST-*.xml'
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Version 3.3.0
- Update BaseAppStoreServerAPIClient to move URL selection to a method

## Version 3.2.0
- Incorporate caching of validated certificate chains to prevent repetitive OCSP fetches [https://github.com/apple/app-store-server-library-java/pull/127]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Java server library for the [App Store Server API](https://developer.apple.c

### Gradle
```groovy
implementation 'com.apple.itunes.storekit:app-store-server-library:3.2.0'
implementation 'com.apple.itunes.storekit:app-store-server-library:3.3.0'
```

Expand All @@ -24,7 +24,7 @@ implementation 'com.apple.itunes.storekit:app-store-server-library:3.2.0'
<dependency>
<groupId>com.apple.itunes.storekit</groupId>
<artifactId>app-store-server-library</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.2.0
version=3.3.0
group=com.apple.itunes.storekit
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class BaseAppStoreServerAPIClient {
private static final String PRODUCTION_URL = "https://api.storekit.itunes.apple.com";
private static final String SANDBOX_URL = "https://api.storekit-sandbox.itunes.apple.com";
private static final String LOCAL_TESTING_URL = "https://local-testing-base-url";
private static final String USER_AGENT = "app-store-server-library/java/3.2.0";
private static final String USER_AGENT = "app-store-server-library/java/3.3.0";
private static final String JSON = "application/json; charset=utf-8";

private final BearerTokenAuthenticatorInterface bearerTokenAuthenticator;
Expand All @@ -55,29 +55,30 @@ public BaseAppStoreServerAPIClient(String signingKey, String keyId, String issue

public BaseAppStoreServerAPIClient(BearerTokenAuthenticatorInterface bearerTokenAuthenticator, Environment environment) {
this.bearerTokenAuthenticator = bearerTokenAuthenticator;
this.url = getUrlForEnvironment(environment);
this.objectMapper = new ObjectMapper();
objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
}

protected String getUrlForEnvironment(Environment environment) {
switch (environment) {
case XCODE:
throw new IllegalArgumentException("Xcode is not a supported environment for an AppStoreServerAPIClient");
case PRODUCTION:
this.url = PRODUCTION_URL;
break;
return PRODUCTION_URL;
case LOCAL_TESTING:
this.url = LOCAL_TESTING_URL;
break;
return LOCAL_TESTING_URL;
case SANDBOX:
this.url = SANDBOX_URL;
break;
return SANDBOX_URL;
default:
// This switch statement is exhaustive
throw new IllegalStateException();
}
this.objectMapper = new ObjectMapper();
objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
}

/**
Expand Down

0 comments on commit 4dd1e78

Please sign in to comment.