Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Commit

Permalink
Merge branch 'develop' into update-from-template-merged
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev-gh-bot committed Oct 28, 2024
2 parents b8de24f + 763a8d8 commit 21d7924
Show file tree
Hide file tree
Showing 47 changed files with 2,926 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ body:
attributes:
label: "Checklist"
options:
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/universe-client/releases/latest)"
required: true
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/universe-client/issues) or [closed](https://github.com/xdev-software/universe-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/universe-client/issues) or [closed](https://github.com/xdev-software/universe-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/universe-client/issues) or [closed](https://github.com/xdev-software/universe-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions .run/Run Demo.run.xml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 2.0.0
<i>Major refactoring</i>
* Now requires less dependencies
* API was changed so that it's easier usable
* Requires Java 17+
* Updated dependencies

# 1.0.0
Initial release
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/universe-client/release.yml?branch=master)](https://github.com/xdev-software/universe-client/actions/workflows/release.yml)

Before releasing:
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Consider doing a [test-deployment](https://github.com/xdev-software/universe-client/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
60 changes: 54 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,60 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/universe-client?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/universe-client)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/universe-client/check-build.yml?branch=develop)](https://github.com/xdev-software/universe-client/actions/workflows/check-build.yml?query=branch%3Adevelop)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_universe-client&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_universe-client)

# template-placeholder
# Universe client for Java

A simple Java client for the [Universe API](https://developers.universe.com).

## Usage

The two basic entries are the ``ApplicationId`` and the ``RedirectUri``. They **must** be set.

If these two entries are set, you need to get ``AuthorizationCode``. This is a one-time-only code, which
you get by calling the URL provided by ``client.getUrlToGetAuthorizationCode()``.

With this ``AuthorizationCode`` you can request a ``BearerToken``. You can can request the ``BearerToken`` only
one time with one ``AuthorizationCode``. After that the ``AuthorizationCode`` is invalidated.
This can be achieved with ``client.requestBearerToken()``.
The ``BearerToken`` can be used for all your future requests. It is usually valid for one month.

If the ``BearerToken`` is set, you can use the actual API calls.

### Example
Full example, see [Demo](universe-client-demo/src/main/java/software/xdev/Application.java).

```java
UniverseClient client = new UniverseClient(yourConfig);

// Get Events
List<Event> events = client.requestEvents(hostId);
events.forEach(event -> logger.info("Event: " + event.getTitle() + "(id:" + event.getId() + ")"));

// Get Attendees
List<Attendee> attendees = client.requestAttendeesInEvent(events.get(0).getId(), 5, 0);
```

## GraphQL
We are using the [Universe GraphQL API](https://developers.universe.com/docs/graphql).
Here are some thing to help with orientation with GraphQL.

You can test requests on [Universes GraphiQL (Explorer)](https://www.universe.com/graphiql);

Get Schema:
```
{
__schema {
queryType {
fields {
name
}
}
}
}
```

## Installation
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
[Installation guide for the latest release](https://github.com/xdev-software/universe-client/releases/latest#Installation)

## Support
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
Expand All @@ -15,4 +63,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/universe-client/dependencies)
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/universe-client/security/advisories/new).
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>universe-client-root</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<organization>
Expand All @@ -15,8 +15,8 @@
</organization>

<modules>
<module>template-placeholder</module>
<module>template-placeholder-demo</module>
<module>universe-client</module>
<module>universe-client-demo</module>
</modules>

<properties>
Expand Down Expand Up @@ -77,6 +77,9 @@
<rulesets>
<ruleset>.config/pmd/ruleset.xml</ruleset>
</rulesets>
<excludes>
<exclude>software/xdev/universe/requests/**</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packageRules": [
{
"description": "Ignore project internal dependencies",
"packagePattern": "^software.xdev:template-placeholder",
"packagePattern": "^software.xdev:universe-client",
"datasources": [
"maven"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<parent>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>universe-client-root</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>template-placeholder-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>universe-client-demo</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand All @@ -32,7 +32,7 @@
<dependencies>
<dependency>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder</artifactId>
<artifactId>universe-client</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down
89 changes: 89 additions & 0 deletions universe-client-demo/src/main/java/software/xdev/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package software.xdev;

import java.awt.Desktop;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.util.List;
import java.util.Scanner;

import software.xdev.universe.UniverseClient;
import software.xdev.universe.UniverseConfiguration;
import software.xdev.universe.requests.get_attendees.Attendee;
import software.xdev.universe.requests.get_attendees.DefaultQuestions;
import software.xdev.universe.requests.get_buyers.Buyer;
import software.xdev.universe.requests.get_events.Event;


public final class Application
{
public static void main(final String[] args)
{
final UniverseClient client = new UniverseClient(new UniverseConfiguration(
System.getProperty("applicationId"),
System.getProperty("applicationSecret"),
System.getProperty("redirectUri"),
System.getProperty("authorizationCode"),
System.getProperty("bearerToken")
));

// STEP 1: Get Authorization Code
// After getting the authorization code it must be set in the microprofile-config.properties
// or through client.getConfig().withAuthorizationCode()
client.withAuthorizationCode(openBrowserToGetAuthorizationCodeAndWaitForInput(client));

// STEP 2: Get Bearer Token
// After getting the bearer token it must be set in the microprofile-config.properties
// or through client.getConfig().withBearerToken()
client.withBearerToken(client.requestBearerToken().getAccessToken());

// STEP 3: Get Host Id
final String hostId = client.requestHostId();

// STEP 4: Get Events
final List<Event> events = client.requestEvents(hostId);
events.forEach(event -> System.out.println(("Event: " + event.getTitle() + "(id:" + event.getId() + ")")));

// STEP 5: Get Buyers
final List<Buyer> buyers = client.requestBuyersInEvent(events.get(0).getId(), 5, 0);
buyers.forEach(buyer -> System.out.println(("Buyer: " + buyer.getName())));

// STEP 6: Get Attendees
final List<Attendee> attendees = client.requestAttendeesInEvent(events.get(0).getId(), 5, 0);
attendees.forEach(attendee ->
System.out.println(
"Attendee: "
+ "\n Name: " + attendee.getTypedAnswerToQuestion(DefaultQuestions.FIRST_NAME)
+ " " + attendee.getTypedAnswerToQuestion(DefaultQuestions.LAST_NAME)
+ "\n Email: " + attendee.getTypedAnswerToQuestion(DefaultQuestions.EMAIL)
+ "\n Company: " + attendee.getTypedAnswerToQuestion(DefaultQuestions.COMPANY)
+ "\n Job: " + attendee.getTypedAnswerToQuestion(DefaultQuestions.JOB_TITLE)
+ "\n Country: " + attendee.getTypedAnswerToQuestion(DefaultQuestions.COUNTRY)
)
);
}

private static String openBrowserToGetAuthorizationCodeAndWaitForInput(final UniverseClient client)
{
if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE))
{
try
{
Desktop.getDesktop().browse(URI.create(client.getUrlToGetAuthorizationCode()));
}
catch(final IOException ex)
{
throw new UncheckedIOException(ex);
}
}
try(final Scanner scanner = new Scanner(System.in))
{
System.out.println("Please input displayed authorization code:");
return scanner.nextLine();
}
}

private Application()
{
}
}
31 changes: 24 additions & 7 deletions template-placeholder/pom.xml → universe-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>template-placeholder</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>universe-client</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>template-placeholder</name>
<description>template-placeholder</description>
<url>https://github.com/xdev-software/template-placeholder</url>
<name>universe-client</name>
<description>universe-client</description>
<url>https://github.com/xdev-software/universe-client</url>

<scm>
<url>https://github.com/xdev-software/template-placeholder</url>
<connection>scm:git:https://github.com/xdev-software/template-placeholder.git</connection>
<url>https://github.com/xdev-software/universe-client</url>
<connection>scm:git:https://github.com/xdev-software/universe-client.git</connection>
</scm>

<inceptionYear>2023</inceptionYear>
Expand Down Expand Up @@ -84,6 +84,20 @@
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -279,6 +293,9 @@
<rulesets>
<ruleset>../.config/pmd/ruleset.xml</ruleset>
</rulesets>
<excludes>
<exclude>software/xdev/universe/requests/**</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
Expand Down
Loading

0 comments on commit 21d7924

Please sign in to comment.