├── .editorconfig ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── gradle-ci.yml │ └── gradle-publishing.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── LICENSE_BANNER.txt ├── README.md ├── build.gradle ├── codegeneration ├── codegen.sh ├── config.json └── template │ ├── jackson_annotations.mustache │ ├── model.mustache │ └── pojo.mustache ├── config └── formatter │ ├── adobe.header.generated.txt │ └── adobe.header.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── openapi ├── .github │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE.md │ └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── common │ └── components │ │ ├── ABTOrder.yaml │ │ ├── AuthenticatedState.yaml │ │ ├── CustomerId.yaml │ │ ├── Order.yaml │ │ ├── Parameters.yaml │ │ ├── Preview.yaml │ │ ├── Product.yaml │ │ ├── QAMode.yaml │ │ ├── QAModePreviewIndex.yaml │ │ ├── ResponseTokens.yaml │ │ ├── UnexpectedError.yaml │ │ └── VisitorId.yaml └── delivery │ ├── api.yaml │ ├── components │ ├── Address.yaml │ ├── AnalyticsPayload.yaml │ ├── AnalyticsRequest.yaml │ ├── AnalyticsResponse.yaml │ ├── Application.yaml │ ├── AudienceManager.yaml │ ├── Browser.yaml │ ├── ChannelType.yaml │ ├── ClientHints.yaml │ ├── Context.yaml │ ├── DecisioningMethod.yaml │ ├── DeliveryRequest.yaml │ ├── DeliveryResponse.yaml │ ├── DeviceType.yaml │ ├── ExecuteRequest.yaml │ ├── ExecuteResponse.yaml │ ├── ExecutionMode.yaml │ ├── ExperienceCloud.yaml │ ├── Geo.yaml │ ├── LoggingType.yaml │ ├── MboxRequest.yaml │ ├── MboxResponse.yaml │ ├── Metric.yaml │ ├── MetricType.yaml │ ├── MobilePlatform.yaml │ ├── MobilePlatformType.yaml │ ├── Notification.yaml │ ├── NotificationMbox.yaml │ ├── NotificationPageLoad.yaml │ ├── NotificationResponse.yaml │ ├── NotificationView.yaml │ ├── Option.yaml │ ├── OptionType.yaml │ ├── PageLoadResponse.yaml │ ├── PrefetchMboxResponse.yaml │ ├── PrefetchRequest.yaml │ ├── PrefetchResponse.yaml │ ├── Property.yaml │ ├── RequestDetails.yaml │ ├── Screen.yaml │ ├── ScreenOrientationType.yaml │ ├── Telemetry.yaml │ ├── TelemetryEntry.yaml │ ├── TelemetryFeatures.yaml │ ├── TelemetryRequest.yaml │ ├── Trace.yaml │ ├── TraceResponse.yaml │ ├── View.yaml │ ├── ViewRequest.yaml │ └── Window.yaml │ ├── examples │ ├── notificationsForDisplayedContent.json │ ├── responseForPrefetchViewsForMobileChannel.json │ └── responseForPrefetchViewsForWebChannel.json │ └── markdown │ └── api-description.md ├── settings.gradle └── src ├── main └── java │ └── com │ └── adobe │ └── target │ ├── delivery │ └── v1 │ │ └── model │ │ ├── Action.java │ │ ├── Address.java │ │ ├── AnalyticsPayload.java │ │ ├── AnalyticsRequest.java │ │ ├── AnalyticsResponse.java │ │ ├── Application.java │ │ ├── AudienceManager.java │ │ ├── AuthenticatedState.java │ │ ├── Browser.java │ │ ├── ChannelType.java │ │ ├── ClientHints.java │ │ ├── Context.java │ │ ├── CustomerId.java │ │ ├── DecisioningMethod.java │ │ ├── DeliveryRequest.java │ │ ├── DeliveryResponse.java │ │ ├── DeviceType.java │ │ ├── ExecuteRequest.java │ │ ├── ExecuteResponse.java │ │ ├── ExecutionMode.java │ │ ├── ExperienceCloud.java │ │ ├── Geo.java │ │ ├── LoggingType.java │ │ ├── MboxRequest.java │ │ ├── MboxRequestAllOf.java │ │ ├── MboxResponse.java │ │ ├── Metric.java │ │ ├── MetricType.java │ │ ├── MobilePlatform.java │ │ ├── MobilePlatformType.java │ │ ├── Notification.java │ │ ├── NotificationAllOf.java │ │ ├── NotificationMbox.java │ │ ├── NotificationPageLoad.java │ │ ├── NotificationResponse.java │ │ ├── NotificationView.java │ │ ├── Option.java │ │ ├── OptionType.java │ │ ├── Order.java │ │ ├── PageLoadResponse.java │ │ ├── PrefetchMboxResponse.java │ │ ├── PrefetchMboxResponseAllOf.java │ │ ├── PrefetchRequest.java │ │ ├── PrefetchResponse.java │ │ ├── Preview.java │ │ ├── Product.java │ │ ├── Property.java │ │ ├── QAMode.java │ │ ├── QAModePreviewIndex.java │ │ ├── RequestDetails.java │ │ ├── Screen.java │ │ ├── ScreenOrientationType.java │ │ ├── Telemetry.java │ │ ├── TelemetryEntry.java │ │ ├── TelemetryFeatures.java │ │ ├── TelemetryRequest.java │ │ ├── Trace.java │ │ ├── UnexpectedError.java │ │ ├── View.java │ │ ├── ViewRequest.java │ │ ├── ViewRequestAllOf.java │ │ ├── VisitorId.java │ │ └── Window.java │ └── edge │ └── client │ ├── Attributes.java │ ├── ClientConfig.java │ ├── ClientProxyConfig.java │ ├── DefaultTargetClient.java │ ├── TargetClient.java │ ├── exception │ ├── TargetClientException.java │ ├── TargetExceptionHandler.java │ └── TargetRequestException.java │ ├── http │ ├── ApacheClientFactory.java │ ├── DebuggingInterceptor.java │ ├── DefaultTargetHttpClient.java │ ├── DefaultTargetMetricContext.java │ ├── JacksonObjectMapper.java │ ├── LoggingMetricConsumer.java │ ├── ResponseStatus.java │ ├── ResponseWrapper.java │ ├── TargetAsyncIdleConnectionMonitorThread.java │ ├── TargetHttpClient.java │ ├── TargetHttpClientLoggingDecorator.java │ ├── TargetMetricContext.java │ └── TargetMetrics.java │ ├── model │ ├── DecisioningMethod.java │ ├── ServerState.java │ ├── TargetAttributesResponse.java │ ├── TargetCookie.java │ ├── TargetDeliveryRequest.java │ ├── TargetDeliveryRequestBuilder.java │ ├── TargetDeliveryResponse.java │ └── ondevice │ │ ├── OnDeviceDecisioningEvaluation.java │ │ ├── OnDeviceDecisioningHandler.java │ │ ├── OnDeviceDecisioningRule.java │ │ ├── OnDeviceDecisioningRuleSet.java │ │ └── OnDeviceDecisioningRules.java │ ├── ondevice │ ├── CampaignMacroReplacer.java │ ├── ClusterLocator.java │ ├── DefaultRuleLoader.java │ ├── OnDeviceDecisioningDetailsExecutor.java │ ├── OnDeviceDecisioningEvaluator.java │ ├── OnDeviceDecisioningRuleExecutor.java │ ├── OnDeviceDecisioningService.java │ ├── OnDeviceDecisioningServicesManager.java │ ├── RuleLoader.java │ ├── TraceHandler.java │ ├── client │ │ └── geo │ │ │ ├── DefaultGeoClient.java │ │ │ └── GeoClient.java │ └── collator │ │ ├── CustomParamsCollator.java │ │ ├── GeoParamsCollator.java │ │ ├── PageParamsCollator.java │ │ ├── ParamsCollator.java │ │ ├── TimeParamsCollator.java │ │ └── UserParamsCollator.java │ ├── service │ ├── DefaultTargetService.java │ ├── NotificationService.java │ ├── TargetService.java │ ├── TelemetryService.java │ └── VisitorProvider.java │ └── utils │ ├── AllocationUtils.java │ ├── CollectionUtils.java │ ├── CookieUtils.java │ ├── HashingUtils.java │ ├── LogUtils.java │ ├── MathUtils.java │ ├── StringUtils.java │ ├── TargetConstants.java │ ├── TimingTool.java │ └── VisitorConstants.java └── test ├── java └── com │ └── adobe │ └── target │ └── edge │ └── client │ ├── ClientConfigTest.java │ ├── entities │ ├── TargetDeliveryAttributesTest.java │ ├── TargetDeliveryExceptionTest.java │ ├── TargetDeliveryLocalGeoTest.java │ ├── TargetDeliveryLocalPropertyTest.java │ ├── TargetDeliveryRequestLocalMboxTest.java │ ├── TargetDeliveryRequestLocalViewTest.java │ └── TargetDeliveryRequestTest.java │ ├── http │ ├── DefaultTargetHttpClientTest.java │ └── TargetMetricsTest.java │ ├── ondevice │ ├── DefaultRuleLoaderTest.java │ ├── OnDeviceDecisioningEvaluatorTest.java │ ├── client │ │ └── geo │ │ │ └── DefaultGeoClientTest.java │ └── collator │ │ ├── CustomParamsCollatorTest.java │ │ ├── GeoParamsCollatorTest.java │ │ ├── PageParamsCollatorTest.java │ │ ├── TimeParamsCollatorTest.java │ │ └── UserParamsCollatorTest.java │ ├── service │ ├── DefaultTargetServiceTest.java │ ├── NotificationServiceTest.java │ └── TelemetryServiceTest.java │ └── utils │ ├── AllocationUtilsTest.java │ ├── MockRawResponse.java │ └── TargetTestDeliveryRequestUtils.java └── resources ├── DECISIONING_ARTIFACT_GEO.json ├── DECISIONING_ARTIFACT_GEO_FAKE.json ├── DECISIONING_ARTIFACT_PROPERTY.json ├── DECISIONING_PAYLOAD_ADDRESS.json ├── DECISIONING_PAYLOAD_ALL_MATCHES.json ├── DECISIONING_PAYLOAD_ATTRIBUTES.json ├── DECISIONING_PAYLOAD_BROWSER.json ├── DECISIONING_PAYLOAD_CAMPAIGN_MACROS.json ├── DECISIONING_PAYLOAD_GLOBAL_MBOX.json ├── DECISIONING_PAYLOAD_PAGELOAD_VEC_AB.json ├── DECISIONING_PAYLOAD_PAGELOAD_VEC_XT.json ├── DECISIONING_PAYLOAD_PARAMS.json ├── DECISIONING_PAYLOAD_PRIORITIES.json ├── DECISIONING_PAYLOAD_RECOMMENDATIONS.json ├── DECISIONING_PAYLOAD_TIMEFRAME.json └── DECISIONING_PAYLOAD_VIEWS.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for choosing to contribute! 4 | 5 | The following are a set of guidelines to follow when contributing to this project. 6 | 7 | ## Code Of Conduct 8 | 9 | This project adheres to the Adobe [code of conduct](../CODE_OF_CONDUCT.md). By participating, 10 | you are expected to uphold this code. Please report unacceptable behavior to 11 | [Grp-opensourceoffice@adobe.com](mailto:Grp-opensourceoffice@adobe.com). 12 | 13 | ## Have A Question? 14 | 15 | Start by filing an issue. The existing committers on this project work to reach 16 | consensus around project direction and issue solutions within issue threads 17 | (when appropriate). 18 | 19 | ## Contributor License Agreement 20 | 21 | All third-party contributions to this project must be accompanied by a signed contributor 22 | license agreement. This gives Adobe permission to redistribute your contributions 23 | as part of the project. [Sign our CLA](https://opensource.adobe.com/cla.html). You 24 | only need to submit an Adobe CLA one time, so if you have submitted one previously, 25 | you are good to go! 26 | 27 | ## Code Reviews 28 | 29 | All submissions should come in the form of pull requests and need to be reviewed 30 | by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/) 31 | for more information on sending pull requests. 32 | 33 | Lastly, please follow the [pull request template](PULL_REQUEST_TEMPLATE.md) when 34 | submitting a pull request! 35 | 36 | ## From Contributor To Committer 37 | 38 | We love contributions from our community! If you'd like to go a step beyond contributor 39 | and become a committer with full write access and a say in the project, you must 40 | be invited to the project. The existing committers employ an internal nomination 41 | process that must reach lazy consensus (silence is approval) before invitations 42 | are issued. If you feel you are qualified and want to get more deeply involved, 43 | feel free to reach out to existing committers to have a conversation about that. 44 | 45 | ## Security Issues 46 | 47 | Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html) 48 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Expected Behaviour 5 | 6 | ### Actual Behaviour 7 | 8 | ### Reproduce Scenario (including but not limited to) 9 | 10 | #### Steps to Reproduce 11 | 12 | #### Platform and Version 13 | 14 | #### Sample Code that illustrates the problem 15 | 16 | #### Logs taken while reproducing problem 17 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | 7 | ## Related Issue 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Motivation and Context 15 | 16 | 17 | 18 | ## How Has This Been Tested? 19 | 20 | 21 | 22 | 23 | 24 | ## Screenshots (if appropriate): 25 | 26 | ## Types of changes 27 | 28 | 29 | 30 | - [ ] Bug fix (non-breaking change which fixes an issue) 31 | - [ ] New feature (non-breaking change which adds functionality) 32 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 33 | 34 | ## Checklist: 35 | 36 | 37 | 38 | 39 | - [ ] I have signed the [Adobe Open Source CLA](https://opensource.adobe.com/cla.html). 40 | - [ ] My code follows the code style of this project. 41 | - [ ] My change requires a change to the documentation. 42 | - [ ] I have updated the documentation accordingly. 43 | - [ ] I have read the **CONTRIBUTING** document. 44 | - [ ] I have added tests to cover my changes. 45 | - [ ] All new and existing tests passed. 46 | -------------------------------------------------------------------------------- /.github/workflows/gradle-ci.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019-2020 Adobe. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 18 | 19 | name: Gradle Build 20 | 21 | on: 22 | push: 23 | branches: [ main ] 24 | pull_request: 25 | branches: [ main ] 26 | 27 | jobs: 28 | build: 29 | runs-on: ubuntu-latest 30 | 31 | steps: 32 | - uses: actions/checkout@v2 33 | - name: Set up JDK 1.8 34 | uses: actions/setup-java@v1 35 | with: 36 | java-version: 1.8 37 | - name: Cache Gradle packages 38 | uses: actions/cache@v2 39 | with: 40 | path: ~/.gradle/caches 41 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 42 | restore-keys: ${{ runner.os }}-gradle 43 | - name: Build with Gradle 44 | run: ./gradlew build 45 | -------------------------------------------------------------------------------- /.github/workflows/gradle-publishing.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017-2020 Adobe. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 18 | 19 | name: Gradle Publishing 20 | 21 | on: workflow_dispatch 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | with: 29 | fetch-depth: 0 30 | - name: Set up JDK 31 | uses: actions/setup-java@v1 32 | with: 33 | java-version: 1.8 34 | 35 | - name: Configure git user for release commits 36 | env: 37 | X_GITHUB_USERNAME: ${{ secrets.ADOBE_BOT_GITHUB_USERNAME }} 38 | run: | 39 | git config user.email "Grp-opensourceoffice@adobe.com" 40 | git config user.name "${X_GITHUB_USERNAME}" 41 | 42 | # Import GPG key used during the release to sign the artifacts (required by Sonatype) 43 | - name: Import GPG key 44 | env: 45 | GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }} 46 | GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }} 47 | run: | 48 | echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes 49 | echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes 50 | echo "GPG_KEY_ID=$(gpg -k --with-colons | grep 'pub' | cut -d':' -f5 | tail -c 9)" >> $GITHUB_ENV 51 | 52 | - name: Publish to the Maven Central Repository 53 | run: ./gradlew publish 54 | env: 55 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 56 | ADOBE_BOT_GITHUB_USERNAME: ${{ secrets.ADOBE_BOT_GITHUB_USERNAME }} 57 | ADOBE_BOT_GITHUB_PASSWORD: ${{ secrets.ADOBE_BOT_GITHUB_PASSWORD }} 58 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 59 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | out/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | codegeneration/build 6 | codegeneration/openapi-generator 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | /out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | .DS_Store 31 | .java-version 32 | -------------------------------------------------------------------------------- /LICENSE_BANNER.txt: -------------------------------------------------------------------------------- 1 | <%= pkg.name %> v.<%= pkg.version %> 2 | Copyright 2021 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under 8 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | OF ANY KIND, either express or implied. See the License for the specific language 10 | governing permissions and limitations under the License. 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adobe Target Java SDK 2 | 3 | The Adobe Target Java SDK uses the [Target View Delivery API] to retrieve and deliver personalized experiences using 4 | best practices. Furthermore, the Java SDK helps manage integrations with Experience Cloud solutions like Visitor API and Adobe 5 | Analytics. 6 | 7 | - Checkout [Server-Side Optimization](https://medium.com/adobetech/server-side-optimization-with-the-new-target-java-sdk-421dc418a3f2) post for benefits and best practices of using Target Java SDK. 8 | 9 | - Standalone Spring Boot based sample is available at [target-java-sdk-samples](https://github.com/adobe/target-java-sdk-samples) 10 | 11 | ## Getting started 12 | 13 | ### Prerequisites 14 | 15 | - Java 8+ 16 | - Maven or Gradle 17 | 18 | ### Installation 19 | 20 | To get started with Target Java SDK, just add it as a dependency in `gradle` as: 21 | ```groovy 22 | implementation 'com.adobe.target:target-java-sdk:2.5.1' 23 | ``` 24 | or `maven` as: 25 | ```xml 26 | 27 | com.adobe.target 28 | target-java-sdk 29 | 2.5.1 30 | 31 | ``` 32 | 33 | ## Super Simple to Use 34 | 35 | Please take a look at our [documentation](https://experienceleague.adobe.com/en/docs/target-dev/developer/server-side/java/overview) to learn how to use the Java SDK. 36 | 37 | ## Samples 38 | 39 | The Adobe Target Java SDK Samples can be found [here](https://github.com/adobe/target-java-sdk-samples). 40 | 41 | ## Development 42 | 43 | Check out our [Contribution guidelines](.github/CONTRIBUTING.md) as well as [Code of Conduct](CODE_OF_CONDUCT.md) prior 44 | to contributing to Target Java SDK development. 45 | 1. To build the project: `./gradlew build` 46 | 2. To install `java-sdk` locally: `./gradlew install` 47 | 3. To run the unit tests locally: `./gradlew test` 48 | 49 | ## Delivery API Client generation 50 | 51 | The SDK depends on [Target Open API](https://github.com/adobe/target-openapi). It uses Open API and the `Open API generator` to generate the low level HTTP client. 52 | 53 | To be able to use `Target Open API` for code generation, we are leveraging Git subtree. 54 | 55 | To refresh the local `target-openapi` subtree, use the command: 56 | 57 | ```bash 58 | git subtree pull --prefix openapi git@github.com:adobe/target-openapi.git main --squash 59 | ``` 60 | 61 | The openapi-generator config is located in the `codegeneration` directory, but there is no need to invoke it directly. To regenerate the openapi models use the command: `./gradlew codegen spotlessApply` 62 | -------------------------------------------------------------------------------- /codegeneration/codegen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Using custom openapi-generator fork based on version 5.2.0 due to the main version introducing breaking changes to our models 4 | rm -rf ./build ../src/main/java/com/adobe/target/delivery/v1 5 | mkdir ../src/main/java/com/adobe/target/delivery/v1 6 | git clone git@github.com:dcottingham/openapi-generator.git 7 | cd openapi-generator 8 | git fetch --tags 9 | git checkout tags/v5.2.0_custom 10 | ./mvnw clean install package -Dmaven.javadoc.skip=true -Dmaven.test.skip=true 11 | java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -c ../config.json -i ../../openapi/delivery/api.yaml -o ../build -t ../template --skip-validate-spec 12 | mkdir ../../src/main/java/com/adobe/target/delivery/v1/model/ 13 | cp ../build/src/main/java/com/adobe/target/delivery/v1/model/* ../../src/main/java/com/adobe/target/delivery/v1/model/ 14 | -------------------------------------------------------------------------------- /codegeneration/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "library": "resttemplate", 3 | "apiPackage": "com.adobe.target.delivery.v1.api", 4 | "modelPackage": "com.adobe.target.delivery.v1.model", 5 | "invokerPackage": "com.adobe.target.delivery.v1", 6 | "java8": true, 7 | "dateLibrary": "java8", 8 | "fullJavaUtil": false, 9 | "hideGenerationTimestamp": true 10 | } 11 | -------------------------------------------------------------------------------- /codegeneration/template/jackson_annotations.mustache: -------------------------------------------------------------------------------- 1 | {{! 2 | If this is map and items are nullable, make sure that nulls are included. 3 | To determine what JsonInclude.Include method to use, consider the following: 4 | * If the field is required, always include it, even if it is null. 5 | * Else use custom behaviour, IOW use whatever is defined on the object mapper 6 | }} 7 | {{#withXml}} 8 | {{^isContainer}} 9 | @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") 10 | {{/isContainer}} 11 | {{#isContainer}} 12 | {{#isXmlWrapped}} 13 | // items.xmlName={{items.xmlName}} 14 | @JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}") 15 | {{/isXmlWrapped}} 16 | {{/isContainer}} 17 | {{/withXml}} 18 | -------------------------------------------------------------------------------- /codegeneration/template/model.mustache: -------------------------------------------------------------------------------- 1 | {{>licenseInfo}} 2 | 3 | package {{package}}; 4 | 5 | {{#useReflectionEqualsHashCode}} 6 | import org.apache.commons.lang3.builder.EqualsBuilder; 7 | import org.apache.commons.lang3.builder.HashCodeBuilder; 8 | {{/useReflectionEqualsHashCode}} 9 | import java.util.Objects; 10 | import java.util.Arrays; 11 | {{#imports}} 12 | import {{import}}; 13 | {{/imports}} 14 | {{#serializableModel}} 15 | import java.io.Serializable; 16 | {{/serializableModel}} 17 | {{#jackson}} 18 | {{#withXml}} 19 | import com.fasterxml.jackson.dataformat.xml.annotation.*; 20 | {{/withXml}} 21 | {{/jackson}} 22 | {{#withXml}} 23 | import javax.xml.bind.annotation.*; 24 | {{/withXml}} 25 | {{#jsonb}} 26 | import java.lang.reflect.Type; 27 | import javax.json.bind.annotation.JsonbTypeDeserializer; 28 | import javax.json.bind.annotation.JsonbTypeSerializer; 29 | import javax.json.bind.serializer.DeserializationContext; 30 | import javax.json.bind.serializer.JsonbDeserializer; 31 | import javax.json.bind.serializer.JsonbSerializer; 32 | import javax.json.bind.serializer.SerializationContext; 33 | import javax.json.stream.JsonGenerator; 34 | import javax.json.stream.JsonParser; 35 | import javax.json.bind.annotation.JsonbProperty; 36 | {{/jsonb}} 37 | {{#parcelableModel}} 38 | import android.os.Parcelable; 39 | import android.os.Parcel; 40 | {{/parcelableModel}} 41 | {{#useBeanValidation}} 42 | import javax.validation.constraints.*; 43 | import javax.validation.Valid; 44 | {{/useBeanValidation}} 45 | {{#performBeanValidation}} 46 | import org.hibernate.validator.constraints.*; 47 | {{/performBeanValidation}} 48 | 49 | {{#models}} 50 | {{#model}} 51 | {{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}{{^vendorExtensions.x-is-one-of-interface}}{{>pojo}}{{/vendorExtensions.x-is-one-of-interface}}{{/isEnum}} 52 | {{/model}} 53 | {{/models}} 54 | -------------------------------------------------------------------------------- /config/formatter/adobe.header.generated.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | -------------------------------------------------------------------------------- /config/formatter/adobe.header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=com.adobe.target 2 | version=2.6.1 3 | mavenCentralUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2 4 | pomDescription=Adobe Target Java SDK 5 | pomURL=https://docs.adobe.com/content/help/en/target/using/implement-target/server-side/api-and-sdk-overview.html 6 | pomScmURL=https://github.com/adobe/target-java-sdk 7 | pomDevId=adobe 8 | pomDevName=Adobe 9 | pomDevOrgURL=https://www.adobe.com 10 | pomLicenseName=Apache License, Version 2.0 11 | pomLicenseUrl=https://www.apache.org/licenses/LICENSE-2.0.txt 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe/target-java-sdk/a23d6ecc6b42c42bcfdabe64b2aa78a650c6fe5b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 10 09:35:05 IST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /openapi/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for choosing to contribute! 4 | 5 | The following are a set of guidelines to follow when contributing to this project. 6 | 7 | ## Code Of Conduct 8 | 9 | This project adheres to the Adobe [code of conduct](../CODE_OF_CONDUCT.md). By participating, 10 | you are expected to uphold this code. Please report unacceptable behavior to 11 | [Grp-opensourceoffice@adobe.com](mailto:Grp-opensourceoffice@adobe.com). 12 | 13 | ## Have A Question? 14 | 15 | Start by filing an issue. The existing committers on this project work to reach 16 | consensus around project direction and issue solutions within issue threads 17 | (when appropriate). 18 | 19 | ## Contributor License Agreement 20 | 21 | All third-party contributions to this project must be accompanied by a signed contributor 22 | license agreement. This gives Adobe permission to redistribute your contributions 23 | as part of the project. [Sign our CLA](https://opensource.adobe.com/cla.html). You 24 | only need to submit an Adobe CLA one time, so if you have submitted one previously, 25 | you are good to go! 26 | 27 | ## Code Reviews 28 | 29 | All submissions should come in the form of pull requests and need to be reviewed 30 | by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/) 31 | for more information on sending pull requests. 32 | 33 | Lastly, please follow the [pull request template](PULL_REQUEST_TEMPLATE.md) when 34 | submitting a pull request! 35 | 36 | ## From Contributor To Committer 37 | 38 | We love contributions from our community! If you'd like to go a step beyond contributor 39 | and become a committer with full write access and a say in the project, you must 40 | be invited to the project. The existing committers employ an internal nomination 41 | process that must reach lazy consensus (silence is approval) before invitations 42 | are issued. If you feel you are qualified and want to get more deeply involved, 43 | feel free to reach out to existing committers to have a conversation about that. 44 | 45 | ## Security Issues 46 | 47 | Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html) 48 | -------------------------------------------------------------------------------- /openapi/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Expected Behaviour 5 | 6 | ### Actual Behaviour 7 | 8 | ### Reproduce Scenario (including but not limited to) 9 | 10 | #### Steps to Reproduce 11 | 12 | #### Platform and Version 13 | 14 | #### Sample Code that illustrates the problem 15 | 16 | #### Logs taken while reproducing problem 17 | -------------------------------------------------------------------------------- /openapi/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | 7 | ## Related Issue 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Motivation and Context 15 | 16 | 17 | 18 | ## How Has This Been Tested? 19 | 20 | 21 | 22 | 23 | 24 | ## Screenshots (if appropriate): 25 | 26 | ## Types of changes 27 | 28 | 29 | 30 | - [ ] Bug fix (non-breaking change which fixes an issue) 31 | - [ ] New feature (non-breaking change which adds functionality) 32 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 33 | 34 | ## Checklist: 35 | 36 | 37 | 38 | 39 | - [ ] I have signed the [Adobe Open Source CLA](https://opensource.adobe.com/cla.html). 40 | - [ ] My code follows the code style of this project. 41 | - [ ] My change requires a change to the documentation. 42 | - [ ] I have updated the documentation accordingly. 43 | - [ ] I have read the **CONTRIBUTING** document. 44 | - [ ] I have added tests to cover my changes. 45 | - [ ] All new and existing tests passed. 46 | -------------------------------------------------------------------------------- /openapi/README.md: -------------------------------------------------------------------------------- 1 | # Target OpenAPI 2 | This repository contains OpenAPI 3.0 specifications for Target REST APIs. 3 | 4 | The APIs described here are used by Target SDKs. 5 | 6 | ## Contributing 7 | 8 | Contributions are welcome! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information. 9 | 10 | ## Licensing 11 | 12 | This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information. 13 | -------------------------------------------------------------------------------- /openapi/common/components/ABTOrder.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.2" 2 | ABTOrder: 3 | type: object 4 | description: Object that describes the order details for ABT activities. 5 | properties: 6 | id: 7 | type: string 8 | maxLength: 250 9 | description: Order id. 10 | decisionStackId: 11 | type: integer 12 | description: The decision stack id 13 | total: 14 | type: number 15 | minimum: 0 16 | description: | 17 | Order Total. The amount of money in the current order. 18 | time: 19 | type: string 20 | format: date-time 21 | description: | 22 | Time in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Time_intervals) format 23 | productIds: 24 | type: array 25 | description: A list of product ids 26 | items: 27 | type: integer 28 | -------------------------------------------------------------------------------- /openapi/common/components/AuthenticatedState.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | AuthenticatedState: 3 | type: string 4 | enum: ["unknown", "authenticated", "logged_out"] 5 | -------------------------------------------------------------------------------- /openapi/common/components/CustomerId.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | CustomerId: 3 | required: 4 | - id 5 | - integrationCode 6 | - authenticatedState 7 | type: object 8 | properties: 9 | id: 10 | type: string 11 | maxLength: 128 12 | integrationCode: 13 | type: string 14 | maxLength: 50 15 | description: This is the **alias** used when setting up a CRS datasource in the Marketing Cloud UI. 16 | authenticatedState: 17 | $ref: "./AuthenticatedState.yaml#/AuthenticatedState" 18 | -------------------------------------------------------------------------------- /openapi/common/components/Order.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.2" 2 | Order: 3 | type: object 4 | description: Object that describes the order details. 5 | properties: 6 | id: 7 | type: string 8 | maxLength: 250 9 | description: Order Id. 10 | total: 11 | type: number 12 | minimum: 0 13 | description: | 14 | Order Total. The amount of money in the current order. 15 | purchasedProductIds: 16 | type: array 17 | description: | 18 | Order's product ids. 19 | Validation 20 | * No blank values allowed. 21 | * Each product Id max length 50. 22 | * Product ids, separated by commas and concatenated, total length should not exceed 250. 23 | items: 24 | type: string 25 | time: 26 | type: string 27 | format: date-time 28 | description: | 29 | Time in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Time_intervals) format 30 | experienceLocalId: 31 | type: integer 32 | minimum: 0 33 | maximum: 2147483647 34 | description: Id used to track the experience across POST/PUT requests 35 | duplicate: 36 | type: boolean 37 | description: Whether or not the order is a duplicate 38 | outlier: 39 | type: boolean 40 | description: Whether or not the order is abnormally different from the rest in volume 41 | -------------------------------------------------------------------------------- /openapi/common/components/Parameters.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Parameters: 3 | type: object 4 | maxProperties: 50 5 | description: | 6 | Parameters map. 7 | Same object is reused for mbox or profile parameters with slight validation differences. 8 | Following names are not allowed for mbox parameters: 'orderId', 'orderTotal', productPurchasedIds' 9 | Validation (for both mbox and profile parameters): 10 | * Max 50 parameters limit. 11 | * Parameter name should not be blank. 12 | * Parameter name max length 128. 13 | * Parameter name should not start with 'profile.' 14 | * Parameter value length max 5000. 15 | additionalProperties: 16 | type: string 17 | description: Name of the property 18 | -------------------------------------------------------------------------------- /openapi/common/components/Preview.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Preview: 3 | type: object 4 | description: | 5 | Use this object to enable the Preview mode in the request. 6 | Use the Preview mode to test the look and feel of your site for various location and offer combinations. 7 | 8 | properties: 9 | token: 10 | type: string 11 | description: | 12 | The token for the Preview mode. 13 | Validation 14 | * Verify that the token belongs to the client provided in request. 15 | -------------------------------------------------------------------------------- /openapi/common/components/Product.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Product: 3 | type: object 4 | description: The properties of the products 5 | properties: 6 | id: 7 | type: string 8 | maxLength: 128 9 | description: Product id. Should not be blank. 10 | categoryId: 11 | type: string 12 | maxLength: 128 13 | description: Category id. Should not be blank. 14 | -------------------------------------------------------------------------------- /openapi/common/components/QAMode.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | QAMode: 3 | type: object 4 | description: | 5 | Use this object to enable the QA mode in the request. 6 | Use the QA mode to test the look and feel of your site or application for various activities in isolation or together, 7 | with the possibilty to match or not match specified audiences, select a specific experience, count the 8 | impressions/visits for the reporting or not. 9 | 10 | properties: 11 | token: 12 | type: string 13 | description: | 14 | The encrypted token for the QA mode. It contains the list of the activity ids that are allowed to 15 | be executed in QA mode. 16 | Validation 17 | * After decryption, the client code from the token should match the one from the request. 18 | * After decryption, activities with the ids specified in the token should belong to the client. 19 | listedActivitiesOnly: 20 | type: boolean 21 | description: | 22 | Specifies whether qa_mode campaigns should be executed in isolation or if they should be evaluated along other 23 | active campaigns for current environment. 24 | evaluateAsTrueAudienceIds: 25 | type: array 26 | description: | 27 | List of audience ids that should be always evaluated as TRUE in the scope of the delivery request 28 | items: 29 | type: integer 30 | format: int64 31 | evaluateAsFalseAudienceIds: 32 | type: array 33 | description: | 34 | List of audience ids that should be always evaluated as FALSE in the scope of the delivery request 35 | items: 36 | type: integer 37 | format: int64 38 | previewIndexes: 39 | type: array 40 | description: | 41 | List of preview indexes. If present, the list cannot be empty. 42 | items: 43 | $ref: "./QAModePreviewIndex.yaml#/QAModePreviewIndex" 44 | -------------------------------------------------------------------------------- /openapi/common/components/QAModePreviewIndex.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | QAModePreviewIndex: 3 | type: object 4 | properties: 5 | activityIndex: 6 | type: integer 7 | minimum: 1 8 | description: | 9 | Index references the activity in the activity list (from the encrypted token). 10 | Validation 11 | * If the activity list index is out of boundaries of the activities list in the token or if it is null it will be ignored. 12 | * Activity list index starts with 1. 13 | * Should be at least one activity index, and should reference an activity specified in the token. 14 | experienceIndex: 15 | type: integer 16 | minimum: 1 17 | description: | 18 | When specified, the experience with this index in the activity definition will be selected. 19 | Validation 20 | * Can be null (unspecified) 21 | * If index is not specified or out of bounds, the experience will be selected via activity experience selector strategy. 22 | * Experience index starts with 1. 23 | -------------------------------------------------------------------------------- /openapi/common/components/ResponseTokens.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ResponseTokens: 3 | type: object 4 | description: | 5 | List of the response tokens and their values for the given option. 6 | Response tokens can be defined via the /v1/responsetokens API. 7 | The values for the tokens are computed for every option returned by a activity and represented as a dictionary: 8 | * Key - the response token name. 9 | * Value - the response token value. The value is usually a string, but it can be a list of string in case of 10 | 'category affinity' response token. 11 | additionalProperties: 12 | type: object 13 | properties: 14 | responseTokenName: 15 | type: string 16 | responseTokenValue: 17 | type: object 18 | -------------------------------------------------------------------------------- /openapi/common/components/UnexpectedError.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | UnexpectedError: 3 | type: object 4 | required: 5 | - status 6 | - message 7 | properties: 8 | status: 9 | type: integer 10 | format: int32 11 | description: | 12 | HTTP response codes: 13 | * `400` - Validation error (ex. invalid token) 14 | * `500` - An internal server error during processing 15 | message: 16 | type: string 17 | description: error message 18 | -------------------------------------------------------------------------------- /openapi/common/components/VisitorId.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | VisitorId: 3 | type: object 4 | description: | 5 | Object that contains the identifiers for the visitor. 6 | If no id is provided in the first request, Target will generate a VisitorId with a tntId. The code that runs on the 7 | client side is then responsible for passing this tntId value on all subsequent calls. 8 | 9 | Validation 10 | * Either tntId, thirdPartyId or maketingCloudVisistorId required. 11 | properties: 12 | tntId: 13 | type: string 14 | maxLength: 128 15 | description: | 16 | Tnt id - an unique identifier (UUID). 17 | If no visitor id is provided the TNT id will be generated by the TNT server. 18 | The TNT id retunred by the server may also contain the profile location hint, 19 | with the same format as for other endpoints (standard/ajax/json/..). 20 | Example 32440324234-2343423.23_41, in this example the 23_41 is the profile location hint. 21 | Tnt id retuned in the response (containting the profile location hint) should be used in the subsequent requests 22 | 23 | Validation 24 | * Should not contain a '.' (dot) unless the dot delimits the location hint. 25 | thirdPartyId: 26 | type: string 27 | maxLength: 128 28 | description: | 29 | Third party id 30 | marketingCloudVisitorId: 31 | type: string 32 | maxLength: 128 33 | description: | 34 | Marketing cloud visitor id 35 | customerIds: 36 | type: array 37 | maxItems: 50 38 | description: | 39 | Along with the marketing cloud visitor id, you can associate additional customer ids 40 | 41 | Validation 42 | * No null elements. 43 | items: 44 | $ref: "./CustomerId.yaml#/CustomerId" 45 | -------------------------------------------------------------------------------- /openapi/delivery/components/Address.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Address: 3 | type: object 4 | description: The address object. It indicates the current URL and the referring URL. 5 | properties: 6 | url: 7 | type: string 8 | maxLength: 4096 9 | description: URL 10 | referringUrl: 11 | type: string 12 | maxLength: 4096 13 | description: referral URL 14 | -------------------------------------------------------------------------------- /openapi/delivery/components/AnalyticsPayload.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | AnalyticsPayload: 3 | type: object 4 | description: | 5 | Analytics payload for client side integration that should be sent to Analytics after content has been applied. 6 | properties: 7 | pe: 8 | type: string 9 | description: Indicates to Adobe Analytics that the payload is an Adobe Target type 10 | tnta: 11 | type: string 12 | description: Contains Target metadata that describes the activity and experience 13 | -------------------------------------------------------------------------------- /openapi/delivery/components/AnalyticsRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | AnalyticsRequest: 3 | type: object 4 | description: Integration with Adobe Analytics (A4T) 5 | properties: 6 | supplementalDataId: 7 | type: string 8 | description: | 9 | Supplemental data id, used for **server side** integrations. 10 | Format <16 hexadecimal digits>-<16 hexadecimal digits> 11 | maxLength: 33 12 | minLength: 33 13 | logging: 14 | $ref: "./LoggingType.yaml#/LoggingType" 15 | trackingServer: 16 | type: string 17 | description: tracking server domain (should not include http://) 18 | trackingServerSecure: 19 | type: string 20 | description: secure tracking server domain (should not include https://) 21 | -------------------------------------------------------------------------------- /openapi/delivery/components/AnalyticsResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | AnalyticsResponse: 3 | type: object 4 | description: Contains the analytics payload metadata 5 | properties: 6 | payload: 7 | $ref: "./AnalyticsPayload.yaml#/AnalyticsPayload" 8 | -------------------------------------------------------------------------------- /openapi/delivery/components/Application.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Application: 3 | type: object 4 | description: Application identifiers. If specified, should match the with the one from the activity. 5 | properties: 6 | id: 7 | type: string 8 | maxLength: 250 9 | description: | 10 | Application ID. 11 | If not specified - all activities with any applicationId will be evaluated. 12 | If specified - only activities with the matching applicationId will be evaluated. 13 | name: 14 | type: string 15 | maxLength: 250 16 | description: | 17 | Application name. 18 | If not specified - all activities with any applicationName will be evaluated. 19 | If specified - only activities with specified applicationName will be evaluated. 20 | version: 21 | type: string 22 | maxLength: 128 23 | description: | 24 | Application version 25 | If not specified - all activities with any applicationVersion will not be evaluated. 26 | If specified - only activities with specific applicationVersion will be evaluated. 27 | -------------------------------------------------------------------------------- /openapi/delivery/components/AudienceManager.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | AudienceManager: 3 | type: object 4 | description: Audience Manager Integration (AAM). 5 | properties: 6 | locationHint: 7 | type: integer 8 | minimum: 1 9 | description: | 10 | DCS location hint. 11 | Used to determine which AAM DCS Endpoint to hit in order to retrieve the profile. 12 | blob: 13 | type: string 14 | minLength: 1 15 | maxLength: 1024 16 | description: | 17 | AAM Blob. Used to send additional data to AAM. 18 | Validation 19 | * Cannot be blank. 20 | -------------------------------------------------------------------------------- /openapi/delivery/components/Browser.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Browser: 3 | type: object 4 | description: Browser object may be specified only when the Channel is Web. 5 | properties: 6 | host: 7 | type: string 8 | description: Current web page host 9 | language: 10 | type: string 11 | description: Language in Accept-Language header format, see RFC 7231 sec. 5.3.5 12 | webGLRenderer: 13 | type: string 14 | description: | 15 | This is an optional field, added to help with device detection using device atlas 16 | -------------------------------------------------------------------------------- /openapi/delivery/components/ChannelType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ChannelType: 3 | type: string 4 | description: | 5 | Specifies the channel for the request. Only activities with the matching channel will be evaluated. 6 | enum: ["mobile", "web"] 7 | 8 | -------------------------------------------------------------------------------- /openapi/delivery/components/ClientHints.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ClientHints: 3 | type: object 4 | description: | 5 | Client hints data. Used in place of userAgent if provided. 6 | properties: 7 | mobile: 8 | type: boolean 9 | description: Sec-CH-UA-Mobile (low entropy) 10 | model: 11 | type: string 12 | description: Sec-CH-UA-Model 13 | platform: 14 | type: string 15 | description: Sec-CH-UA-Platform (low entropy) 16 | platformVersion: 17 | type: string 18 | description: Sec-CH-UA-Platform-Version 19 | browserUAWithMajorVersion: 20 | type: string 21 | description: Sec-CH-UA (low entropy) 22 | browserUAWithFullVersion: 23 | type: string 24 | description: Sec-CH-UA-Full-Version-List 25 | architecture: 26 | type: string 27 | description: Sec-CH-UA-Arch 28 | bitness: 29 | type: string 30 | description: Sec-CH-UA-Bitness 31 | -------------------------------------------------------------------------------- /openapi/delivery/components/Context.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Context: 3 | type: object 4 | required: 5 | - channel 6 | description: Specifies the context for the request, IE if it a web request then is should include user agent etc. 7 | properties: 8 | channel: 9 | $ref: "./ChannelType.yaml#/ChannelType" 10 | mobilePlatform: 11 | $ref: "./MobilePlatform.yaml#/MobilePlatform" 12 | application: 13 | $ref: "./Application.yaml#/Application" 14 | screen: 15 | $ref: "./Screen.yaml#/Screen" 16 | window: 17 | $ref: "./Window.yaml#/Window" 18 | browser: 19 | $ref: "./Browser.yaml#/Browser" 20 | address: 21 | $ref: "./Address.yaml#/Address" 22 | geo: 23 | $ref: "./Geo.yaml#/Geo" 24 | timeOffsetInMinutes: 25 | type: number 26 | description: Specifies minutes from UTC for specific client 27 | format: double 28 | userAgent: 29 | description: User-Agent should be sent only via this property. HTTP header User-Agent is ignored. 30 | type: string 31 | clientHints: 32 | $ref: "./ClientHints.yaml#/ClientHints" 33 | beacon: 34 | type: boolean 35 | default: false 36 | description: | 37 | In case beacon = true is provided in the request, the server will return a 204 No Content response with no response body. 38 | -------------------------------------------------------------------------------- /openapi/delivery/components/DecisioningMethod.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | DecisioningMethod: 3 | x-enum-as-string: true 4 | type: string 5 | enum: ["server-side", "on-device", "hybrid"] 6 | -------------------------------------------------------------------------------- /openapi/delivery/components/DeliveryRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | DeliveryRequest: 3 | type: object 4 | required: 5 | - context 6 | properties: 7 | requestId: 8 | type: string 9 | maxLength: 128 10 | description: | 11 | The request ID that will be returned in the response. In case it is not provided, an UUID is generated and 12 | returned automatically. 13 | impressionId: 14 | description: | 15 | If not present it will be automatically generated (UUID). If present, second and subsequent requests with the 16 | same id will not increment impressions to activities/metrics. Similar to page id. 17 | type: string 18 | maxLength: 128 19 | id: 20 | $ref: "../../common/components/VisitorId.yaml#/VisitorId" 21 | environmentId: 22 | description: Valid client environment id. If not specified host will be determined base on the provided host. 23 | type: integer 24 | format: int64 25 | property: 26 | $ref: "./Property.yaml#/Property" 27 | trace: 28 | $ref: "./Trace.yaml#/Trace" 29 | context: 30 | $ref: "./Context.yaml#/Context" 31 | experienceCloud: 32 | $ref: "./ExperienceCloud.yaml#/ExperienceCloud" 33 | execute: 34 | $ref: "./ExecuteRequest.yaml#/ExecuteRequest" 35 | prefetch: 36 | $ref: "./PrefetchRequest.yaml#/PrefetchRequest" 37 | telemetry: 38 | $ref: "./Telemetry.yaml#/Telemetry" 39 | notifications: 40 | type: array 41 | description: Notifications for the displayed content, clicked selectors, and/or visited views or mboxes. 42 | items: 43 | $ref: "./Notification.yaml#/Notification" 44 | qaMode: 45 | $ref: "../../common/components/QAMode.yaml#/QAMode" 46 | preview: 47 | $ref: "../../common/components/Preview.yaml#/Preview" 48 | -------------------------------------------------------------------------------- /openapi/delivery/components/DeliveryResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | DeliveryResponse: 3 | type: object 4 | description: Delivery response. Returned content will be based upon the request and client's active activities. 5 | properties: 6 | status: 7 | type: integer 8 | requestId: 9 | type: string 10 | description: | 11 | ID of the processed request. 12 | If it's not sent in the request, a random ID (UUID) is generated and returned with the response. 13 | id: 14 | $ref: "../../common/components/VisitorId.yaml#/VisitorId" 15 | client: 16 | type: string 17 | description: Client's code. The one which was sent in the request's path. 18 | edgeHost: 19 | description: Cluster host name that served the response. Ideally, all subsequent requests should be made to that host. 20 | type: string 21 | execute: 22 | $ref: "./ExecuteResponse.yaml#/ExecuteResponse" 23 | prefetch: 24 | $ref: "./PrefetchResponse.yaml#/PrefetchResponse" 25 | notifications: 26 | type: array 27 | items: 28 | $ref: "./NotificationResponse.yaml#/NotificationResponse" 29 | telemetryServerToken: 30 | type: string 31 | description: Encoded data with request telemetry collected from Delivery API 32 | 33 | -------------------------------------------------------------------------------- /openapi/delivery/components/DeviceType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | DeviceType: 3 | type: string 4 | description: | 5 | Field is mandatory when Mobile Platform is specified. 6 | Only activities that match the specified deviceType or have the device type set to 'null' will be 7 | evaluated. Ex if device type is 'phone' in the delivery request, then only activities that have the device type 8 | equal to 'phone' or set to 'null' will be evaluated. 9 | An activity with 'null' device type will be evaluated for requests for both, 'phone' and 'tablet'. 10 | enum: ["phone", "tablet"] 11 | 12 | -------------------------------------------------------------------------------- /openapi/delivery/components/ExecuteRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ExecuteRequest: 3 | type: object 4 | description: | 5 | The execute part of the request that will be evaluated on the server side immediately. 6 | Impressions will be incremented for the matching activities. 7 | properties: 8 | pageLoad: 9 | $ref: "./RequestDetails.yaml#/RequestDetails" 10 | mboxes: 11 | type: array 12 | description: An array of mboxes other than global mbox. 13 | items: 14 | $ref: "./MboxRequest.yaml#/MboxRequest" 15 | -------------------------------------------------------------------------------- /openapi/delivery/components/ExecuteResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ExecuteResponse: 3 | type: object 4 | description: The object that contains responses from execute `pageLoad` and/or execute regional `mboxes` request. 5 | properties: 6 | pageLoad: 7 | $ref: "./PageLoadResponse.yaml#/PageLoadResponse" 8 | mboxes: 9 | type: array 10 | description: The list of responses for requested regional mboxes. 11 | items: 12 | $ref: "./MboxResponse.yaml#/MboxResponse" 13 | -------------------------------------------------------------------------------- /openapi/delivery/components/ExecutionMode.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ExecutionMode: 3 | type: string 4 | enum: ["edge", "local"] 5 | -------------------------------------------------------------------------------- /openapi/delivery/components/ExperienceCloud.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ExperienceCloud: 3 | type: object 4 | description: Integrations with Audience Manager and Analytics 5 | properties: 6 | audienceManager: 7 | $ref: "./AudienceManager.yaml#/AudienceManager" 8 | analytics: 9 | $ref: "./AnalyticsRequest.yaml#/AnalyticsRequest" 10 | -------------------------------------------------------------------------------- /openapi/delivery/components/Geo.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Geo: 3 | type: object 4 | description: | 5 | Geo data. If not specified, and Geo is enabled for the client, it will be resolved via user's IP. 6 | properties: 7 | ipAddress: 8 | type: string 9 | pattern: '((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))' 10 | description: IPv4 or IPv6 address for Geo resolution 11 | latitude: 12 | type: number 13 | format: float 14 | description: Latitude 15 | longitude: 16 | type: number 17 | format: float 18 | description: Longitude 19 | countryCode: 20 | type: string 21 | minLength: 2 22 | maxLength: 2 23 | description: Country code in ISO 3166-1 alpha-2 format 24 | stateCode: 25 | type: string 26 | minLength: 1 27 | maxLength: 3 28 | description: Alphanumeric characters representing the subdivision part from ISO 3166-2 29 | city: 30 | type: string 31 | maxLength: 50 32 | description: City 33 | zip: 34 | type: string 35 | maxLength: 12 36 | description: Zip/Postal Code 37 | 38 | -------------------------------------------------------------------------------- /openapi/delivery/components/LoggingType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | LoggingType: 3 | type: string 4 | description: | 5 | Indicates whether integraion will be done via client side (from the client) or server side (edge servers) 6 | enum: ["server_side", "client_side"] 7 | 8 | -------------------------------------------------------------------------------- /openapi/delivery/components/MboxRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | MboxRequest: 3 | required: 4 | - index 5 | - mbox 6 | description: Regional mbox request. 7 | allOf: 8 | - $ref: "./RequestDetails.yaml#/RequestDetails" 9 | - type: object 10 | properties: 11 | index: 12 | type: integer 13 | format: int32 14 | description: | 15 | An index for the mboxes to be executed or prefetched. 16 | Mbox index is used for correlation between the mbox request with the mbox response, for either prefetch or 17 | execute responses. Index should be unique in the mbox list. 18 | name: 19 | type: string 20 | description: | 21 | The name of the regional mbox to be evaluated. 22 | -------------------------------------------------------------------------------- /openapi/delivery/components/MboxResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | MboxResponse: 3 | type: object 4 | description: | 5 | Mbox response object. 6 | discriminator: 7 | propertyName: $_type 8 | properties: 9 | $_type: 10 | type: string 11 | index: 12 | type: integer 13 | format: int32 14 | description: | 15 | Indicates that the response is for mbox with the same index, as was specified in the prefetch or execute request. 16 | name: 17 | type: string 18 | description: | 19 | The name of the mbox. Since the same mbox name can be specified multiple times in the request it 20 | should be used in conjunction with the index. 21 | options: 22 | type: array 23 | description: | 24 | The option that was matched for the current mbox. Cannot be an offer with templates or a visual offer. 25 | items: 26 | $ref: "./Option.yaml#/Option" 27 | metrics: 28 | type: array 29 | description: Click metrics. 30 | items: 31 | $ref: "./Metric.yaml#/Metric" 32 | analytics: 33 | $ref: "./AnalyticsResponse.yaml#/AnalyticsResponse" 34 | trace: 35 | $ref: "./TraceResponse.yaml#/TraceResponse" 36 | -------------------------------------------------------------------------------- /openapi/delivery/components/Metric.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Metric: 3 | type: object 4 | properties: 5 | type: 6 | $ref: "./MetricType.yaml#/MetricType" 7 | selector: 8 | type: string 9 | description: The selector 10 | eventToken: 11 | description: The event token that should be sent with the notifications in case the click occurred. 12 | type: string 13 | analytics: 14 | description: Analytics payload for A4T integration 15 | $ref: "./AnalyticsResponse.yaml#/AnalyticsResponse" 16 | -------------------------------------------------------------------------------- /openapi/delivery/components/MetricType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | MetricType: 3 | type: string 4 | description: Notification type. Currently only click and display are supported. 5 | enum: ["click", "display"] 6 | 7 | -------------------------------------------------------------------------------- /openapi/delivery/components/MobilePlatform.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | MobilePlatform: 3 | type: object 4 | required: 5 | - deviceType 6 | - platformType 7 | description: Mobile Platform should be specified when the channel is Mobile 8 | properties: 9 | deviceName: 10 | description: | 11 | Optional field, added to help with device detection using device atlas. 12 | This is equivalent of a.DeviceName field passed in from Mobile SDK 13 | type: string 14 | deviceType: 15 | $ref: "./DeviceType.yaml#/DeviceType" 16 | platformType: 17 | $ref: "./MobilePlatformType.yaml#/MobilePlatformType" 18 | version: 19 | type: string 20 | maxLength: 128 21 | description: | 22 | If not specified - all activities with any platformVersion will be evaluated. 23 | If specified - only activities with the same platformVersion will be evaluated. 24 | -------------------------------------------------------------------------------- /openapi/delivery/components/MobilePlatformType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | MobilePlatformType: 3 | type: string 4 | description: Only activities with the specified mobile platform type will be evaluated. 5 | enum: ["android", "ios"] 6 | -------------------------------------------------------------------------------- /openapi/delivery/components/Notification.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Notification: 3 | description: | 4 | Notification object is used to sent notificaitons regarding what prefetched content was displayed 5 | (for views, pageLoad or regional mboxes), which views, pages and mboxes were visited (triggered), 6 | and which elements were clicked. 7 | Notification request detail will be validated and in case there are validation errors with any token or timestamp 8 | the entire request will be invalidated, so there are no cases of inconsistent data, caused by a partially 9 | processed notification. 10 | that may happen with a partially processed notification. This is different from the approach in the batch mbox v2 API. 11 | Mboxes and views are mutually exclusive. 12 | required: 13 | - id 14 | - type 15 | - timestamp 16 | allOf: 17 | - $ref: "./RequestDetails.yaml#/RequestDetails" 18 | - type: object 19 | properties: 20 | id: 21 | type: string 22 | maxLength: 200 23 | description: | 24 | Notification id will be returned in response and will indicate that the notification was processed 25 | successfully. 26 | impressionId: 27 | type: string 28 | maxLength: 128 29 | description: | 30 | Impression id is used to stitch (link) the current notification with a previous notification or 31 | execute request. In case they both of them match, the second and other subsequent requests will not generate a 32 | new impression to the activity, experience etc. 33 | type: 34 | $ref: "./MetricType.yaml#/MetricType" 35 | timestamp: 36 | type: integer 37 | format: int64 38 | description: Timestamp of the notification, in milliseconds elapsed since UNIX epoch. 39 | tokens: 40 | type: array 41 | description: A list of tokens for displayed content or clicked selectors, based on the type of notification. 42 | items: 43 | type: string 44 | mbox: 45 | description: Notification for a regional mbox 46 | $ref: "./NotificationMbox.yaml#/NotificationMbox" 47 | view: 48 | $ref: "./NotificationView.yaml#/NotificationView" 49 | pageLoad: 50 | $ref: "./NotificationPageLoad.yaml#/NotificationPageLoad" 51 | -------------------------------------------------------------------------------- /openapi/delivery/components/NotificationMbox.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | NotificationMbox: 3 | type: object 4 | properties: 5 | name: 6 | type: string 7 | maxLength: 250 8 | description: | 9 | Mbox name. 10 | Validation 11 | * No blank values allowed. 12 | * A '-clicked' suffix or the following names are not allowed for mbox names: ** display mboxes **, ** any mbox **, ** click from display mbox ** 13 | * Allowed chars: - '-, ./=`:;&!@#$%^&*()+|?~[]{}' 14 | state: 15 | type: string 16 | description: Mbox state token 17 | -------------------------------------------------------------------------------- /openapi/delivery/components/NotificationPageLoad.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | NotificationPageLoad: 3 | type: object 4 | description: Include this object to send display notifications for the prefetch page load contnet. 5 | properties: 6 | state: 7 | type: string 8 | description: Page Load state token 9 | -------------------------------------------------------------------------------- /openapi/delivery/components/NotificationResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | NotificationResponse: 3 | type: object 4 | description: | 5 | Notification response. Contains the result of a processed notification. 6 | properties: 7 | id: 8 | type: string 9 | description: | 10 | Notification id which indicates that the notification was processed successfully. 11 | trace: 12 | $ref: "./TraceResponse.yaml#/TraceResponse" 13 | -------------------------------------------------------------------------------- /openapi/delivery/components/NotificationView.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | NotificationView: 3 | type: object 4 | description: Notification for the displayed view. 5 | properties: 6 | name: 7 | type: string 8 | maxLength: 128 9 | description: | 10 | View Name - Unique view name. If the activity has a metric with a view with this name it will be matched, 11 | providing the Key matches as well or is null and view and metric targeting is matched. 12 | key: 13 | type: string 14 | maxLength: 512 15 | description: | 16 | View Key - An optional encoded String identifier used in advanced scenarios, such as View fingerprinting. 17 | Same matching conditions as for View Name. 18 | state: 19 | type: string 20 | description: View state token. 21 | -------------------------------------------------------------------------------- /openapi/delivery/components/Option.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Option: 3 | type: object 4 | description: The content from the activitiesc is returned via the option objects. 5 | properties: 6 | type: 7 | $ref: "./OptionType.yaml#/OptionType" 8 | content: 9 | description: | 10 | Content that should be applied/displayed/replaced etc, based on the option type. Content can be one of: 11 | * html 12 | * redirect link 13 | * link for a dynamic offer 14 | * raw json 15 | * one or more actions (json - from offers with templates and visual offers) 16 | Actions format is specific for delivery API. 17 | oneOf: 18 | - type: string 19 | - type: object 20 | - type: array 21 | items: 22 | $ref: "#/components/schemas/Action" 23 | eventToken: 24 | description: | 25 | Will be present only in response of a prefetch request. After the content is displayed the event token should be 26 | sent via notifications to the edge server so that visit/visitor/impression events could be logged. 27 | type: string 28 | responseTokens: 29 | $ref: "../../common/components/ResponseTokens.yaml#/ResponseTokens" 30 | 31 | components: 32 | schemas: 33 | Action: 34 | type: object 35 | properties: 36 | type: 37 | type: string 38 | selector: 39 | type: string 40 | cssSelector: 41 | type: string 42 | content: 43 | oneOf: 44 | - type: string 45 | - type: object 46 | -------------------------------------------------------------------------------- /openapi/delivery/components/OptionType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | OptionType: 3 | type: string 4 | enum: ["html", "json", "redirect", "dynamic", "actions"] -------------------------------------------------------------------------------- /openapi/delivery/components/PageLoadResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | PageLoadResponse: 3 | type: object 4 | description: | 5 | Page load response. Contains the result of prefetching or executing a request that will retrieve content for 6 | all selectors not associated with a particular view. 7 | properties: 8 | options: 9 | type: array 10 | description: | 11 | List of options that should be applied. 12 | Note: options that have been set on selectors assigned to views will not be included here. 13 | items: 14 | $ref: "./Option.yaml#/Option" 15 | metrics: 16 | type: array 17 | description: | 18 | Click track metrics. Note that click metrics for selectors set with views will not be included here. 19 | If the same activity is serving content for selectors on a view and selectors unassociated with 20 | views, and having click track metrics not associated with any view within the activity, then: 21 | * in case of a prefetch-only request, these metrics (tokens) will be set in the prefetch response's metrics. 22 | * in case of an execute-only request, the metrics will be set in the pageLoad response's metrics. 23 | * in case of a request, with both execute and prefetch, the metrics will be set in the pageLoad response's metrics only. 24 | items: 25 | $ref: "./Metric.yaml#/Metric" 26 | analytics: 27 | $ref: "./AnalyticsResponse.yaml#/AnalyticsResponse" 28 | state: 29 | type: string 30 | description: | 31 | View state token that must be sent back with display notification for the view. 32 | May only be present for prefetch requests. 33 | trace: 34 | $ref: "./TraceResponse.yaml#/TraceResponse" 35 | -------------------------------------------------------------------------------- /openapi/delivery/components/PrefetchMboxResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | PrefetchMboxResponse: 3 | allOf: 4 | - $ref: "./MboxResponse.yaml#/MboxResponse" 5 | - type: object 6 | properties: 7 | state: 8 | type: string 9 | description: Mbox state token that must be sent back with display notification for the mbox. 10 | -------------------------------------------------------------------------------- /openapi/delivery/components/PrefetchRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | PrefetchRequest: 3 | type: object 4 | description: | 5 | Use this object to prefetch the content for `views` and/or `pageLoad` and/or `mboxes`. 6 | * `views` - the request to prefetch selectors grouped per view. 7 | * `pageLoad` - the request to prefetch selectors not assigned to any view. 8 | * `mboxes` - the request to prefetch mbox content. 9 | properties: 10 | views: 11 | type: array 12 | description: | 13 | An array of views 14 | items: 15 | $ref: "./ViewRequest.yaml#/ViewRequest" 16 | pageLoad: 17 | $ref: "./RequestDetails.yaml#/RequestDetails" 18 | mboxes: 19 | type: array 20 | description: Prefetch the content for the regional mbox. 21 | items: 22 | $ref: "./MboxRequest.yaml#/MboxRequest" 23 | -------------------------------------------------------------------------------- /openapi/delivery/components/PrefetchResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | PrefetchResponse: 3 | type: object 4 | description: | 5 | The object that will return the prefetched content based on the request, active activities etc 6 | properties: 7 | views: 8 | type: array 9 | description: | 10 | Contains all the views matching the request. 11 | items: 12 | $ref: "./View.yaml#/View" 13 | pageLoad: 14 | $ref: "./PageLoadResponse.yaml#/PageLoadResponse" 15 | mboxes: 16 | type: array 17 | description: | 18 | Prefetched mboxes, including content and notification tokens to be sent back when the mboxes are displayed. 19 | items: 20 | $ref: "./PrefetchMboxResponse.yaml#/PrefetchMboxResponse" 21 | metrics: 22 | type: array 23 | description: | 24 | Click track metrics that are not assigned with a view but are present in activities that have views. 25 | If the same activity is serving content for selectors on a view and selectors unassociated with 26 | views, and having click track metrics not associated with any view within the activity, then: 27 | * in case of a prefetch-only request, these metrics (tokens) will be set in the prefetch response's metrics. 28 | * in case of an execute-only request, the metrics will be set in the pageLoad response's metrics. 29 | * in case of a request, with both execute and prefetch, the metrics will be set in the pageLoad response's metrics only. 30 | items: 31 | $ref: "./Metric.yaml#/Metric" 32 | -------------------------------------------------------------------------------- /openapi/delivery/components/Property.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Property: 3 | type: object 4 | required: 5 | - token 6 | description: | 7 | Specifies the at_property via the token field. It can be used to control the scope for the delivery. 8 | properties: 9 | token: 10 | description: | 11 | The at_property token 12 | 13 | Validation 14 | * Required if the property is specified. 15 | type: string 16 | -------------------------------------------------------------------------------- /openapi/delivery/components/RequestDetails.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | RequestDetails: 3 | type: object 4 | description: Object common for prefetch, execute and notifications in order to specify the request details. 5 | discriminator: 6 | propertyName: $_type 7 | properties: 8 | $_type: 9 | type: string 10 | address: 11 | $ref: "./Address.yaml#/Address" 12 | parameters: 13 | $ref: "../../common/components/Parameters.yaml#/Parameters" 14 | profileParameters: 15 | $ref: "../../common/components/Parameters.yaml#/Parameters" 16 | order: 17 | $ref: "../../common/components/Order.yaml#/Order" 18 | product: 19 | $ref: "../../common/components/Product.yaml#/Product" 20 | -------------------------------------------------------------------------------- /openapi/delivery/components/Screen.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Screen: 3 | type: object 4 | description: The properties that dictate a screen 5 | properties: 6 | width: 7 | type: number 8 | format: double 9 | description: width 10 | height: 11 | type: number 12 | format: double 13 | description: height 14 | colorDepth: 15 | type: number 16 | format: double 17 | description: color depth 18 | pixelRatio: 19 | type: number 20 | format: double 21 | description: Optional, Used for device detection using the device atlas 22 | orientation: 23 | $ref: "./ScreenOrientationType.yaml#/ScreenOrientationType" 24 | -------------------------------------------------------------------------------- /openapi/delivery/components/ScreenOrientationType.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ScreenOrientationType: 3 | type: string 4 | description: | 5 | If not specified, all activities with any screen orientation will be evaluated. 6 | If specified, only the activities with the matching screen orientation will evaluated. 7 | enum: ["portrait", "landscape"] 8 | -------------------------------------------------------------------------------- /openapi/delivery/components/Telemetry.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Telemetry: 3 | type: object 4 | description: Telemetry 5 | properties: 6 | entries: 7 | type: array 8 | description: An array of Telemetry Entries. 9 | items: 10 | $ref: "./TelemetryEntry.yaml#/TelemetryEntry" 11 | -------------------------------------------------------------------------------- /openapi/delivery/components/TelemetryEntry.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | TelemetryEntry: 3 | type: object 4 | description: Telemetry Entry. 5 | properties: 6 | requestId: 7 | type: string 8 | description: Request Id 9 | timestamp: 10 | type: integer 11 | format: int64 12 | description: Timestamp of the entry, in milliseconds elapsed since UNIX epoch. 13 | mode: 14 | $ref: "./ExecutionMode.yaml#/ExecutionMode" 15 | description: Execution Mode for request 16 | execution: 17 | type: number 18 | format: double 19 | description: Execution time in milliseconds. 20 | parsing: 21 | type: number 22 | format: double 23 | description: Response parsing time, in milliseconds elapsed since UNIX epoch. 24 | features: 25 | $ref: "./TelemetryFeatures.yaml#/TelemetryFeatures" 26 | description: Features used by the SDK 27 | request: 28 | $ref: "./TelemetryRequest.yaml#/TelemetryRequest" 29 | description: Details of the request either to Target or CDN 30 | telemetryServerToken: 31 | type: string 32 | description: Encoded data with telemetry collected from previous request to Delivery API 33 | -------------------------------------------------------------------------------- /openapi/delivery/components/TelemetryFeatures.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | TelemetryFeatures: 3 | type: object 4 | description: Telemetry Features 5 | properties: 6 | decisioningMethod: 7 | $ref: "./DecisioningMethod.yaml#/DecisioningMethod" 8 | description: Decisioning Method used 9 | executeMboxCount: 10 | type: integer 11 | description: Number of mboxes in execute request 12 | executePageLoad: 13 | type: boolean 14 | description: Indicates if execute pageLoad was used 15 | prefetchMboxCount: 16 | type: integer 17 | description: Number of prefetched mboxes 18 | prefetchPageLoad: 19 | type: boolean 20 | description: Indicates if prefetch pageLoad was used 21 | prefetchViewCount: 22 | type: integer 23 | description: Number of prefetched views 24 | -------------------------------------------------------------------------------- /openapi/delivery/components/TelemetryRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | TelemetryRequest: 3 | type: object 4 | description: Telemetry Request 5 | properties: 6 | dns: 7 | type: number 8 | format: double 9 | description: DNS resolution time, in milliseconds elapsed since UNIX epoch. 10 | tls: 11 | type: number 12 | format: double 13 | description: TLS handshake time, in milliseconds elapsed since UNIX epoch. 14 | timeToFirstByte: 15 | type: number 16 | format: double 17 | description: Time to first byte, in milliseconds elapsed since UNIX epoch. 18 | download: 19 | type: number 20 | format: double 21 | description: Download time, in milliseconds elapsed since UNIX epoch. 22 | responseSize: 23 | type: integer 24 | format: int64 25 | description: Response size 26 | -------------------------------------------------------------------------------- /openapi/delivery/components/Trace.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Trace: 3 | type: object 4 | required: 5 | - authorizationToken 6 | description: | 7 | Enables the trace for delivery API. 8 | At present it is not be possible to set the metrics and packages for the trace. 9 | properties: 10 | authorizationToken: 11 | type: string 12 | usage: 13 | type: object 14 | additionalProperties: 15 | type: string 16 | description: | 17 | A String dictionary of client SDK usage tracking and internal diagnostics metadata. 18 | -------------------------------------------------------------------------------- /openapi/delivery/components/TraceResponse.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | TraceResponse: 3 | type: object 4 | description: | 5 | The object containing all trace data for the request, only present if the trace token was provided in the request. 6 | additionalProperties: 7 | type: object 8 | properties: 9 | traceKey: 10 | type: string 11 | traceValue: 12 | type: object 13 | -------------------------------------------------------------------------------- /openapi/delivery/components/View.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | View: 3 | type: object 4 | description: | 5 | This object will contain all the options for the selectors set for the current view, from the active activities, 6 | in case the context and targeting conditions from the request have been matched. 7 | properties: 8 | name: 9 | type: string 10 | maxLength: 128 11 | description: | 12 | View Name - Unique view name. If the activity has a metric with a view with this name it will be matched, 13 | providing the Key matches as well or is null and view and metric targeting is matched. 14 | key: 15 | type: string 16 | maxLength: 512 17 | description: | 18 | View Key - An optional encoded String identifier used in advanced scenarios, such as View fingerprinting. 19 | Same matching conditions as for View Name. 20 | options: 21 | type: array 22 | description: | 23 | The prefetched content (options) to be displayed for the current view. 24 | items: 25 | $ref: "./Option.yaml#/Option" 26 | metrics: 27 | type: array 28 | description: | 29 | Click track metrics associated with the current view. 30 | items: 31 | $ref: "./Metric.yaml#/Metric" 32 | analytics: 33 | $ref: "./AnalyticsResponse.yaml#/AnalyticsResponse" 34 | state: 35 | type: string 36 | description: View state token that must be sent back with display notification for the view. 37 | trace: 38 | $ref: "./TraceResponse.yaml#/TraceResponse" 39 | -------------------------------------------------------------------------------- /openapi/delivery/components/ViewRequest.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | ViewRequest: 3 | description: View request 4 | allOf: 5 | - $ref: "./RequestDetails.yaml#/RequestDetails" 6 | - type: object 7 | properties: 8 | name: 9 | type: string 10 | maxLength: 128 11 | description: | 12 | View Name - Unique view name. If the activity has a metric with a view with this name it will be matched, 13 | providing the Key matches as well or is null and view and metric targeting is matched. 14 | key: 15 | type: string 16 | maxLength: 512 17 | description: | 18 | View Key - An optional encoded String identifier used in advanced scenarios, such as View fingerprinting. 19 | Same matching conditions as for View Name. 20 | -------------------------------------------------------------------------------- /openapi/delivery/components/Window.yaml: -------------------------------------------------------------------------------- 1 | openapi: "3.0.0" 2 | Window: 3 | type: object 4 | description: The dimensions that dictate a window 5 | properties: 6 | width: 7 | type: number 8 | format: double 9 | description: width 10 | height: 11 | type: number 12 | format: double 13 | description: height 14 | 15 | -------------------------------------------------------------------------------- /openapi/delivery/examples/notificationsForDisplayedContent.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "tntId": "abcdefghijkl00014.1_1" 4 | }, 5 | "context": { 6 | "channel" : "web", 7 | "browser" : { 8 | "host" : "demo" 9 | }, 10 | "address" : { 11 | "url" : "http://demo.dev.tt-demo.com/demo/store/index.html?ad=a" 12 | }, 13 | "screen" : { 14 | "width" : 1200, 15 | "height": 1400 16 | } 17 | }, 18 | "experienceCloud": { 19 | "audienceManager": { 20 | } 21 | }, 22 | "notifications": [{ 23 | "id" : "notificationId1", 24 | "type": "display", 25 | "timestamp": 1552561951770, 26 | "parameters": { 27 | "ad" : "view" 28 | }, 29 | "tokens" : [ 30 | "1zIHw4w+hPht4NV5MyssK4usK1YQ35VnRXpXdevZO4L+y1IPq9i2NpPJJ/bX9FNd", 31 | "1zIHw4w+hPht4NV5MyssK4usK1YQ35VnRXpXdevZO4L+y1IPq9i2NpPJJ/bX9FNd" 32 | ] 33 | }] 34 | } 35 | -------------------------------------------------------------------------------- /openapi/delivery/examples/responseForPrefetchViewsForMobileChannel.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": 200, 3 | "requestId": "620db62f-fe6c-4d7e-a31f-93dd36da8117", 4 | "client": "demo", 5 | "id": { 6 | "tntId": "abcdefghijkl00014.1_1" 7 | }, 8 | "edgeHost": "mboxedge1.dev.tt.omtrdc.net", 9 | "prefetch": { 10 | "views": [ 11 | { 12 | "id": 1, 13 | "name": "webView1", 14 | "key": "32423dfs3452sdr25r", 15 | "options": [ 16 | { 17 | "content": [ 18 | { 19 | "type": "setHtml", 20 | "selector": "#top-menu", 21 | "content": "AAA" 22 | } 23 | ], 24 | "type": "actions", 25 | "eventToken": "1zIHw4w+hPht4NV5MyssK4usK1YQ35VnRXpXdevZO4L+y1IPq9i2NpPJJ/bX9FNd" 26 | }, 27 | { 28 | "content": [ 29 | { 30 | "type": "setHtml", 31 | "selector": "#sidebar", 32 | "content": "BBB" 33 | } 34 | ], 35 | "type": "actions", 36 | "eventToken": "1zIHw4w+hPht4NV5MyssK4usK1YQ35VnRXpXdevZO4L+y1IPq9i2NpPJJ/bX9FNd" 37 | } 38 | ] 39 | }, 40 | { 41 | "id": 2, 42 | "name": "webView2", 43 | "key": "11423dfs3452sdr233", 44 | "metrics": [ 45 | { 46 | "type": "click", 47 | "selector": "#campaignWithViewsViewIdInSelector", 48 | "eventToken": "cugVCufT8raDG+O9QFSX3w==" 49 | } 50 | ] 51 | } 52 | ], 53 | "metrics": [ 54 | { 55 | "type": "click", 56 | "selector": "#campaignWithViewsNoViewIdInSelector", 57 | "eventToken": "cugVCufT8raDG+O9QFSX3w==" 58 | } 59 | ] 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /openapi/delivery/examples/responseForPrefetchViewsForWebChannel.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": 200, 3 | "requestId": "5efee0d8-3779-4b12-a74e-e04848faf191", 4 | "client": "demo", 5 | "id": { 6 | "tntId": "abcdefghijkl00023.1_1" 7 | }, 8 | "edgeHost": "mboxedge28.tt.omtrdc.net", 9 | "prefetch": { 10 | "mboxes": [ 11 | { 12 | "index": 1, 13 | "name": "SummerOffer", 14 | "options": [ 15 | { 16 | "content": "

