First commit - A basic library available
This commit is contained in:
commit
321e9799fe
2
lib/.gitignore
vendored
Normal file
2
lib/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
bin/
|
||||
build/
|
||||
33
lib/build.gradle
Normal file
33
lib/build.gradle
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* This generated file contains a sample Java library project to get you started.
|
||||
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
|
||||
* User Manual available at https://docs.gradle.org/7.3.3/userguide/building_java_projects.html
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Apply the java-library plugin for API and implementation separation.
|
||||
id 'java-library'
|
||||
id 'eclipse'
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Use JUnit test framework.
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
|
||||
|
||||
implementation "com.google.code.gson:gson:2.8.9"
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
showStandardStreams = true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,217 @@
|
||||
package com.bernard.hellojasso;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.bernard.hellojasso.hellobjects.CompleteFormData;
|
||||
import com.bernard.hellojasso.hellobjects.CompleteItemData;
|
||||
import com.bernard.hellojasso.hellobjects.FormData;
|
||||
import com.bernard.hellojasso.hellobjects.PaymentData;
|
||||
import com.bernard.hellojasso.hellobjects.requests.GrantCredentialsRequestData;
|
||||
import com.bernard.hellojasso.hellobjects.requests.PaginatedListRequestData;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class HelloAssoConnection {
|
||||
|
||||
String token;
|
||||
String refreshToken;
|
||||
long expirationTimestamp;
|
||||
|
||||
int pagesize = 100;
|
||||
|
||||
public static final String encoding = "UTF-8";
|
||||
|
||||
static Logger log = LogManager.getLogger(HelloAssoConnection.class);
|
||||
|
||||
private HelloAssoConnection(String token, String refreshToken, long expirationTimestamp) {
|
||||
this.token = token;
|
||||
this.refreshToken = refreshToken;
|
||||
this.expirationTimestamp = expirationTimestamp;
|
||||
}
|
||||
|
||||
public static HelloAssoConnection makeConnection(File credentialsFile) throws IOException {
|
||||
|
||||
// Reading credentials file
|
||||
BufferedReader credentialsBr = new BufferedReader(new FileReader(credentialsFile));
|
||||
String clientId = credentialsBr.readLine();
|
||||
String clientSecret = credentialsBr.readLine();
|
||||
credentialsBr.close();
|
||||
|
||||
return makeConnection(clientId, clientSecret);
|
||||
}
|
||||
|
||||
public static HelloAssoConnection makeConnection(String clientId, String clientSecret) {
|
||||
|
||||
try {
|
||||
|
||||
URL urlObj = new URL("https://api.helloasso.com/oauth2/token");
|
||||
HttpsURLConnection connection = (HttpsURLConnection) urlObj.openConnection();
|
||||
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
connection.setRequestProperty("Accept-Charset", encoding);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
||||
wr.write("client_id=");
|
||||
wr.write(clientId);
|
||||
wr.write("&client_secret=");
|
||||
wr.write(clientSecret);
|
||||
wr.write("&grant_type=client_credentials");
|
||||
wr.close();
|
||||
|
||||
System.out.println("Send 'HTTP POST' request to : " + urlObj);
|
||||
|
||||
Integer responseCode = connection.getResponseCode();
|
||||
System.out.println("Response Code : " + responseCode);
|
||||
|
||||
|
||||
BufferedReader inputReader = new BufferedReader(new InputStreamReader(connection.getInputStream(),encoding));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = inputReader.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
inputReader.close();
|
||||
|
||||
// create Gson instance
|
||||
Gson gson = new Gson();
|
||||
|
||||
// convert JSON file to map
|
||||
GrantCredentialsRequestData gcrd = gson.fromJson(response.toString(), GrantCredentialsRequestData.class);
|
||||
|
||||
return new HelloAssoConnection(gcrd.getAccess_token(), gcrd.getRefresh_token(), System.currentTimeMillis() + 1000*gcrd.getExpires_in());
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ProtocolException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String doRequest(String url){
|
||||
try {
|
||||
// Reading credentials file
|
||||
|
||||
URL urlObj = new URL(url);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) urlObj.openConnection();
|
||||
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");//TODO: UserAgent arbitraire
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
connection.setRequestProperty("authorization", "Bearer "+token);
|
||||
connection.setRequestProperty("Accept-Charset", encoding);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
log.debug("Send 'HTTP POST' request to : " + urlObj);
|
||||
|
||||
// TODO: Change Sysouts to Log.d
|
||||
Integer responseCode = connection.getResponseCode();
|
||||
log.debug("Response Code : " + responseCode);
|
||||
|
||||
|
||||
BufferedReader inputReader = new BufferedReader(new InputStreamReader(connection.getInputStream(),encoding));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = inputReader.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
inputReader.close();
|
||||
|
||||
System.out.println(response);
|
||||
|
||||
return response.toString();
|
||||
} catch (ProtocolException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T> T doRequest(String url, Type castClass) {
|
||||
|
||||
String response = this.doRequest(url);
|
||||
log.debug(response);
|
||||
// create Gson instance
|
||||
Gson gson = new Gson();
|
||||
|
||||
// convert JSON file to T
|
||||
T result = gson.fromJson(response, castClass);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private <T> List<T> requestList(String url, Class<T> returnClass) {
|
||||
List<T> out = new ArrayList<>();
|
||||
|
||||
String argDelimiter = url.contains("?")?"&":"?";
|
||||
|
||||
Type tt = TypeToken.getParameterized(PaginatedListRequestData.class,returnClass).getType();
|
||||
|
||||
PaginatedListRequestData<T> plrd = null;
|
||||
String continuationToken = null;
|
||||
do {
|
||||
String reqUrl = url + ((continuationToken==null)?"":(argDelimiter+"continuationToken="+continuationToken));
|
||||
|
||||
plrd = this.doRequest(reqUrl,(Type) tt);
|
||||
|
||||
out.addAll(plrd.getData());
|
||||
continuationToken = plrd.getPagination().getContinuationToken();
|
||||
} while (plrd.getPagination().getPageIndex() < plrd.getPagination().getTotalPages());
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<String> listBilletteriesSlugs(String organizationSlug) {
|
||||
List<FormData> ofprd = this.requestList("https://api.helloasso.com/v5/organizations/"+organizationSlug+"/forms",FormData.class);
|
||||
|
||||
return ofprd.stream().map(e -> e.getFormSlug()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public CompleteFormData getFormInformation(String organizationSlug, String billetterieSlug) {
|
||||
return this.doRequest("https://api.helloasso.com/v5/organizations/"+organizationSlug+"/forms/Event/"+billetterieSlug+"/public",CompleteFormData.class);
|
||||
}
|
||||
public List<PaymentData> listPaiements(String organizationSlug, String billetterieSlug) {
|
||||
|
||||
return this.requestList("https://api.helloasso.com/v5/organizations/"+organizationSlug+"/forms/Event/"+billetterieSlug+"/payments?pagesize="+pagesize,PaymentData.class);
|
||||
}
|
||||
public List<CompleteItemData> listItems(String organizationSlug, String billetterieSlug) {
|
||||
|
||||
return this.requestList("https://api.helloasso.com/v5/organizations/"+organizationSlug+"/forms/Event/"+billetterieSlug+"/items?pageSize="+pagesize,CompleteItemData.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,198 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CompleteFormData {
|
||||
String organisationLogo;
|
||||
String organisationName;
|
||||
List<Tiers> tiers;
|
||||
String activityType;
|
||||
int activityTypeId;
|
||||
Place place;
|
||||
String saleEndDate;
|
||||
String saleStartDate;
|
||||
OnlineImage banner;
|
||||
String currency;
|
||||
String description;
|
||||
String startDate;
|
||||
String endDate;
|
||||
OnlineImage logo;
|
||||
MetaData meta;
|
||||
String state;
|
||||
String title;
|
||||
String widgetButtonUrl;
|
||||
String widgetFullUrl;
|
||||
String widgetVignetteHorizontalUrl;
|
||||
String widgetVignetteVerticalUrl;
|
||||
String formSlug;
|
||||
String formType;
|
||||
String url;
|
||||
String organisationSlug;
|
||||
|
||||
|
||||
|
||||
public String getOrganisationLogo() {
|
||||
return organisationLogo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getOrganisationName() {
|
||||
return organisationName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Tiers> getTiers() {
|
||||
return tiers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getActivityType() {
|
||||
return activityType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getActivityTypeId() {
|
||||
return activityTypeId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSaleEndDate() {
|
||||
return saleEndDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSaleStartDate() {
|
||||
return saleStartDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public OnlineImage getBanner() {
|
||||
return banner;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public OnlineImage getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public MetaData getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getWidgetButtonUrl() {
|
||||
return widgetButtonUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getWidgetFullUrl() {
|
||||
return widgetFullUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getWidgetVignetteHorizontalUrl() {
|
||||
return widgetVignetteHorizontalUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getWidgetVignetteVerticalUrl() {
|
||||
return widgetVignetteVerticalUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getFormSlug() {
|
||||
return formSlug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getFormType() {
|
||||
return formType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getOrganisationSlug() {
|
||||
return organisationSlug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CompleteFormData [organisationLogo=" + organisationLogo + ", organisationName=" + organisationName
|
||||
+ ", tiers=" + tiers + ", activityType=" + activityType + ", activityTypeId=" + activityTypeId
|
||||
+ ", place=" + place + ", saleEndDate=" + saleEndDate + ", saleStartDate=" + saleStartDate + ", banner="
|
||||
+ banner + ", currency=" + currency + ", description=" + description + ", startDate=" + startDate
|
||||
+ ", endDate=" + endDate + ", logo=" + logo + ", meta=" + meta + ", state=" + state + ", title=" + title
|
||||
+ ", widgetButtonUrl=" + widgetButtonUrl + ", widgetFullUrl=" + widgetFullUrl
|
||||
+ ", widgetVignetteHorizontalUrl=" + widgetVignetteHorizontalUrl + ", widgetVignetteVerticalUrl="
|
||||
+ widgetVignetteVerticalUrl + ", formSlug=" + formSlug + ", formType=" + formType + ", url=" + url
|
||||
+ ", organisationSlug=" + organisationSlug + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CompleteItemData {
|
||||
|
||||
OrderData order;
|
||||
PayerData payer;
|
||||
|
||||
|
||||
List<PaymentData> payments;
|
||||
|
||||
String name;
|
||||
User user;
|
||||
|
||||
String priceCategory;
|
||||
Discount discount;
|
||||
|
||||
String tierDescription;
|
||||
int id;
|
||||
int amount;
|
||||
String type;
|
||||
int initialAmount;
|
||||
String state;
|
||||
public OrderData getOrder() {
|
||||
return order;
|
||||
}
|
||||
public PayerData getPayer() {
|
||||
return payer;
|
||||
}
|
||||
public List<PaymentData> getPayments() {
|
||||
return payments;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
public String getPriceCategory() {
|
||||
return priceCategory;
|
||||
}
|
||||
public Discount getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
public String getTierDescription() {
|
||||
return tierDescription;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public int getInitialAmount() {
|
||||
return initialAmount;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CompleteItemData [order=" + order + ", payer=" + payer + ", payments=" + payments + ", name=" + name
|
||||
+ ", user=" + user + ", priceCategory=" + priceCategory + ", discount=" + discount
|
||||
+ ", tierDescription=" + tierDescription + ", id=" + id + ", amount=" + amount + ", type=" + type
|
||||
+ ", initialAmount=" + initialAmount + ", state=" + state + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class Discount {
|
||||
String code;
|
||||
int amount;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class FormData {
|
||||
|
||||
String currency;
|
||||
String description;
|
||||
/* TODO Add this object
|
||||
"meta": {
|
||||
"createdAt": "2021-04-01T06:35:33.89+02:00",
|
||||
"updatedAt": "2021-11-21T13:53:05.627+01:00"
|
||||
}
|
||||
*/
|
||||
String state;
|
||||
String title;
|
||||
String widgetButtonUrl;
|
||||
String widgetFullUrl;
|
||||
String widgetVignetteHorizontalUrl;
|
||||
String widgetVignetteVerticalUrl;
|
||||
String formSlug;
|
||||
String formType;
|
||||
String url;
|
||||
String organizationSlug;
|
||||
|
||||
public String getFormSlug() {
|
||||
return formSlug;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class ItemData {
|
||||
int shareAmount;
|
||||
int shareItemAmount;
|
||||
int id;
|
||||
int amount;
|
||||
String type;
|
||||
String state;
|
||||
|
||||
public int getShareAmount() {
|
||||
return shareAmount;
|
||||
}
|
||||
public int getShareItemAmount() {
|
||||
return shareItemAmount;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class MetaData {
|
||||
String createdAt;
|
||||
String updatedAt;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class OnlineImage {
|
||||
String filename;
|
||||
String publicUrl;
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class OrderData {
|
||||
int id;
|
||||
String date;
|
||||
String formSlug;
|
||||
String formType;
|
||||
String organizationName;
|
||||
String organizationSlug;
|
||||
String formName;
|
||||
|
||||
MetaData meta;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getFormSlug() {
|
||||
return formSlug;
|
||||
}
|
||||
|
||||
public String getFormType() {
|
||||
return formType;
|
||||
}
|
||||
|
||||
public String getOrganizationName() {
|
||||
return organizationName;
|
||||
}
|
||||
|
||||
public String getOrganizationSlug() {
|
||||
return organizationSlug;
|
||||
}
|
||||
|
||||
public String getFormName() {
|
||||
return formName;
|
||||
}
|
||||
|
||||
public MetaData getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class PaginationData {
|
||||
int pageSize;
|
||||
int totalCount;
|
||||
int pageIndex;
|
||||
int totalPages;
|
||||
String continuationToken;
|
||||
|
||||
public int getPageIndex() {
|
||||
return pageIndex;
|
||||
}
|
||||
public int getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
public String getContinuationToken() {
|
||||
return continuationToken;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class PayerData {
|
||||
String email;
|
||||
String country;
|
||||
String firstName;
|
||||
String lastName;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaymentData {
|
||||
|
||||
OrderData order;
|
||||
PayerData payer;
|
||||
|
||||
List<ItemData> items;
|
||||
|
||||
String cashOutDate;
|
||||
String cashOutState;
|
||||
String paymentReceiptUrl;
|
||||
int id;
|
||||
int amount;
|
||||
String date;
|
||||
String paymentMeans;
|
||||
String state;
|
||||
|
||||
MetaData meta;
|
||||
|
||||
public OrderData getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public PayerData getPayer() {
|
||||
return payer;
|
||||
}
|
||||
|
||||
public List<ItemData> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public String getCashOutDate() {
|
||||
return cashOutDate;
|
||||
}
|
||||
|
||||
public String getCashOutState() {
|
||||
return cashOutState;
|
||||
}
|
||||
|
||||
public String getPaymentReceiptUrl() {
|
||||
return paymentReceiptUrl;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getPaymentMeans() {
|
||||
return paymentMeans;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public MetaData getMeta() {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class Place {
|
||||
String address;
|
||||
String name;
|
||||
String city;
|
||||
String zipCode;
|
||||
String country;
|
||||
int[] geoLocation;
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class Tiers {
|
||||
|
||||
int id;
|
||||
String label;
|
||||
String description;
|
||||
String tierType;
|
||||
int vatRate;
|
||||
int minAmount;
|
||||
String payementFrequency;
|
||||
int maxPerUser;
|
||||
boolean isEligibleTaxReceipt;
|
||||
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getTierType() {
|
||||
return tierType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getVatRate() {
|
||||
return vatRate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getMinAmount() {
|
||||
return minAmount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getPayementFrequency() {
|
||||
return payementFrequency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getMaxPerUser() {
|
||||
return maxPerUser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isEligibleTaxReceipt() {
|
||||
return isEligibleTaxReceipt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tiers [id=" + id + ", label=" + label + ", description=" + description + ", tierType=" + tierType
|
||||
+ ", vatRate=" + vatRate + ", minAmount=" + minAmount + ", payementFrequency=" + payementFrequency
|
||||
+ ", maxPerUser=" + maxPerUser + ", isEligibleTaxReceipt=" + isEligibleTaxReceipt + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.bernard.hellojasso.hellobjects;
|
||||
|
||||
public class User {
|
||||
String firstName;
|
||||
String lastName;
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.bernard.hellojasso.hellobjects.requests;
|
||||
|
||||
public class GrantCredentialsRequestData {
|
||||
|
||||
//TODO: Changer les affreux noms de ces variables
|
||||
String access_token;
|
||||
String token_type;
|
||||
int expires_in;
|
||||
String refresh_token;
|
||||
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public String getToken_type() {
|
||||
return token_type;
|
||||
}
|
||||
|
||||
public int getExpires_in() {
|
||||
return expires_in;
|
||||
}
|
||||
|
||||
public String getRefresh_token() {
|
||||
return refresh_token;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.bernard.hellojasso.hellobjects.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bernard.hellojasso.hellobjects.CompleteItemData;
|
||||
import com.bernard.hellojasso.hellobjects.PaginationData;
|
||||
|
||||
public class OrganizationFormItemsRequestData {
|
||||
|
||||
List<CompleteItemData> data;
|
||||
|
||||
PaginationData pagination;
|
||||
|
||||
public List<CompleteItemData> getData() {
|
||||
return data;
|
||||
}
|
||||
public PaginationData getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrganizationFormItemsRequestData [data=" + data + ", pagination=" + pagination + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.bernard.hellojasso.hellobjects.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bernard.hellojasso.hellobjects.PaginationData;
|
||||
import com.bernard.hellojasso.hellobjects.PaymentData;
|
||||
|
||||
public class OrganizationFormPaymentsRequestData {
|
||||
|
||||
|
||||
List<PaymentData> data;
|
||||
|
||||
PaginationData pagination;
|
||||
|
||||
public List<PaymentData> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public PaginationData getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.bernard.hellojasso.hellobjects.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bernard.hellojasso.hellobjects.FormData;
|
||||
import com.bernard.hellojasso.hellobjects.PaginationData;
|
||||
|
||||
public class OrganizationFormsRequestData {
|
||||
|
||||
List<FormData> data;
|
||||
|
||||
PaginationData pagination;
|
||||
|
||||
public List<FormData> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.bernard.hellojasso.hellobjects.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bernard.hellojasso.hellobjects.PaginationData;
|
||||
|
||||
public class PaginatedListRequestData <T> {
|
||||
|
||||
List<T> data;
|
||||
|
||||
PaginationData pagination;
|
||||
|
||||
public List<T> getData() {
|
||||
return data;
|
||||
}
|
||||
public PaginationData getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
}
|
||||
8
lib/src/main/java/module-info.java
Normal file
8
lib/src/main/java/module-info.java
Normal file
@ -0,0 +1,8 @@
|
||||
module com.bernard.hellojasso {
|
||||
|
||||
exports com.bernard.hellojasso;
|
||||
exports com.bernard.hellojasso.hellobjects;
|
||||
|
||||
requires com.google.gson;
|
||||
requires org.apache.logging.log4j;
|
||||
}
|
||||
33
lib/src/test/java/hellojasso/LibraryTest.java
Normal file
33
lib/src/test/java/hellojasso/LibraryTest.java
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package hellojasso;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.bernard.hellojasso.HelloAssoConnection;
|
||||
|
||||
public class LibraryTest {
|
||||
@Test public void testConnection() throws IOException {
|
||||
|
||||
String asso = "enverts";
|
||||
File haCredentialsFile = new File("/home/mysaa/Documents/Assos/ENvertS/helloasso_client_credentials");
|
||||
|
||||
HelloAssoConnection hcon = HelloAssoConnection.makeConnection(haCredentialsFile);
|
||||
|
||||
List<String> billetteries = hcon.listBilletteriesSlugs(asso);
|
||||
|
||||
String billetterie = billetteries.get(2);
|
||||
System.out.println("On cherche dans la billetterie "+billetterie);
|
||||
|
||||
hcon.listPaiements(asso, billetterie);
|
||||
|
||||
hcon.listItems(asso, billetterie);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
settings.gradle
Normal file
11
settings.gradle
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
*
|
||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
||||
* in the user manual at https://docs.gradle.org/7.3.3/userguide/multi_project_builds.html
|
||||
*/
|
||||
|
||||
rootProject.name = 'HelloJasso'
|
||||
include('lib')
|
||||
Loading…
x
Reference in New Issue
Block a user