Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 91 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,91 @@ To use the xAPI Client include the appropriate XML in the `dependencies` section
<dependency>
<groupId>dev.learning.xapi</groupId>
<artifactId>xapi-client</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
</dependencies>
</project>
```

### Statement Resource

The xAPI Client allows applications to store and fetch xAPI [Statements](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#statements).

### Getting a Statement

```java
var response = client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block();

Statement statement = response.getBody();
```

### Getting Statements

Example:

```java
var response = client.getStatements().block();

StatementResult statementResult = response.getBody();

Statement[] statements = statementResult.getStatements();
```

### Getting the next page of Statements


Example:

```java
var response = client.getStatements().block();

var moreResponse = client.getMoreStatements(r -> r.more(response.getBody().getMore())).block();

StatementResult moreStatementResult = moreResponse.getBody();

Statement[] statements = moreStatementResult.getStatements();
```


### Posting a Statement

Example:

```java
client.postStatement(
r -> r.statement(s -> s.actor(a -> a.name("A N Other").mbox("mailto:another@example.com"))

.verb(Verb.ATTEMPTED)

.activityObject(o -> o.id("https://example.com/activity/simplestatement")
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))))
.block();
```

### Posting Statements

Example:

```java
Statement attemptedStatement = Statement.builder()
.actor(a -> a.name("A N Other").mbox("mailto:another@example.com")).verb(Verb.ATTEMPTED)
.activityObject(o -> o.id("https://example.com/activity/simplestatement")
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))
.build();

Statement passedStatement = attemptedStatement.toBuilder().verb(Verb.PASSED).build();

client.postStatements(r -> r.statements(attemptedStatement, passedStatement)).block();
```

### Getting voided a Statement

```java
var response = client.getVoidedStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block();

Statement voidedStatement = response.getBody();
```

### State Resource

The xAPI Client allows applications to store, change, fetch, or delete [state documents](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#23-state-resource).
Expand All @@ -39,7 +118,7 @@ The xAPI Client allows applications to store, change, fetch, or delete [state do
Example:

```java
final var request = client.getState(r -> r.activityId("https://example.com/activity/1")
var request = client.getState(r -> r.activityId("https://example.com/activity/1")

.agent(a -> a.name("A N Other").mbox("another@example.com"))

Expand All @@ -48,8 +127,8 @@ final var request = client.getState(r -> r.activityId("https://example.com/activ
.stateId("bookmark"), String.class)

.block();
final String state = request.getBody();

String state = request.getBody();
```

#### Posting a state
Expand Down Expand Up @@ -123,7 +202,7 @@ To use the xAPI Model include the appropriate XML in the `dependencies` section
<dependency>
<groupId>dev.learning.xapi</groupId>
<artifactId>xapi-model</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
</dependencies>
</project>
Expand All @@ -134,7 +213,7 @@ To use the xAPI Model include the appropriate XML in the `dependencies` section
Example:

```java
final Statement statement = Statement.builder()
Statement statement = Statement.builder()

.actor(a -> a.name("A N Other").mbox("mailto:another@example.com"))

Expand All @@ -153,7 +232,7 @@ The Jackson ObjectMapper can be used to deserialize statements into Java objects
Example:

```java
final String json = """
String json = """
{
"actor":{
"objectType":"Agent",
Expand All @@ -177,7 +256,7 @@ final String json = """
}
}""";

final Statement statement = objectMapper.readValue(json, Statement.class);
Statement statement = objectMapper.readValue(json, Statement.class);
```

### Serializing Statements
Expand All @@ -188,13 +267,13 @@ Example:

```java

final Statement statement = Statement.builder()
Statement statement = Statement.builder()
.actor(a -> a.name("A N Other").mbox("mailto:another@example.com")).verb(Verb.ATTEMPTED)
.activityObject(o -> o.id("https://example.com/activity/simplestatement")
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))
.build();

final String json = objectMapper.writeValueAsString(statement);
String json = objectMapper.writeValueAsString(statement);

```

Expand All @@ -204,13 +283,13 @@ Example:

```java

final Statement passed = Statement.builder()
Statement passed = Statement.builder()
.actor(a -> a.name("A N Other").mbox("mailto:another@example.com")).verb(Verb.PASSED)
.activityObject(o -> o.id("https://example.com/activity/simplestatement")
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))
.build();

final Statement completed = passed.toBuilder().verb(Verb.COMPLETED).build();
Statement completed = passed.toBuilder().verb(Verb.COMPLETED).build();

```

Expand Down
26 changes: 0 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@
<name>xAPI Build</name>
<description>learning.dev xAPI Build</description>
<url>https://github.com/BerryCloud/xapi-java</url>

<properties>
<java.version>17</java.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<maven-checkstyle-plugin.version>3.2.1</maven-checkstyle-plugin.version>
<checkstyle.version>10.6.0</checkstyle.version>
<lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
</properties>

<organization>
<name>Berry Cloud Ltd</name>
<url>https://berrycloud.co.uk</url>
</organization>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<developers>
<developer>
<id>thomas_turrell</id>
Expand Down Expand Up @@ -66,29 +62,24 @@
</roles>
</developer>
</developers>

<scm>
<url>https://github.com/BerryCloud/xapi-java</url>
<connection>scm:git:https://github.com/BerryCloud/xapi-java.git</connection>
<developerConnection>scm:git:https://github.com/BerryCloud/xapi-java.git</developerConnection>
<tag>HEAD</tag>
</scm>

<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/BerryCloud/xapi-java/issues</url>
</issueManagement>

<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/BerryCloud/xapi-java/actions</url>
</ciManagement>

<modules>
<module>xapi-model</module>
<module>xapi-client</module>
</modules>

<build>
<pluginManagement>
<plugins>
Expand All @@ -97,7 +88,6 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -110,7 +100,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -123,7 +112,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -136,7 +124,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand All @@ -158,7 +145,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -190,7 +176,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -202,8 +187,6 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>


<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
Expand Down Expand Up @@ -238,7 +221,6 @@
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -259,7 +241,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand All @@ -273,7 +254,6 @@
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -283,7 +263,6 @@
</dependency>
</dependencies>
</dependencyManagement>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand All @@ -294,7 +273,6 @@
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<profiles>
<profile>
<id>release</id>
Expand All @@ -304,17 +282,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -323,5 +298,4 @@
</build>
</profile>
</profiles>

</project>
Loading