Enjoy this 15% discount on your next purchase

", 17 | "type": "html", 18 | "eventToken": "GcvBXDhdJFNR9E9r1tgjfmqipf", 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'target-java-sdk' 2 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** The address object. It indicates the current URL and the referring URL. */ 20 | public class Address { 21 | @JsonProperty("url") 22 | private String url; 23 | 24 | @JsonProperty("referringUrl") 25 | private String referringUrl; 26 | 27 | public Address url(String url) { 28 | this.url = url; 29 | return this; 30 | } 31 | 32 | /** 33 | * URL 34 | * 35 | * @return url 36 | */ 37 | public String getUrl() { 38 | return url; 39 | } 40 | 41 | public void setUrl(String url) { 42 | this.url = url; 43 | } 44 | 45 | public Address referringUrl(String referringUrl) { 46 | this.referringUrl = referringUrl; 47 | return this; 48 | } 49 | 50 | /** 51 | * referral URL 52 | * 53 | * @return referringUrl 54 | */ 55 | public String getReferringUrl() { 56 | return referringUrl; 57 | } 58 | 59 | public void setReferringUrl(String referringUrl) { 60 | this.referringUrl = referringUrl; 61 | } 62 | 63 | @Override 64 | public boolean equals(Object o) { 65 | if (this == o) { 66 | return true; 67 | } 68 | if (o == null || getClass() != o.getClass()) { 69 | return false; 70 | } 71 | Address address = (Address) o; 72 | return Objects.equals(this.url, address.url) 73 | && Objects.equals(this.referringUrl, address.referringUrl); 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return Objects.hash(url, referringUrl); 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | StringBuilder sb = new StringBuilder(); 84 | sb.append("class Address {\n"); 85 | sb.append(" url: ").append(toIndentedString(url)).append("\n"); 86 | sb.append(" referringUrl: ").append(toIndentedString(referringUrl)).append("\n"); 87 | sb.append("}"); 88 | return sb.toString(); 89 | } 90 | 91 | /** 92 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 93 | */ 94 | private String toIndentedString(Object o) { 95 | if (o == null) { 96 | return "null"; 97 | } 98 | return o.toString().replace("\n", "\n "); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/AnalyticsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** Contains the analytics payload metadata */ 20 | public class AnalyticsResponse { 21 | @JsonProperty("payload") 22 | private AnalyticsPayload payload; 23 | 24 | public AnalyticsResponse payload(AnalyticsPayload payload) { 25 | this.payload = payload; 26 | return this; 27 | } 28 | 29 | /** 30 | * Get payload 31 | * 32 | * @return payload 33 | */ 34 | public AnalyticsPayload getPayload() { 35 | return payload; 36 | } 37 | 38 | public void setPayload(AnalyticsPayload payload) { 39 | this.payload = payload; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object o) { 44 | if (this == o) { 45 | return true; 46 | } 47 | if (o == null || getClass() != o.getClass()) { 48 | return false; 49 | } 50 | AnalyticsResponse analyticsResponse = (AnalyticsResponse) o; 51 | return Objects.equals(this.payload, analyticsResponse.payload); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(payload); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | StringBuilder sb = new StringBuilder(); 62 | sb.append("class AnalyticsResponse {\n"); 63 | sb.append(" payload: ").append(toIndentedString(payload)).append("\n"); 64 | sb.append("}"); 65 | return sb.toString(); 66 | } 67 | 68 | /** 69 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 70 | */ 71 | private String toIndentedString(Object o) { 72 | if (o == null) { 73 | return "null"; 74 | } 75 | return o.toString().replace("\n", "\n "); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/AuthenticatedState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Gets or Sets AuthenticatedState */ 20 | public enum AuthenticatedState { 21 | UNKNOWN("unknown"), 22 | 23 | AUTHENTICATED("authenticated"), 24 | 25 | LOGGED_OUT("logged_out"); 26 | 27 | private String value; 28 | 29 | AuthenticatedState(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return String.valueOf(value); 41 | } 42 | 43 | @JsonCreator 44 | public static AuthenticatedState fromValue(String value) { 45 | for (AuthenticatedState b : AuthenticatedState.values()) { 46 | if (b.value.equals(value)) { 47 | return b; 48 | } 49 | } 50 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/ChannelType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** 20 | * Specifies the channel for the request. Only activities with the matching channel will be 21 | * evaluated. 22 | */ 23 | public enum ChannelType { 24 | MOBILE("mobile"), 25 | 26 | WEB("web"); 27 | 28 | private String value; 29 | 30 | ChannelType(String value) { 31 | this.value = value; 32 | } 33 | 34 | @JsonValue 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return String.valueOf(value); 42 | } 43 | 44 | @JsonCreator 45 | public static ChannelType fromValue(String value) { 46 | for (ChannelType b : ChannelType.values()) { 47 | if (b.value.equals(value)) { 48 | return b; 49 | } 50 | } 51 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/DecisioningMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Gets or Sets DecisioningMethod */ 20 | public enum DecisioningMethod { 21 | SERVER_SIDE("server-side"), 22 | 23 | ON_DEVICE("on-device"), 24 | 25 | HYBRID("hybrid"); 26 | 27 | private String value; 28 | 29 | DecisioningMethod(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return String.valueOf(value); 41 | } 42 | 43 | @JsonCreator 44 | public static DecisioningMethod fromValue(String value) { 45 | for (DecisioningMethod b : DecisioningMethod.values()) { 46 | if (b.value.equals(value)) { 47 | return b; 48 | } 49 | } 50 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/DeviceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** 20 | * Field is mandatory when Mobile Platform is specified. Only activities that match the specified 21 | * deviceType or have the device type set to 'null' will be evaluated. Ex if device type is 22 | * 'phone' in the delivery request, then only activities that have the device type equal to 23 | * 'phone' or set to 'null' will be evaluated. An activity with 'null' 24 | * device type will be evaluated for requests for both, 'phone' and 'tablet'. 25 | */ 26 | public enum DeviceType { 27 | PHONE("phone"), 28 | 29 | TABLET("tablet"); 30 | 31 | private String value; 32 | 33 | DeviceType(String value) { 34 | this.value = value; 35 | } 36 | 37 | @JsonValue 38 | public String getValue() { 39 | return value; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return String.valueOf(value); 45 | } 46 | 47 | @JsonCreator 48 | public static DeviceType fromValue(String value) { 49 | for (DeviceType b : DeviceType.values()) { 50 | if (b.value.equals(value)) { 51 | return b; 52 | } 53 | } 54 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/ExecutionMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Gets or Sets ExecutionMode */ 20 | public enum ExecutionMode { 21 | EDGE("edge"), 22 | 23 | LOCAL("local"); 24 | 25 | private String value; 26 | 27 | ExecutionMode(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return String.valueOf(value); 39 | } 40 | 41 | @JsonCreator 42 | public static ExecutionMode fromValue(String value) { 43 | for (ExecutionMode b : ExecutionMode.values()) { 44 | if (b.value.equals(value)) { 45 | return b; 46 | } 47 | } 48 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/LoggingType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** 20 | * Indicates whether integraion will be done via client side (from the client) or server side (edge 21 | * servers) 22 | */ 23 | public enum LoggingType { 24 | SERVER_SIDE("server_side"), 25 | 26 | CLIENT_SIDE("client_side"); 27 | 28 | private String value; 29 | 30 | LoggingType(String value) { 31 | this.value = value; 32 | } 33 | 34 | @JsonValue 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return String.valueOf(value); 42 | } 43 | 44 | @JsonCreator 45 | public static LoggingType fromValue(String value) { 46 | for (LoggingType b : LoggingType.values()) { 47 | if (b.value.equals(value)) { 48 | return b; 49 | } 50 | } 51 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/MetricType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Notification type. Currently only click and display are supported. */ 20 | public enum MetricType { 21 | CLICK("click"), 22 | 23 | DISPLAY("display"); 24 | 25 | private String value; 26 | 27 | MetricType(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return String.valueOf(value); 39 | } 40 | 41 | @JsonCreator 42 | public static MetricType fromValue(String value) { 43 | for (MetricType b : MetricType.values()) { 44 | if (b.value.equals(value)) { 45 | return b; 46 | } 47 | } 48 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/MobilePlatformType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Only activities with the specified mobile platform type will be evaluated. */ 20 | public enum MobilePlatformType { 21 | ANDROID("android"), 22 | 23 | IOS("ios"); 24 | 25 | private String value; 26 | 27 | MobilePlatformType(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return String.valueOf(value); 39 | } 40 | 41 | @JsonCreator 42 | public static MobilePlatformType fromValue(String value) { 43 | for (MobilePlatformType b : MobilePlatformType.values()) { 44 | if (b.value.equals(value)) { 45 | return b; 46 | } 47 | } 48 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/NotificationPageLoad.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** Include this object to send display notifications for the prefetch page load contnet. */ 20 | public class NotificationPageLoad { 21 | @JsonProperty("state") 22 | private String state; 23 | 24 | public NotificationPageLoad state(String state) { 25 | this.state = state; 26 | return this; 27 | } 28 | 29 | /** 30 | * Page Load state token 31 | * 32 | * @return state 33 | */ 34 | public String getState() { 35 | return state; 36 | } 37 | 38 | public void setState(String state) { 39 | this.state = state; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object o) { 44 | if (this == o) { 45 | return true; 46 | } 47 | if (o == null || getClass() != o.getClass()) { 48 | return false; 49 | } 50 | NotificationPageLoad notificationPageLoad = (NotificationPageLoad) o; 51 | return Objects.equals(this.state, notificationPageLoad.state); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(state); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | StringBuilder sb = new StringBuilder(); 62 | sb.append("class NotificationPageLoad {\n"); 63 | sb.append(" state: ").append(toIndentedString(state)).append("\n"); 64 | sb.append("}"); 65 | return sb.toString(); 66 | } 67 | 68 | /** 69 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 70 | */ 71 | private String toIndentedString(Object o) { 72 | if (o == null) { 73 | return "null"; 74 | } 75 | return o.toString().replace("\n", "\n "); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/OptionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** Gets or Sets OptionType */ 20 | public enum OptionType { 21 | HTML("html"), 22 | 23 | JSON("json"), 24 | 25 | REDIRECT("redirect"), 26 | 27 | DYNAMIC("dynamic"), 28 | 29 | ACTIONS("actions"); 30 | 31 | private String value; 32 | 33 | OptionType(String value) { 34 | this.value = value; 35 | } 36 | 37 | @JsonValue 38 | public String getValue() { 39 | return value; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return String.valueOf(value); 45 | } 46 | 47 | @JsonCreator 48 | public static OptionType fromValue(String value) { 49 | for (OptionType b : OptionType.values()) { 50 | if (b.value.equals(value)) { 51 | return b; 52 | } 53 | } 54 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/PrefetchMboxResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** PrefetchMboxResponse */ 20 | public class PrefetchMboxResponse extends MboxResponse { 21 | @JsonProperty("state") 22 | private String state; 23 | 24 | public PrefetchMboxResponse state(String state) { 25 | this.state = state; 26 | return this; 27 | } 28 | 29 | /** 30 | * Mbox state token that must be sent back with display notification for the mbox. 31 | * 32 | * @return state 33 | */ 34 | public String getState() { 35 | return state; 36 | } 37 | 38 | public void setState(String state) { 39 | this.state = state; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object o) { 44 | if (this == o) { 45 | return true; 46 | } 47 | if (o == null || getClass() != o.getClass()) { 48 | return false; 49 | } 50 | PrefetchMboxResponse prefetchMboxResponse = (PrefetchMboxResponse) o; 51 | return Objects.equals(this.state, prefetchMboxResponse.state) && super.equals(o); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(state, super.hashCode()); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | StringBuilder sb = new StringBuilder(); 62 | sb.append("class PrefetchMboxResponse {\n"); 63 | sb.append(" ").append(toIndentedString(super.toString())).append("\n"); 64 | sb.append(" state: ").append(toIndentedString(state)).append("\n"); 65 | sb.append("}"); 66 | return sb.toString(); 67 | } 68 | 69 | /** 70 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 71 | */ 72 | private String toIndentedString(Object o) { 73 | if (o == null) { 74 | return "null"; 75 | } 76 | return o.toString().replace("\n", "\n "); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/PrefetchMboxResponseAllOf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** PrefetchMboxResponseAllOf */ 20 | public class PrefetchMboxResponseAllOf { 21 | @JsonProperty("state") 22 | private String state; 23 | 24 | public PrefetchMboxResponseAllOf state(String state) { 25 | this.state = state; 26 | return this; 27 | } 28 | 29 | /** 30 | * Mbox state token that must be sent back with display notification for the mbox. 31 | * 32 | * @return state 33 | */ 34 | public String getState() { 35 | return state; 36 | } 37 | 38 | public void setState(String state) { 39 | this.state = state; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object o) { 44 | if (this == o) { 45 | return true; 46 | } 47 | if (o == null || getClass() != o.getClass()) { 48 | return false; 49 | } 50 | PrefetchMboxResponseAllOf prefetchMboxResponseAllOf = (PrefetchMboxResponseAllOf) o; 51 | return Objects.equals(this.state, prefetchMboxResponseAllOf.state); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(state); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | StringBuilder sb = new StringBuilder(); 62 | sb.append("class PrefetchMboxResponseAllOf {\n"); 63 | sb.append(" state: ").append(toIndentedString(state)).append("\n"); 64 | sb.append("}"); 65 | return sb.toString(); 66 | } 67 | 68 | /** 69 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 70 | */ 71 | private String toIndentedString(Object o) { 72 | if (o == null) { 73 | return "null"; 74 | } 75 | return o.toString().replace("\n", "\n "); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Preview.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** 20 | * Use this object to enable the Preview mode in the request. Use the Preview mode to test the look 21 | * and feel of your site for various location and offer combinations. 22 | */ 23 | public class Preview { 24 | @JsonProperty("token") 25 | private String token; 26 | 27 | public Preview token(String token) { 28 | this.token = token; 29 | return this; 30 | } 31 | 32 | /** 33 | * The token for the Preview mode. Validation * Verify that the token belongs to the client 34 | * provided in request. 35 | * 36 | * @return token 37 | */ 38 | public String getToken() { 39 | return token; 40 | } 41 | 42 | public void setToken(String token) { 43 | this.token = token; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if (this == o) { 49 | return true; 50 | } 51 | if (o == null || getClass() != o.getClass()) { 52 | return false; 53 | } 54 | Preview preview = (Preview) o; 55 | return Objects.equals(this.token, preview.token); 56 | } 57 | 58 | @Override 59 | public int hashCode() { 60 | return Objects.hash(token); 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | StringBuilder sb = new StringBuilder(); 66 | sb.append("class Preview {\n"); 67 | sb.append(" token: ").append(toIndentedString(token)).append("\n"); 68 | sb.append("}"); 69 | return sb.toString(); 70 | } 71 | 72 | /** 73 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 74 | */ 75 | private String toIndentedString(Object o) { 76 | if (o == null) { 77 | return "null"; 78 | } 79 | return o.toString().replace("\n", "\n "); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Product.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** The properties of the products */ 20 | public class Product { 21 | @JsonProperty("id") 22 | private String id; 23 | 24 | @JsonProperty("categoryId") 25 | private String categoryId; 26 | 27 | public Product id(String id) { 28 | this.id = id; 29 | return this; 30 | } 31 | 32 | /** 33 | * Product id. Should not be blank. 34 | * 35 | * @return id 36 | */ 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | public void setId(String id) { 42 | this.id = id; 43 | } 44 | 45 | public Product categoryId(String categoryId) { 46 | this.categoryId = categoryId; 47 | return this; 48 | } 49 | 50 | /** 51 | * Category id. Should not be blank. 52 | * 53 | * @return categoryId 54 | */ 55 | public String getCategoryId() { 56 | return categoryId; 57 | } 58 | 59 | public void setCategoryId(String categoryId) { 60 | this.categoryId = categoryId; 61 | } 62 | 63 | @Override 64 | public boolean equals(Object o) { 65 | if (this == o) { 66 | return true; 67 | } 68 | if (o == null || getClass() != o.getClass()) { 69 | return false; 70 | } 71 | Product product = (Product) o; 72 | return Objects.equals(this.id, product.id) 73 | && Objects.equals(this.categoryId, product.categoryId); 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return Objects.hash(id, categoryId); 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | StringBuilder sb = new StringBuilder(); 84 | sb.append("class Product {\n"); 85 | sb.append(" id: ").append(toIndentedString(id)).append("\n"); 86 | sb.append(" categoryId: ").append(toIndentedString(categoryId)).append("\n"); 87 | sb.append("}"); 88 | return sb.toString(); 89 | } 90 | 91 | /** 92 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 93 | */ 94 | private String toIndentedString(Object o) { 95 | if (o == null) { 96 | return "null"; 97 | } 98 | return o.toString().replace("\n", "\n "); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Property.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** 20 | * Specifies the at_property via the token field. It can be used to control the scope for the 21 | * delivery. 22 | */ 23 | public class Property { 24 | @JsonProperty("token") 25 | private String token; 26 | 27 | public Property token(String token) { 28 | this.token = token; 29 | return this; 30 | } 31 | 32 | /** 33 | * The at_property token Validation * Required if the property is specified. 34 | * 35 | * @return token 36 | */ 37 | public String getToken() { 38 | return token; 39 | } 40 | 41 | public void setToken(String token) { 42 | this.token = token; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object o) { 47 | if (this == o) { 48 | return true; 49 | } 50 | if (o == null || getClass() != o.getClass()) { 51 | return false; 52 | } 53 | Property property = (Property) o; 54 | return Objects.equals(this.token, property.token); 55 | } 56 | 57 | @Override 58 | public int hashCode() { 59 | return Objects.hash(token); 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | StringBuilder sb = new StringBuilder(); 65 | sb.append("class Property {\n"); 66 | sb.append(" token: ").append(toIndentedString(token)).append("\n"); 67 | sb.append("}"); 68 | return sb.toString(); 69 | } 70 | 71 | /** 72 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 73 | */ 74 | private String toIndentedString(Object o) { 75 | if (o == null) { 76 | return "null"; 77 | } 78 | return o.toString().replace("\n", "\n "); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/ScreenOrientationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonValue; 18 | 19 | /** 20 | * If not specified, all activities with any screen orientation will be evaluated. If specified, 21 | * only the activities with the matching screen orientation will evaluated. 22 | */ 23 | public enum ScreenOrientationType { 24 | PORTRAIT("portrait"), 25 | 26 | LANDSCAPE("landscape"); 27 | 28 | private String value; 29 | 30 | ScreenOrientationType(String value) { 31 | this.value = value; 32 | } 33 | 34 | @JsonValue 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return String.valueOf(value); 42 | } 43 | 44 | @JsonCreator 45 | public static ScreenOrientationType fromValue(String value) { 46 | for (ScreenOrientationType b : ScreenOrientationType.values()) { 47 | if (b.value.equals(value)) { 48 | return b; 49 | } 50 | } 51 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Telemetry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | import java.util.Objects; 20 | 21 | /** Telemetry */ 22 | public class Telemetry { 23 | @JsonProperty("entries") 24 | private List entries = new ArrayList<>(); 25 | 26 | public Telemetry entries(List entries) { 27 | this.entries = entries; 28 | return this; 29 | } 30 | 31 | public Telemetry addEntriesItem(TelemetryEntry entriesItem) { 32 | if (this.entries == null) { 33 | this.entries = new ArrayList<>(); 34 | } 35 | this.entries.add(entriesItem); 36 | return this; 37 | } 38 | 39 | /** 40 | * An array of Telemetry Entries. 41 | * 42 | * @return entries 43 | */ 44 | public List getEntries() { 45 | return entries; 46 | } 47 | 48 | public void setEntries(List entries) { 49 | this.entries = entries; 50 | } 51 | 52 | @Override 53 | public boolean equals(Object o) { 54 | if (this == o) { 55 | return true; 56 | } 57 | if (o == null || getClass() != o.getClass()) { 58 | return false; 59 | } 60 | Telemetry telemetry = (Telemetry) o; 61 | return Objects.equals(this.entries, telemetry.entries); 62 | } 63 | 64 | @Override 65 | public int hashCode() { 66 | return Objects.hash(entries); 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | StringBuilder sb = new StringBuilder(); 72 | sb.append("class Telemetry {\n"); 73 | sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); 74 | sb.append("}"); 75 | return sb.toString(); 76 | } 77 | 78 | /** 79 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 80 | */ 81 | private String toIndentedString(Object o) { 82 | if (o == null) { 83 | return "null"; 84 | } 85 | return o.toString().replace("\n", "\n "); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/delivery/v1/model/Window.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | * NOTE: This is an auto generated file. Do not edit directly. 13 | */ 14 | package com.adobe.target.delivery.v1.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | import java.util.Objects; 18 | 19 | /** The dimensions that dictate a window */ 20 | public class Window { 21 | @JsonProperty("width") 22 | private Double width; 23 | 24 | @JsonProperty("height") 25 | private Double height; 26 | 27 | public Window width(Double width) { 28 | this.width = width; 29 | return this; 30 | } 31 | 32 | /** 33 | * width 34 | * 35 | * @return width 36 | */ 37 | public Double getWidth() { 38 | return width; 39 | } 40 | 41 | public void setWidth(Double width) { 42 | this.width = width; 43 | } 44 | 45 | public Window height(Double height) { 46 | this.height = height; 47 | return this; 48 | } 49 | 50 | /** 51 | * height 52 | * 53 | * @return height 54 | */ 55 | public Double getHeight() { 56 | return height; 57 | } 58 | 59 | public void setHeight(Double height) { 60 | this.height = height; 61 | } 62 | 63 | @Override 64 | public boolean equals(Object o) { 65 | if (this == o) { 66 | return true; 67 | } 68 | if (o == null || getClass() != o.getClass()) { 69 | return false; 70 | } 71 | Window window = (Window) o; 72 | return Objects.equals(this.width, window.width) && Objects.equals(this.height, window.height); 73 | } 74 | 75 | @Override 76 | public int hashCode() { 77 | return Objects.hash(width, height); 78 | } 79 | 80 | @Override 81 | public String toString() { 82 | StringBuilder sb = new StringBuilder(); 83 | sb.append("class Window {\n"); 84 | sb.append(" width: ").append(toIndentedString(width)).append("\n"); 85 | sb.append(" height: ").append(toIndentedString(height)).append("\n"); 86 | sb.append("}"); 87 | return sb.toString(); 88 | } 89 | 90 | /** 91 | * Convert the given object to string with each line indented by 4 spaces (except the first line). 92 | */ 93 | private String toIndentedString(Object o) { 94 | if (o == null) { 95 | return "null"; 96 | } 97 | return o.toString().replace("\n", "\n "); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/Attributes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client; 13 | 14 | import com.adobe.target.edge.client.model.TargetDeliveryResponse; 15 | import java.util.Map; 16 | 17 | public interface Attributes { 18 | 19 | Map> toMap(); 20 | 21 | Map toMboxMap(String mbox); 22 | 23 | Boolean getBoolean(String mbox, String key, Boolean defaultValue); 24 | 25 | String getString(String mbox, String key); 26 | 27 | Integer getInteger(String mbox, String key, Integer defaultValue); 28 | 29 | Double getDouble(String mbox, String key, Double defaultValue); 30 | 31 | /** Allows access to resulting response to retrieve cookies. */ 32 | TargetDeliveryResponse getResponse(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ClientProxyConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client; 13 | 14 | public class ClientProxyConfig { 15 | private String host; 16 | private int port; 17 | private String username; 18 | private String password; 19 | private boolean authProxy = false; 20 | 21 | public ClientProxyConfig(String host, int port) { 22 | this.host = host; 23 | this.port = port; 24 | } 25 | 26 | public ClientProxyConfig(String host, int port, String username, String password) { 27 | this.host = host; 28 | this.port = port; 29 | this.username = username; 30 | this.password = password; 31 | authProxy = true; 32 | } 33 | 34 | public String getHost() { 35 | return host; 36 | } 37 | 38 | public int getPort() { 39 | return port; 40 | } 41 | 42 | public String getUsername() { 43 | return username; 44 | } 45 | 46 | public String getPassword() { 47 | return password; 48 | } 49 | 50 | public boolean isAuthProxy() { 51 | return authProxy; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/TargetClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client; 13 | 14 | import com.adobe.target.edge.client.http.ResponseStatus; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import com.adobe.target.edge.client.model.TargetDeliveryResponse; 17 | import java.util.concurrent.CompletableFuture; 18 | 19 | public interface TargetClient extends AutoCloseable { 20 | 21 | TargetDeliveryResponse getOffers(TargetDeliveryRequest request); 22 | 23 | CompletableFuture getOffersAsync(TargetDeliveryRequest request); 24 | 25 | ResponseStatus sendNotifications(TargetDeliveryRequest request); 26 | 27 | CompletableFuture sendNotificationsAsync(TargetDeliveryRequest request); 28 | 29 | /** 30 | * Makes a getOffers() call and converts all returned JSON offers into Attributes. 31 | * 32 | * @param targetRequest optional TargetDeliveryRequest that can be used to set specific request 33 | * items such as Visitor, Context, etc. If null, one will be generated. Request for given mbox 34 | * will be added automatically. 35 | * @param mboxes Name of mboxes to use to retrieve attributes. 36 | * @return Attributes object 37 | */ 38 | Attributes getAttributes(TargetDeliveryRequest targetRequest, String... mboxes); 39 | 40 | /** 41 | * Makes an async getOffers() call and converts all returned JSON offers into Attributes. 42 | * 43 | * @param targetRequest optional TargetDeliveryRequest that can be used to set specific request 44 | * items such as Visitor, Context, etc. If null, one will be generated. Request for given mbox 45 | * will be added automatically. 46 | * @param mboxes Name of mboxes to use to retrieve attributes. 47 | * @return CompletableFuture<Attributes> object 48 | */ 49 | CompletableFuture getAttributesAsync( 50 | TargetDeliveryRequest targetRequest, String... mboxes); 51 | 52 | static TargetClient create(ClientConfig config) { 53 | return new DefaultTargetClient(config); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/exception/TargetClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.exception; 13 | 14 | public class TargetClientException extends RuntimeException { 15 | 16 | public TargetClientException(String message) { 17 | super(message); 18 | } 19 | 20 | public TargetClientException(String message, Throwable cause) { 21 | super(message, cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/exception/TargetExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.exception; 13 | 14 | public interface TargetExceptionHandler { 15 | 16 | void handleException(TargetClientException e); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/exception/TargetRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.exception; 13 | 14 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 15 | import com.adobe.target.edge.client.utils.LogUtils; 16 | 17 | public class TargetRequestException extends RuntimeException { 18 | private TargetDeliveryRequest request; 19 | 20 | public TargetRequestException( 21 | String message, Throwable cause, TargetDeliveryRequest deliveryRequest) { 22 | super(message, cause); 23 | 24 | request = deliveryRequest; 25 | } 26 | 27 | public TargetRequestException(String message) { 28 | super(message); 29 | } 30 | 31 | public TargetDeliveryRequest getRequest() { 32 | return request; 33 | } 34 | 35 | public void setRequest(TargetDeliveryRequest deliveryRequest) { 36 | request = deliveryRequest; 37 | } 38 | 39 | @Override 40 | public String getMessage() { 41 | if (request == null) { 42 | return super.getMessage(); 43 | } 44 | 45 | return super.getMessage() + " " + LogUtils.getRequestDetails(request); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/DebuggingInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import org.apache.http.HttpRequest; 15 | import org.apache.http.HttpRequestInterceptor; 16 | import org.apache.http.protocol.HttpContext; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | public class DebuggingInterceptor implements HttpRequestInterceptor { 21 | 22 | private static final Logger logger = LoggerFactory.getLogger(TargetMetrics.class); 23 | 24 | @Override 25 | public void process(HttpRequest request, HttpContext context) { 26 | logger.info(request.getRequestLine().getUri()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/DefaultTargetMetricContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | public class DefaultTargetMetricContext implements TargetMetricContext { 15 | 16 | private final String url; 17 | private final String message; 18 | private final int status; 19 | private final int executionTime; 20 | 21 | public DefaultTargetMetricContext(String url, int status, String message, int executionTime) { 22 | this.url = url; 23 | this.status = status; 24 | this.message = message; 25 | this.executionTime = executionTime; 26 | } 27 | 28 | @Override 29 | public String getUrl() { 30 | return url; 31 | } 32 | 33 | @Override 34 | public int getStatus() { 35 | return status; 36 | } 37 | 38 | @Override 39 | public String getStatusMessage() { 40 | return message; 41 | } 42 | 43 | @Override 44 | public int getExecutionTime() { 45 | return executionTime; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/JacksonObjectMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import com.fasterxml.jackson.annotation.JsonInclude; 15 | import com.fasterxml.jackson.core.JsonGenerator; 16 | import com.fasterxml.jackson.core.JsonProcessingException; 17 | import com.fasterxml.jackson.databind.DeserializationFeature; 18 | import com.fasterxml.jackson.databind.ObjectMapper; 19 | import java.io.IOException; 20 | import kong.unirest.GenericType; 21 | import kong.unirest.UnirestException; 22 | 23 | public class JacksonObjectMapper implements kong.unirest.ObjectMapper { 24 | 25 | private final ObjectMapper objectMapper; 26 | 27 | public JacksonObjectMapper() { 28 | this.objectMapper = new ObjectMapper(); 29 | this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); 30 | this.objectMapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true); 31 | this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 32 | this.objectMapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true); 33 | } 34 | 35 | @Override 36 | public T readValue(String value, Class valueType) { 37 | try { 38 | return objectMapper.readValue(value, valueType); 39 | } catch (IOException e) { 40 | throw new UnirestException(e); 41 | } 42 | } 43 | 44 | @Override 45 | public T readValue(String value, GenericType genericType) { 46 | try { 47 | return objectMapper.readValue(value, objectMapper.constructType(genericType.getType())); 48 | } catch (IOException e) { 49 | throw new UnirestException(e); 50 | } 51 | } 52 | 53 | @Override 54 | public String writeValue(Object value) { 55 | try { 56 | return objectMapper.writeValueAsString(value); 57 | } catch (JsonProcessingException e) { 58 | throw new UnirestException(e); 59 | } 60 | } 61 | 62 | public ObjectMapper getMapper() { 63 | return this.objectMapper; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/LoggingMetricConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import java.util.function.Consumer; 15 | import org.apache.http.HttpStatus; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | 19 | public class LoggingMetricConsumer implements Consumer { 20 | private static final Logger logger = LoggerFactory.getLogger(TargetMetrics.class); 21 | 22 | @Override 23 | public void accept(TargetMetricContext targetMetricContext) { 24 | 25 | if (targetMetricContext.getStatus() == HttpStatus.SC_OK) { 26 | logger.debug( 27 | "Target Request Status: {} Time: {}ms Url: {} ", 28 | targetMetricContext.getUrl(), 29 | targetMetricContext.getStatus(), 30 | targetMetricContext.getExecutionTime()); 31 | return; 32 | } 33 | 34 | logger.error( 35 | "Target Request Status: Status: {} Message: {} Time: {}ms Url: {} ", 36 | targetMetricContext.getUrl(), 37 | targetMetricContext.getStatus(), 38 | targetMetricContext.getStatusMessage(), 39 | targetMetricContext.getExecutionTime()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/ResponseStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import java.util.List; 15 | 16 | public class ResponseStatus { 17 | private final int status; 18 | private final String message; 19 | private String globalMbox; 20 | private List remoteMboxes; 21 | private List remoteViews; 22 | 23 | public ResponseStatus(int status, String message) { 24 | this.status = status; 25 | this.message = message; 26 | } 27 | 28 | public int getStatus() { 29 | return status; 30 | } 31 | 32 | public String getMessage() { 33 | return message; 34 | } 35 | 36 | public String getGlobalMbox() { 37 | return globalMbox; 38 | } 39 | 40 | public void setGlobalMbox(String globalMbox) { 41 | this.globalMbox = globalMbox; 42 | } 43 | 44 | public List getRemoteMboxes() { 45 | return remoteMboxes; 46 | } 47 | 48 | public void setRemoteMboxes(List mboxes) { 49 | remoteMboxes = mboxes; 50 | } 51 | 52 | public List getRemoteViews() { 53 | return remoteViews; 54 | } 55 | 56 | public void setRemoteViews(List views) { 57 | remoteViews = views; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "ResponseStatus{" 63 | + "status=" 64 | + status 65 | + ", message='" 66 | + message 67 | + '\'' 68 | + ", globalMbox='" 69 | + globalMbox 70 | + '\'' 71 | + ", remoteMboxes=" 72 | + remoteMboxes 73 | + ", remoteViews=" 74 | + remoteViews 75 | + '}'; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/ResponseWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import kong.unirest.HttpResponse; 15 | 16 | public final class ResponseWrapper { 17 | 18 | private double parsingTime; 19 | 20 | private long responseSize; 21 | 22 | private HttpResponse httpResponse; 23 | 24 | public ResponseWrapper() {} 25 | 26 | public double getParsingTime() { 27 | return parsingTime; 28 | } 29 | 30 | public void setParsingTime(double parsingTime) { 31 | this.parsingTime = parsingTime; 32 | } 33 | 34 | public long getResponseSize() { 35 | return responseSize; 36 | } 37 | 38 | public void setResponseSize(long responseSize) { 39 | this.responseSize = responseSize; 40 | } 41 | 42 | public HttpResponse getHttpResponse() { 43 | return httpResponse; 44 | } 45 | 46 | public void setHttpResponse(HttpResponse httpResponse) { 47 | this.httpResponse = httpResponse; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/TargetAsyncIdleConnectionMonitorThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import java.util.concurrent.TimeUnit; 15 | 16 | import com.adobe.target.edge.client.ClientConfig; 17 | import kong.unirest.apache.AsyncIdleConnectionMonitorThread; 18 | import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager; 19 | 20 | public class TargetAsyncIdleConnectionMonitorThread extends AsyncIdleConnectionMonitorThread { 21 | 22 | public static final long CONNECTION_CHECK_INTERVAL_MS = 1000; 23 | private final PoolingNHttpClientConnectionManager connectionManager; 24 | private final long evictIdleConnectionsAfterSecs; 25 | 26 | public TargetAsyncIdleConnectionMonitorThread(PoolingNHttpClientConnectionManager connMgr, ClientConfig clientConfig) { 27 | super(connMgr); 28 | super.setDaemon(true); 29 | this.connectionManager = connMgr; 30 | this.evictIdleConnectionsAfterSecs = clientConfig.getEvictIdleConnectionsAfterSecs(); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | try { 36 | while (!Thread.currentThread().isInterrupted()) { 37 | synchronized (this) { 38 | wait(CONNECTION_CHECK_INTERVAL_MS); 39 | connectionManager.closeExpiredConnections(); 40 | connectionManager.closeIdleConnections(evictIdleConnectionsAfterSecs, TimeUnit.SECONDS); 41 | } 42 | } 43 | } catch (InterruptedException ex) { 44 | // terminate 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/TargetHttpClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import java.util.Map; 15 | import java.util.concurrent.CompletableFuture; 16 | 17 | public interface TargetHttpClient extends AutoCloseable { 18 | 19 | ResponseWrapper execute( 20 | Map queryParams, String url, T request, Class response); 21 | 22 | CompletableFuture> executeAsync( 23 | Map queryParams, String url, T request, Class response); 24 | 25 | void addDefaultHeader(String key, String value); 26 | 27 | static TargetHttpClient createLoggingHttpClient(TargetHttpClient targetHttpClient) { 28 | return new TargetHttpClientLoggingDecorator(targetHttpClient); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/TargetMetricContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | public interface TargetMetricContext { 15 | 16 | String getUrl(); 17 | 18 | int getStatus(); 19 | 20 | String getStatusMessage(); 21 | 22 | int getExecutionTime(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/http/TargetMetrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import java.util.function.Consumer; 15 | import kong.unirest.HttpRequestSummary; 16 | import kong.unirest.HttpResponseSummary; 17 | import kong.unirest.MetricContext; 18 | import kong.unirest.UniMetric; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | public class TargetMetrics implements UniMetric { 23 | 24 | private static final Logger LOG = LoggerFactory.getLogger(TargetMetrics.class); 25 | 26 | private final Consumer metricContextConsumer; 27 | 28 | public TargetMetrics(Consumer metricContextConsumer) { 29 | this.metricContextConsumer = metricContextConsumer; 30 | } 31 | 32 | @Override 33 | public MetricContext begin(HttpRequestSummary request) { 34 | final long startMillis = System.currentTimeMillis(); 35 | 36 | return (response, exception) -> { 37 | if (exception != null) { 38 | LOG.error("Response processing failed", exception); 39 | return; 40 | } 41 | 42 | this.metricContextConsumer.accept(createMetricContext(request, response, startMillis)); 43 | }; 44 | } 45 | 46 | private static TargetMetricContext createMetricContext( 47 | HttpRequestSummary request, HttpResponseSummary response, long startMillis) { 48 | 49 | return new DefaultTargetMetricContext( 50 | request.getUrl(), 51 | response.getStatus(), 52 | response.getStatusText(), 53 | (int) (System.currentTimeMillis() - startMillis)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/DecisioningMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model; 13 | 14 | import com.fasterxml.jackson.annotation.JsonCreator; 15 | import com.fasterxml.jackson.annotation.JsonValue; 16 | 17 | /** Gets or Sets DecisioningMethod */ 18 | public enum DecisioningMethod { 19 | SERVER_SIDE(com.adobe.target.delivery.v1.model.DecisioningMethod.SERVER_SIDE.toString()), 20 | 21 | ON_DEVICE(com.adobe.target.delivery.v1.model.DecisioningMethod.ON_DEVICE.toString()), 22 | 23 | HYBRID(com.adobe.target.delivery.v1.model.DecisioningMethod.HYBRID.toString()); 24 | 25 | private String value; 26 | 27 | DecisioningMethod(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return String.valueOf(value); 39 | } 40 | 41 | @JsonCreator 42 | public static DecisioningMethod fromValue(String value) { 43 | for (DecisioningMethod b : DecisioningMethod.values()) { 44 | if (b.value.equals(value)) { 45 | return b; 46 | } 47 | } 48 | throw new IllegalArgumentException("Unexpected value '" + value + "'"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ServerState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model; 13 | 14 | import com.adobe.target.delivery.v1.model.DeliveryRequest; 15 | import com.adobe.target.delivery.v1.model.DeliveryResponse; 16 | import com.fasterxml.jackson.annotation.JsonProperty; 17 | 18 | public class ServerState { 19 | 20 | @JsonProperty("request") 21 | private final DeliveryRequest request; 22 | 23 | @JsonProperty("response") 24 | private final DeliveryResponse response; 25 | 26 | public ServerState(DeliveryRequest request, DeliveryResponse response) { 27 | this.request = request; 28 | this.response = response; 29 | } 30 | 31 | public DeliveryRequest getRequest() { 32 | return request; 33 | } 34 | 35 | public DeliveryResponse getResponse() { 36 | return response; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/TargetCookie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model; 13 | 14 | import java.io.Serializable; 15 | import java.util.Objects; 16 | 17 | public class TargetCookie implements Serializable { 18 | private final String name; 19 | private final String value; 20 | private final int maxAge; 21 | 22 | public TargetCookie(String name, String value, int maxAge) { 23 | this.name = name; 24 | this.value = value; 25 | this.maxAge = maxAge; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public int getMaxAge() { 37 | return maxAge; 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (this == o) { 43 | return true; 44 | } 45 | if (o == null || getClass() != o.getClass()) { 46 | return false; 47 | } 48 | TargetCookie that = (TargetCookie) o; 49 | return Objects.equals(name, that.name) && Objects.equals(value, that.value); 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return Objects.hash(name, value); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/TargetDeliveryRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model; 13 | 14 | import com.adobe.experiencecloud.ecid.visitor.Visitor; 15 | import com.adobe.target.delivery.v1.model.DeliveryRequest; 16 | 17 | public class TargetDeliveryRequest { 18 | 19 | private String sessionId; 20 | private String locationHint; 21 | private Visitor visitor; 22 | private DecisioningMethod decisioningMethod; 23 | private DeliveryRequest deliveryRequest = new DeliveryRequest(); 24 | 25 | private TargetDeliveryRequest() {} 26 | 27 | public static TargetDeliveryRequest fromRequest(DeliveryRequest deliveryRequest) { 28 | TargetDeliveryRequest targetDeliveryRequest = new TargetDeliveryRequest(); 29 | targetDeliveryRequest.deliveryRequest = deliveryRequest; 30 | return targetDeliveryRequest; 31 | } 32 | 33 | TargetDeliveryRequest setVisitor(Visitor visitor) { 34 | this.visitor = visitor; 35 | return this; 36 | } 37 | 38 | TargetDeliveryRequest setSessionId(String sessionId) { 39 | this.sessionId = sessionId; 40 | return this; 41 | } 42 | 43 | TargetDeliveryRequest setLocationHint(String locationHint) { 44 | this.locationHint = locationHint; 45 | return this; 46 | } 47 | 48 | TargetDeliveryRequest setDecisioningMethod(DecisioningMethod decisioningMethod) { 49 | this.decisioningMethod = decisioningMethod; 50 | return this; 51 | } 52 | 53 | public String getSessionId() { 54 | return sessionId; 55 | } 56 | 57 | public DeliveryRequest getDeliveryRequest() { 58 | return deliveryRequest; 59 | } 60 | 61 | public Visitor getVisitor() { 62 | return visitor; 63 | } 64 | 65 | public String getLocationHint() { 66 | return locationHint; 67 | } 68 | 69 | public DecisioningMethod getDecisioningMethod() { 70 | return decisioningMethod; 71 | } 72 | 73 | public static TargetDeliveryRequestBuilder builder() { 74 | return new TargetDeliveryRequestBuilder(); 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "TargetDeliveryRequest{" 80 | + "sessionId='" 81 | + sessionId 82 | + '\'' 83 | + ", locationHint='" 84 | + locationHint 85 | + '\'' 86 | + ", visitor=" 87 | + visitor 88 | + ", decisioningMethod=" 89 | + decisioningMethod 90 | + ", deliveryRequest=" 91 | + deliveryRequest 92 | + '}'; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ondevice/OnDeviceDecisioningEvaluation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model.ondevice; 13 | 14 | import java.util.List; 15 | 16 | public class OnDeviceDecisioningEvaluation { 17 | 18 | private boolean allLocal; 19 | private String reason; 20 | private String globalMbox; 21 | private List remoteMBoxes; 22 | private List remoteViews; 23 | 24 | public OnDeviceDecisioningEvaluation( 25 | boolean allLocal, 26 | String reason, 27 | String globalMbox, 28 | List remoteMBoxes, 29 | List remoteViews) { 30 | this.allLocal = allLocal; 31 | this.reason = reason; 32 | this.globalMbox = globalMbox; 33 | this.remoteMBoxes = remoteMBoxes; 34 | this.remoteViews = remoteViews; 35 | } 36 | 37 | public boolean isAllLocal() { 38 | return allLocal; 39 | } 40 | 41 | public String getReason() { 42 | return reason; 43 | } 44 | 45 | public String getGlobalMbox() { 46 | return globalMbox; 47 | } 48 | 49 | public List getRemoteMBoxes() { 50 | return remoteMBoxes; 51 | } 52 | 53 | public List getRemoteViews() { 54 | return remoteViews; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ondevice/OnDeviceDecisioningHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model.ondevice; 13 | 14 | import com.adobe.target.edge.client.exception.TargetClientException; 15 | 16 | public interface OnDeviceDecisioningHandler { 17 | 18 | /** This is called when local execution is ready. It is called only once. */ 19 | void onDeviceDecisioningReady(); 20 | 21 | void artifactDownloadSucceeded(byte[] artifactData); 22 | 23 | void artifactDownloadFailed(TargetClientException e); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ondevice/OnDeviceDecisioningRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model.ondevice; 13 | 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class OnDeviceDecisioningRule { 18 | 19 | private String ruleKey; 20 | private String activityId; 21 | private List propertyTokens; 22 | private Object condition; 23 | private Map consequence; 24 | private Map meta; 25 | 26 | public OnDeviceDecisioningRule() {} 27 | 28 | public String getRuleKey() { 29 | return ruleKey; 30 | } 31 | 32 | public String getActivityId() { 33 | return activityId; 34 | } 35 | 36 | public List getPropertyTokens() { 37 | return propertyTokens; 38 | } 39 | 40 | public Object getCondition() { 41 | return condition; 42 | } 43 | 44 | public Map getConsequence() { 45 | return consequence; 46 | } 47 | 48 | public Map getMeta() { 49 | return meta; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "LocalDecisioningRule{" 55 | + "ruleKey='" 56 | + ruleKey 57 | + '\'' 58 | + ", activityId='" 59 | + activityId 60 | + '\'' 61 | + ", propertyTokens='" 62 | + propertyTokens 63 | + '\'' 64 | + ", condition=" 65 | + condition 66 | + ", consequence=" 67 | + consequence 68 | + ", meta=" 69 | + meta 70 | + '}'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ondevice/OnDeviceDecisioningRuleSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model.ondevice; 13 | 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class OnDeviceDecisioningRuleSet { 18 | 19 | private String version; 20 | private String globalMbox; 21 | private boolean geoTargetingEnabled; 22 | private List remoteMboxes; 23 | private List remoteViews; 24 | private List localMboxes; 25 | private List localViews; 26 | private List responseTokens; 27 | private OnDeviceDecisioningRules rules; 28 | private Map meta; 29 | 30 | public OnDeviceDecisioningRuleSet() {} 31 | 32 | public String getVersion() { 33 | return version; 34 | } 35 | 36 | public String getGlobalMbox() { 37 | return globalMbox; 38 | } 39 | 40 | public boolean isGeoTargetingEnabled() { 41 | return geoTargetingEnabled; 42 | } 43 | 44 | public List getRemoteMboxes() { 45 | return remoteMboxes; 46 | } 47 | 48 | public List getRemoteViews() { 49 | return remoteViews; 50 | } 51 | 52 | public List getResponseTokens() { 53 | return responseTokens; 54 | } 55 | 56 | public List getLocalMboxes() { 57 | return localMboxes; 58 | } 59 | 60 | public List getLocalViews() { 61 | return localViews; 62 | } 63 | 64 | public OnDeviceDecisioningRules getRules() { 65 | return rules; 66 | } 67 | 68 | public Map getMeta() { 69 | return meta; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "LocalDecisioningRuleSet{" 75 | + "version='" 76 | + version 77 | + '\'' 78 | + ", globalMbox='" 79 | + globalMbox 80 | + '\'' 81 | + ", geoTargetingEnabled=" 82 | + geoTargetingEnabled 83 | + ", remoteMboxes=" 84 | + remoteMboxes 85 | + ", remoteViews=" 86 | + remoteViews 87 | + ", localMboxes=" 88 | + localMboxes 89 | + ", localViews=" 90 | + localViews 91 | + ", responseTokens=" 92 | + responseTokens 93 | + ", rules=" 94 | + rules 95 | + ", meta=" 96 | + meta 97 | + '}'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/model/ondevice/OnDeviceDecisioningRules.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.model.ondevice; 13 | 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class OnDeviceDecisioningRules { 18 | private Map> mboxes; 19 | private Map> views; 20 | 21 | public Map> getMboxes() { 22 | return mboxes; 23 | } 24 | 25 | public Map> getViews() { 26 | return views; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "LocalDecisioningRules{" + "mboxes=" + mboxes + ", views=" + views + '}'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/RuleLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice; 13 | 14 | import com.adobe.target.edge.client.ClientConfig; 15 | import com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet; 16 | import com.adobe.target.edge.client.service.TelemetryService; 17 | import java.util.Date; 18 | 19 | public interface RuleLoader { 20 | 21 | void start(ClientConfig clientConfig, TelemetryService telemetryService); 22 | 23 | void stop(); 24 | 25 | void refresh(); 26 | 27 | OnDeviceDecisioningRuleSet getLatestRules(); 28 | 29 | long getPollingInterval(); 30 | 31 | int getNumFetches(); 32 | 33 | Date getLastFetch(); 34 | 35 | String getLocation(); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/client/geo/GeoClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.client.geo; 13 | 14 | import com.adobe.target.delivery.v1.model.Geo; 15 | import com.adobe.target.edge.client.ClientConfig; 16 | 17 | public interface GeoClient extends AutoCloseable { 18 | 19 | void start(ClientConfig clientConfig); 20 | 21 | Geo lookupGeo(String ip); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/collator/CustomParamsCollator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import com.adobe.target.delivery.v1.model.*; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import java.util.*; 17 | 18 | public class CustomParamsCollator implements ParamsCollator { 19 | 20 | protected static final String LOWER_CASE_POSTFIX = "_lc"; 21 | 22 | public Map collateParams( 23 | TargetDeliveryRequest deliveryRequest, RequestDetails requestDetails) { 24 | Map custom = new HashMap<>(); 25 | addAllParameters(custom, requestDetails); 26 | custom = createNestedParametersFromDots(custom); 27 | return custom; 28 | } 29 | 30 | private void addAllParameters(Map custom, RequestDetails details) { 31 | if (details != null) { 32 | Map params = details.getParameters(); 33 | if (params != null) { 34 | custom.putAll(params); 35 | params.forEach((key, value) -> custom.put(key + LOWER_CASE_POSTFIX, value.toLowerCase())); 36 | } 37 | } 38 | } 39 | 40 | private Map createNestedParametersFromDots(Map custom) { 41 | Map result = new HashMap<>(); 42 | custom.forEach( 43 | (key, value) -> { 44 | if (key.contains(".") 45 | && !key.contains("..") 46 | && key.charAt(0) != '.' 47 | && key.charAt(key.length() - 1) != '.') { 48 | addNestedKeyToParameters(result, key, value); 49 | return; 50 | } 51 | result.put(key, value); 52 | }); 53 | return result; 54 | } 55 | 56 | private void addNestedKeyToParameters(Map custom, String key, Object value) { 57 | String[] keys = key.split("\\."); 58 | for (int i = 0; i < keys.length - 1; i++) { 59 | custom.putIfAbsent(keys[i], new HashMap()); 60 | custom = (Map) custom.get(keys[i]); 61 | } 62 | custom.put(keys[keys.length - 1], value); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/collator/GeoParamsCollator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import com.adobe.target.delivery.v1.model.Context; 15 | import com.adobe.target.delivery.v1.model.Geo; 16 | import com.adobe.target.delivery.v1.model.RequestDetails; 17 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 18 | import com.adobe.target.edge.client.utils.StringUtils; 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | public class GeoParamsCollator implements ParamsCollator { 23 | 24 | public static final Map DEFAULT_GEO_PARAMS = 25 | new HashMap() { 26 | { 27 | put(GEO_LATITUDE, null); 28 | put(GEO_LONGITUDE, null); 29 | put(GEO_CITY, ""); 30 | put(GEO_REGION, ""); 31 | put(GEO_COUNTRY, ""); 32 | } 33 | }; 34 | 35 | protected static final String GEO_LATITUDE = "latitude"; 36 | protected static final String GEO_LONGITUDE = "longitude"; 37 | protected static final String GEO_CITY = "city"; 38 | protected static final String GEO_REGION = "region"; 39 | protected static final String GEO_COUNTRY = "country"; 40 | 41 | public Map collateParams( 42 | TargetDeliveryRequest deliveryRequest, RequestDetails requestDetails) { 43 | Map params = new HashMap<>(); 44 | Context context = deliveryRequest.getDeliveryRequest().getContext(); 45 | if (context == null || context.getGeo() == null) { 46 | params.putAll(DEFAULT_GEO_PARAMS); 47 | return params; 48 | } 49 | 50 | Geo geo = context.getGeo(); 51 | params.put(GEO_LATITUDE, geo.getLatitude()); 52 | params.put(GEO_LONGITUDE, geo.getLongitude()); 53 | params.put( 54 | GEO_CITY, 55 | StringUtils.isEmpty(geo.getCity()) ? "" : geo.getCity().toUpperCase().replace(" ", "")); 56 | params.put( 57 | GEO_REGION, 58 | StringUtils.isEmpty(geo.getStateCode()) ? "" : geo.getStateCode().toUpperCase()); 59 | params.put( 60 | GEO_COUNTRY, 61 | StringUtils.isEmpty(geo.getCountryCode()) ? "" : geo.getCountryCode().toUpperCase()); 62 | 63 | return params; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/collator/ParamsCollator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import com.adobe.target.delivery.v1.model.RequestDetails; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import java.util.Map; 17 | 18 | public interface ParamsCollator { 19 | 20 | Map collateParams( 21 | TargetDeliveryRequest deliveryRequest, RequestDetails requestDetails); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/ondevice/collator/TimeParamsCollator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import com.adobe.target.delivery.v1.model.RequestDetails; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import java.text.SimpleDateFormat; 17 | import java.util.*; 18 | 19 | public class TimeParamsCollator implements ParamsCollator { 20 | 21 | protected static final String CURRENT_TIMESTAMP = "current_timestamp"; 22 | protected static final String CURRENT_DAY = "current_day"; 23 | protected static final String CURRENT_TIME = "current_time"; 24 | 25 | public Map collateParams( 26 | TargetDeliveryRequest deliveryRequest, RequestDetails requestDetails) { 27 | Map time = new HashMap<>(); 28 | long now = currentTimestamp(); 29 | Date nowDate = new Date(now); 30 | time.put(CURRENT_TIMESTAMP, now); 31 | SimpleDateFormat dayFormat = new SimpleDateFormat("u"); 32 | dayFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 33 | time.put(CURRENT_DAY, dayFormat.format(nowDate)); 34 | SimpleDateFormat timeFormat = new SimpleDateFormat("HHmm"); 35 | timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 36 | time.put(CURRENT_TIME, timeFormat.format(nowDate)); 37 | return time; 38 | } 39 | 40 | protected long currentTimestamp() { 41 | return System.currentTimeMillis(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/service/TargetService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.service; 13 | 14 | import com.adobe.target.edge.client.http.ResponseStatus; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import com.adobe.target.edge.client.model.TargetDeliveryResponse; 17 | import java.util.concurrent.CompletableFuture; 18 | 19 | public interface TargetService extends AutoCloseable { 20 | 21 | TargetDeliveryResponse executeRequest(TargetDeliveryRequest deliveryRequest); 22 | 23 | CompletableFuture executeRequestAsync( 24 | TargetDeliveryRequest deliveryRequest); 25 | 26 | ResponseStatus executeNotification(TargetDeliveryRequest deliveryRequest); 27 | 28 | CompletableFuture executeNotificationAsync(TargetDeliveryRequest deliveryRequest); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/service/VisitorProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.service; 13 | 14 | import com.adobe.experiencecloud.ecid.visitor.Visitor; 15 | import com.adobe.target.edge.client.exception.TargetClientException; 16 | import com.adobe.target.edge.client.exception.TargetRequestException; 17 | import java.io.UnsupportedEncodingException; 18 | import java.net.URLEncoder; 19 | 20 | public class VisitorProvider { 21 | 22 | private static VisitorProvider INSTANCE = null; 23 | 24 | private final String VISITOR_COOKIE_PREFIX = "AMCV_"; 25 | private String visitorCookieName; 26 | private String orgId; 27 | 28 | private VisitorProvider(String orgId) throws UnsupportedEncodingException { 29 | this.orgId = orgId; 30 | this.visitorCookieName = VISITOR_COOKIE_PREFIX + URLEncoder.encode(orgId, "UTF-8"); 31 | } 32 | 33 | public Visitor createVisitor(String visitorCookie) { 34 | return new Visitor(orgId, visitorCookie); 35 | } 36 | 37 | public String getVisitorCookieName() { 38 | return visitorCookieName; 39 | } 40 | 41 | public static VisitorProvider getInstance() { 42 | if (INSTANCE == null) { 43 | throw new TargetRequestException("VisitorProvider instance is not initialized"); 44 | } 45 | 46 | return INSTANCE; 47 | } 48 | 49 | public static VisitorProvider init(String orgId) { 50 | try { 51 | INSTANCE = new VisitorProvider(orgId); 52 | } catch (UnsupportedEncodingException e) { 53 | throw new TargetClientException("Error occurred while initializing VisitorProvider", e); 54 | } 55 | return INSTANCE; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/AllocationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | public class AllocationUtils { 15 | private static final int TOTAL_BUCKETS = 10_000; 16 | private static final int MAX_PERCENTAGE = 100; 17 | 18 | public static String getDeviceId( 19 | String clientId, String activityId, String visitorId, String salt) { 20 | return clientId + "." + activityId + "." + visitorId + "." + salt; 21 | } 22 | 23 | public static double calculateAllocation( 24 | String clientId, String activityId, String visitorId, String salt) { 25 | return calculateAllocation(getDeviceId(clientId, activityId, visitorId, salt)); 26 | } 27 | 28 | public static double calculateAllocation(String deviceId) { 29 | int hashValue = HashingUtils.hashUnencodedChars(deviceId); 30 | 31 | int hashFixedBucket = Math.abs(hashValue) % TOTAL_BUCKETS; 32 | float allocationValue = ((float) hashFixedBucket / TOTAL_BUCKETS) * MAX_PERCENTAGE; 33 | 34 | return (double) Math.round(allocationValue * 100) / 100; // two decimal places 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import java.util.Collection; 15 | import java.util.Map; 16 | 17 | public class CollectionUtils { 18 | 19 | public static boolean isEmpty(Collection collection) { 20 | return collection == null || collection.isEmpty(); 21 | } 22 | 23 | public static boolean isNotEmpty(Collection collection) { 24 | return !isEmpty(collection); 25 | } 26 | 27 | public static boolean isEmpty(Map map) { 28 | return map == null || map.isEmpty(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/HashingUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | /** 15 | * Hashing util that implements a MurmurHash3 algorithm. Based on the guava implementation found 16 | * here 17 | * https://github.com/google/guava/blob/392f6bf278d6baa907f3d737bb5a216f94ff0794/guava/src/com/google/common/hash/Murmur3_32HashFunction.java 18 | */ 19 | public class HashingUtils { 20 | private static final int DEFAULT_SEED_VALUE = 0; 21 | 22 | private static final int C1 = 0xcc9e2d51; 23 | private static final int C2 = 0x1b873593; 24 | 25 | public static final int CHARACTER_SIZE = 16; 26 | public static final int BYTE_SIZE = 8; 27 | 28 | public static final int CHARS_BYTES = CHARACTER_SIZE / BYTE_SIZE; 29 | 30 | private static int mixK1(int k1) { 31 | k1 *= C1; 32 | k1 = Integer.rotateLeft(k1, 15); 33 | k1 *= C2; 34 | return k1; 35 | } 36 | 37 | private static int mixH1(int h1, int k1) { 38 | h1 ^= k1; 39 | h1 = Integer.rotateLeft(h1, 13); 40 | h1 = h1 * 5 + 0xe6546b64; 41 | return h1; 42 | } 43 | 44 | private static int fmix(int h1, int length) { 45 | h1 ^= length; 46 | h1 ^= h1 >>> 16; 47 | h1 *= 0x85ebca6b; 48 | h1 ^= h1 >>> 13; 49 | h1 *= 0xc2b2ae35; 50 | h1 ^= h1 >>> 16; 51 | return h1; 52 | } 53 | 54 | public static int hashUnencodedChars(CharSequence input) { 55 | return hashUnencodedChars(input, DEFAULT_SEED_VALUE); 56 | } 57 | 58 | public static int hashUnencodedChars(CharSequence input, int seed) { 59 | int h1 = seed; 60 | 61 | // step through the CharSequence 2 chars at a time 62 | for (int i = 1; i < input.length(); i += 2) { 63 | int k1 = input.charAt(i - 1) | (input.charAt(i) << 16); 64 | k1 = mixK1(k1); 65 | h1 = mixH1(h1, k1); 66 | } 67 | 68 | // deal with any remaining characters 69 | if ((input.length() & 1) == 1) { 70 | int k1 = input.charAt(input.length() - 1); 71 | k1 = mixK1(k1); 72 | h1 ^= k1; 73 | } 74 | 75 | return fmix(h1, CHARS_BYTES * input.length()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/LogUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import com.adobe.target.delivery.v1.model.DeliveryRequest; 15 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 16 | import java.util.HashMap; 17 | import java.util.Iterator; 18 | import java.util.Map; 19 | 20 | public class LogUtils { 21 | public static String getRequestDetails(TargetDeliveryRequest targetDeliveryRequest) { 22 | DeliveryRequest deliveryRequest = targetDeliveryRequest.getDeliveryRequest(); 23 | 24 | StringBuilder builder = new StringBuilder(); 25 | builder.append("("); 26 | 27 | Map details = new HashMap<>(); 28 | 29 | details.put("sessionId", targetDeliveryRequest.getSessionId()); 30 | details.put("requestId", deliveryRequest.getRequestId()); 31 | 32 | Iterator> entrySet = details.entrySet().iterator(); 33 | 34 | while (entrySet.hasNext()) { 35 | Map.Entry entry = entrySet.next(); 36 | builder.append(entry.getKey() + ":" + entry.getValue()); 37 | if (entrySet.hasNext()) { 38 | builder.append(", "); 39 | } 40 | } 41 | 42 | builder.append(")"); 43 | 44 | return builder.toString(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import java.math.BigDecimal; 15 | import java.math.RoundingMode; 16 | 17 | public final class MathUtils { 18 | 19 | public static double roundDouble(double d, int places) { 20 | BigDecimal bigDecimal = new BigDecimal(Double.toString(d)); 21 | bigDecimal = bigDecimal.setScale(places, RoundingMode.HALF_UP); 22 | return bigDecimal.doubleValue(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | public class StringUtils { 15 | 16 | public static boolean isEmpty(CharSequence cs) { 17 | return cs == null || cs.length() == 0; 18 | } 19 | 20 | public static boolean isNotEmpty(CharSequence cs) { 21 | return !isEmpty(cs); 22 | } 23 | 24 | public static String firstNonBlank(String... values) { 25 | if (values.length == 0) { 26 | return null; 27 | } 28 | for (String value : values) { 29 | if (isNotEmpty(value)) { 30 | return value; 31 | } 32 | } 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/TargetConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | public class TargetConstants { 15 | 16 | public static final String COOKIE_NAME = "mbox"; 17 | public static final String CLUSTER_COOKIE_NAME = "mboxEdgeCluster"; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/TimingTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | public class TimingTool { 18 | 19 | private Map startTimes = new HashMap<>(); 20 | private Map timings = new HashMap<>(); 21 | 22 | public String timeStart(String id) { 23 | if (!startTimes.containsKey(id)) { 24 | startTimes.put(id, System.nanoTime()); 25 | } 26 | return id; 27 | } 28 | 29 | public double timeEnd(String id) { 30 | if (!startTimes.containsKey(id)) { 31 | return -1; 32 | } 33 | double timing = ((System.nanoTime() - startTimes.get(id)) / 1000000D); 34 | timings.put(id, timing); 35 | return timing; 36 | } 37 | 38 | public Map getTimings() { 39 | return timings; 40 | } 41 | 42 | public double getTiming(String id) { 43 | return timings.get(id); 44 | } 45 | 46 | public void reset() { 47 | startTimes = new HashMap<>(); 48 | timings = new HashMap<>(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/adobe/target/edge/client/utils/VisitorConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | public class VisitorConstants { 15 | public static final String MARKETING_CLOUD_VISITOR_ID = "MCMID"; 16 | public static final String LOCATION_HINT = "MCAAMLH"; 17 | public static final String BLOB = "MCAAMB"; 18 | public static final String SDID_CONSUMER_ID = "target-global-mbox"; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/adobe/target/edge/client/http/TargetMetricsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.http; 13 | 14 | import static org.mockito.ArgumentMatchers.any; 15 | import static org.mockito.Mockito.mock; 16 | import static org.mockito.Mockito.times; 17 | import static org.mockito.Mockito.verify; 18 | 19 | import java.util.function.Consumer; 20 | import kong.unirest.HttpRequestSummary; 21 | import kong.unirest.HttpResponseSummary; 22 | import kong.unirest.MetricContext; 23 | import org.junit.jupiter.api.BeforeEach; 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.mockito.junit.jupiter.MockitoExtension; 27 | 28 | @ExtendWith(MockitoExtension.class) 29 | public class TargetMetricsTest { 30 | 31 | private Consumer consumer; 32 | private HttpRequestSummary request; 33 | private HttpResponseSummary response; 34 | 35 | @BeforeEach 36 | void init() { 37 | consumer = mock(Consumer.class); 38 | request = mock(HttpRequestSummary.class); 39 | response = mock(HttpResponseSummary.class); 40 | } 41 | 42 | @Test 43 | public void testMetricsAreAcceptedWhenNoException() { 44 | TargetMetrics targetMetrics = new TargetMetrics(consumer); 45 | MetricContext metricContext = targetMetrics.begin(request); 46 | 47 | metricContext.complete(response, null); 48 | 49 | verify(consumer, times(1)).accept(any(TargetMetricContext.class)); 50 | } 51 | 52 | @Test 53 | public void testMetricsAreNotAcceptedWhenException() { 54 | TargetMetrics targetMetrics = new TargetMetrics(consumer); 55 | MetricContext metricContext = targetMetrics.begin(request); 56 | 57 | metricContext.complete(null, new Exception()); 58 | 59 | verify(consumer, times(0)).accept(any(TargetMetricContext.class)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/com/adobe/target/edge/client/ondevice/collator/GeoParamsCollatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import static org.junit.jupiter.api.Assertions.assertEquals; 15 | 16 | import com.adobe.target.delivery.v1.model.Context; 17 | import com.adobe.target.delivery.v1.model.ExecuteRequest; 18 | import com.adobe.target.delivery.v1.model.Geo; 19 | import com.adobe.target.delivery.v1.model.RequestDetails; 20 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 21 | import com.adobe.target.edge.client.service.VisitorProvider; 22 | import java.util.Map; 23 | import org.junit.jupiter.api.Test; 24 | 25 | public class GeoParamsCollatorTest { 26 | 27 | @Test 28 | public void testCollator() { 29 | VisitorProvider.init("testOrgId"); 30 | RequestDetails pageLoad = new RequestDetails(); 31 | Geo geo = new Geo(); 32 | geo.setCity("san francisco"); 33 | geo.setStateCode("ca"); 34 | geo.setCountryCode("us"); 35 | geo.setLatitude(37.74f); 36 | geo.setLongitude(-122.24f); 37 | TargetDeliveryRequest request = 38 | TargetDeliveryRequest.builder() 39 | .execute(new ExecuteRequest().pageLoad(pageLoad)) 40 | .context(new Context().geo(geo)) 41 | .build(); 42 | GeoParamsCollator collator = new GeoParamsCollator(); 43 | Map result = collator.collateParams(request, pageLoad); 44 | assertEquals("SANFRANCISCO", result.get(GeoParamsCollator.GEO_CITY)); 45 | assertEquals("CA", result.get(GeoParamsCollator.GEO_REGION)); 46 | assertEquals("US", result.get(GeoParamsCollator.GEO_COUNTRY)); 47 | assertEquals(37.74f, (Float) result.get(GeoParamsCollator.GEO_LATITUDE), 0.01); 48 | assertEquals(-122.24f, (Float) result.get(GeoParamsCollator.GEO_LONGITUDE), 0.01); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/adobe/target/edge/client/ondevice/collator/TimeParamsCollatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.ondevice.collator; 13 | 14 | import static org.junit.jupiter.api.Assertions.assertEquals; 15 | import static org.mockito.Mockito.CALLS_REAL_METHODS; 16 | import static org.mockito.Mockito.mock; 17 | 18 | import com.adobe.target.delivery.v1.model.ExecuteRequest; 19 | import com.adobe.target.delivery.v1.model.RequestDetails; 20 | import com.adobe.target.edge.client.model.TargetDeliveryRequest; 21 | import com.adobe.target.edge.client.service.VisitorProvider; 22 | import java.util.Map; 23 | import org.junit.jupiter.api.Test; 24 | import org.mockito.Mockito; 25 | 26 | public class TimeParamsCollatorTest { 27 | 28 | @Test 29 | public void testCollator() { 30 | VisitorProvider.init("testOrgId"); 31 | TimeParamsCollator collator = mock(TimeParamsCollator.class, CALLS_REAL_METHODS); 32 | long now = 1592433971000L; 33 | Mockito.doReturn(now).when(collator).currentTimestamp(); 34 | RequestDetails pageLoad = new RequestDetails(); 35 | TargetDeliveryRequest request = 36 | TargetDeliveryRequest.builder().execute(new ExecuteRequest().pageLoad(pageLoad)).build(); 37 | Map result = collator.collateParams(request, pageLoad); 38 | assertEquals(now, result.get(TimeParamsCollator.CURRENT_TIMESTAMP)); 39 | assertEquals("3", result.get(TimeParamsCollator.CURRENT_DAY)); 40 | assertEquals("2246", result.get(TimeParamsCollator.CURRENT_TIME)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/adobe/target/edge/client/utils/AllocationUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import static org.junit.jupiter.api.Assertions.assertEquals; 15 | import static org.junit.jupiter.api.Assertions.assertTrue; 16 | 17 | import org.junit.jupiter.api.Test; 18 | import org.junit.jupiter.api.extension.ExtendWith; 19 | import org.mockito.junit.jupiter.MockitoExtension; 20 | 21 | @ExtendWith(MockitoExtension.class) 22 | public class AllocationUtilsTest { 23 | 24 | @Test 25 | void testAllocationCalc() { 26 | assertEquals( 27 | AllocationUtils.calculateAllocation("someClientId", "123456", "ecid123", "salty"), 29.06); 28 | 29 | assertEquals( 30 | AllocationUtils.calculateAllocation("someClientId", "123456", "tntId123", "salty"), 21.94); 31 | 32 | assertEquals( 33 | AllocationUtils.calculateAllocation("someClientId", "123456", "tntId123.28_0", "salty"), 34 | 32.94); 35 | 36 | assertEquals( 37 | AllocationUtils.calculateAllocation("someClientId", "123456", "thirtPartyId123", "salty"), 38 | 73.15); 39 | } 40 | 41 | @Test 42 | public void testAllocationInRange() { 43 | for (long i = 0; i < 10000; i++) { 44 | double allocation = 45 | AllocationUtils.calculateAllocation("myTntId99152", "123456", String.valueOf(i), "salty"); 46 | assertTrue(allocation >= 0); 47 | assertTrue(allocation <= 100); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/adobe/target/edge/client/utils/MockRawResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | */ 12 | package com.adobe.target.edge.client.utils; 13 | 14 | import java.io.InputStream; 15 | import java.io.InputStreamReader; 16 | import kong.unirest.Config; 17 | import kong.unirest.Headers; 18 | import kong.unirest.HttpRequestSummary; 19 | import kong.unirest.HttpResponseSummary; 20 | import kong.unirest.RawResponse; 21 | 22 | public class MockRawResponse implements RawResponse { 23 | 24 | @Override 25 | public int getStatus() { 26 | return 200; 27 | } 28 | 29 | @Override 30 | public String getStatusText() { 31 | return null; 32 | } 33 | 34 | @Override 35 | public Headers getHeaders() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public InputStream getContent() { 41 | return null; 42 | } 43 | 44 | @Override 45 | public byte[] getContentAsBytes() { 46 | return "{\"msg\":\"success\"}".getBytes(); 47 | } 48 | 49 | @Override 50 | public String getContentAsString() { 51 | return null; 52 | } 53 | 54 | @Override 55 | public String getContentAsString(String charset) { 56 | return null; 57 | } 58 | 59 | @Override 60 | public InputStreamReader getContentReader() { 61 | return null; 62 | } 63 | 64 | @Override 65 | public boolean hasContent() { 66 | return false; 67 | } 68 | 69 | @Override 70 | public String getContentType() { 71 | return "application/json;charset=UTF-8"; 72 | } 73 | 74 | @Override 75 | public String getEncoding() { 76 | return null; 77 | } 78 | 79 | @Override 80 | public Config getConfig() { 81 | return null; 82 | } 83 | 84 | @Override 85 | public HttpResponseSummary toSummary() { 86 | return null; 87 | } 88 | 89 | @Override 90 | public HttpRequestSummary getRequestSummary() { 91 | return null; 92 | } 93 | } 94 | --------------------------------------------------------------------------------