Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
F4pl0 committed Oct 29, 2023
1 parent f079fb5 commit 0184a24
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 5 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This workflow will build a Java project with Maven

name: Java CI with Maven

on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
releaseVersion:
description: "Define the release version"
required: true
default: ""
developmentVersion:
description: "Define the snapshot version"
required: true
default: ""

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: 20.0.1
distribution: 'temurin'
java-package: 'jdk'
cache: 'maven'
server-id: ossrh
- name: Configure Git User
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5.0.0
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Verify Whether a Release is Ready
id: release
shell: bash
run: |
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
echo "auto_release=true" >> $GITHUB_ENV
else
echo "auto_release=false" >> $GITHUB_ENV
fi
- name: Release With Maven
run: |
mvn -B -U \
-Pci-cd \
release:prepare \
release:perform \
javadoc:jar \
source:jar \
-s settings.xml \
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \
deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }}
- name: Artifact Name
shell: bash
run: |
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
- name: Define Jar Name
shell: bash
run: |
echo "{{ env.artifact_name }}"
ls -al ./target/
mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}-${{ env.sha_short }}
path: ./target/${{ env.artifact_name }}.jar
- name: Workflow Release Notes
uses: peter-evans/repository-dispatch@v2
if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != ""
with:
event-type: release-notes
client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}'
155 changes: 154 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,167 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.f4pl0.iexcloud</groupId>
<groupId>io.github.f4pl0</groupId>
<artifactId>iex-cloud</artifactId>
<version>1.0-SNAPSHOT</version>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<developers>
<developer>
<id>f4pl0</id>
<name>f4</name>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/F4pl0/iex-cloud-java.git</connection>
<url>https://github.com/F4pl0/iex-cloud-java.git</url>
<developerConnection>scm:git:https://github.com/F4pl0/iex-cloud-java.git</developerConnection>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.1</version>
</dependency>
</dependencies>

<build>
<finalName>iex-cloud</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>ci-cd</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>${env.AUTO_RELEASE_AFTER_CLOSE}</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
<executions>
<execution>
<id>default</id>
<goals>
<goal>perform</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
73 changes: 73 additions & 0 deletions src/main/java/io/github/f4pl0/IEXCloudClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package io.github.f4pl0;

import io.github.f4pl0.equitiesmarketdata.EquitiesMarketData;
import io.github.f4pl0.reference.Reference;

public class IEXCloudClient {
public final EquitiesMarketData equitiesMarketData;
public final Reference reference;

private IEXCloudClient(IEXCloudConfig config) {

equitiesMarketData = new EquitiesMarketData(config);
reference = new Reference(config);
}

/**
* Builder for the IEXCloudClient.
* You will need to set the publishable and secret tokens before building the client.
*/
public static class IEXCloudClientBuilder {
private String publishableToken;
private String secretToken;
private String baseEndpoint = "https://api.iex.cloud/v1";

/**
* Set the publishable token for the IEXCloudClient.
* @param publishableToken The IEX Cloud publishable token.
* @return The IEXCloudClientBuilder object.
*/
public IEXCloudClientBuilder setPublishableToken(String publishableToken) {
this.publishableToken = publishableToken;
return this;
}

/**
* Set the secret token for the IEXCloudClient.
* @param secretToken The IEX Cloud secret token.
* @return The IEXCloudClientBuilder object.
*/
public IEXCloudClientBuilder setSecretToken(String secretToken) {
this.secretToken = secretToken;
return this;
}

/**
* Set the base endpoint for the IEXCloudClient.
* @param baseEndpoint The IEX Cloud base endpoint.
* @return The IEXCloudClientBuilder object.
*/
public IEXCloudClientBuilder setBaseEndpoint(String baseEndpoint) {
this.baseEndpoint = baseEndpoint;
return this;
}

/**
* Build the IEXCloudClient object.
* @return The IEXCloudClient object.
* @throws IllegalArgumentException If the publishable token is not set.
*/
public IEXCloudClient build() {
// Validate the builder
if (publishableToken == null || publishableToken.isEmpty()) {
throw new IllegalArgumentException("Publishable token must be set");
}

IEXCloudConfig config = new IEXCloudConfig();
config.setPublishableToken(publishableToken);
config.setSecretToken(secretToken);
config.setBaseEndpoint(baseEndpoint);
return new IEXCloudClient(config);
}
}
}
10 changes: 10 additions & 0 deletions src/main/java/io/github/f4pl0/IEXCloudConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.f4pl0;

import lombok.Data;

@Data
public class IEXCloudConfig {
private String publishableToken;
private String secretToken;
private String baseEndpoint;
}
19 changes: 19 additions & 0 deletions src/main/java/io/github/f4pl0/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.f4pl0;

import io.github.f4pl0.reference.data.IEXTradingSymbol;
import lombok.SneakyThrows;

import java.util.List;

public class Main {

@SneakyThrows
public static void main(String[] args) {
IEXCloudClient client = new IEXCloudClient.IEXCloudClientBuilder()
.setPublishableToken("pk_5f9b26d6d90e485a87729ac70e5978a6")
.build();

List<IEXTradingSymbol> symbols = client.reference.dailyIEXTradingSymbols();
System.out.println(symbols);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.f4pl0.equitiesmarketdata;

import io.github.f4pl0.IEXCloudConfig;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class EquitiesMarketData {
private final IEXCloudConfig config;
}
Loading

0 comments on commit 0184a24

Please sign in to comment.