Skip to content

Commit

Permalink
Agregado: Cancelación por uuid, cancelación por pfx, validación xml, …
Browse files Browse the repository at this point in the history
…validación lrfc, validación lco, generación de pdf

Fix: cambiadas solicitudes de unirest por apache.
  • Loading branch information
JuanGamezSW committed Aug 6, 2018
1 parent 4c3644d commit ad0a117
Show file tree
Hide file tree
Showing 41 changed files with 1,380 additions and 249 deletions.
34 changes: 34 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SW-JAVA</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
38 changes: 22 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>mx.com.sw.services</groupId>
<artifactId>SW-JAVA</artifactId>
<version>0.0.3.4</version>

<packaging>jar</packaging>

<scm>
<url>https://github.com/lunasoft/sw-sdk-java</url>
<connection>scm:git:git@github.com:lunasoft/sw-sdk-java.git</connection>
<developerConnection>scm:git:git@github.com:lunasoft/sw-sdk-java.git</developerConnection>

</scm>
<licenses>
<license>
Expand Down Expand Up @@ -95,6 +89,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<version>1.6</version>
<executions>
<execution>
Expand All @@ -106,7 +103,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -118,7 +114,6 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

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

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -158,9 +152,24 @@
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.github.bingoohuang</groupId>
<artifactId>unirest-java</artifactId>
<version>0.0.1</version>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
Expand All @@ -172,8 +181,5 @@
<artifactId>org.apache.servicemix.bundles.not-yet-commons-ssl</artifactId>
<version>0.3.11_1</version>
</dependency>

</dependencies>


</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Services.Authentication;

import java.io.IOException;

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Services.SWService;
Expand All @@ -13,7 +15,7 @@ public SWAuthenticationService(String user, String password, String URI) {
}


public IResponse Token() throws GeneralException, AuthException {
public IResponse Token() throws GeneralException, AuthException, IOException {
AuthOptionsRequest settings = new AuthOptionsRequest(getURI(),getUser(),getPassword());


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package Services.BalanceAccount;

import java.io.IOException;

//@author: Lupita Alvarado

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Services.SWService;
import Utils.Constants;
import Utils.Requests.Authentication.AuthOptionsRequest;
import Utils.Requests.Authentication.AuthRequest;
import Utils.Requests.BalanceAccount.BalanceAcctOptionsRequest;
import Utils.Requests.BalanceAccount.BalanceAcctRequest;
import Utils.Responses.IResponse;
Expand All @@ -23,7 +22,7 @@ public SWBalanceAccountService(String token, String URI) {
super(token, URI);
}

public IResponse GetBalanceAccount() throws AuthException, GeneralException {
public IResponse GetBalanceAccount() throws AuthException, GeneralException, IOException {

if (getToken()==null){

Expand Down
39 changes: 34 additions & 5 deletions src/main/java/Services/Cancelation/SWCancelationService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package Services.Cancelation;

import java.io.IOException;

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Services.SWService;
import Utils.Constants;
import Utils.Requests.Authentication.AuthOptionsRequest;
import Utils.Requests.Authentication.AuthRequest;
import Utils.Requests.Cancelation.CancelationOptionsRequest;
import Utils.Requests.Cancelation.CancelationRequest;
import Utils.Responses.IResponse;
Expand All @@ -23,7 +22,7 @@ public SWCancelationService(String token, String URI) {
}


public IResponse Cancelation(String uuid, String password_csd, String rfc, String b64Cer, String b64Key) throws AuthException, GeneralException {
public IResponse Cancelation(String uuid, String password_csd, String rfc, String b64Cer, String b64Key) throws AuthException, GeneralException, IOException {

if (getToken()==null){
generateToken();
Expand All @@ -38,7 +37,7 @@ public IResponse Cancelation(String uuid, String password_csd, String rfc, Strin

}

public IResponse Cancelation(String xml) throws AuthException, GeneralException {
public IResponse Cancelation(String xml) throws AuthException, GeneralException, IOException {

if (getToken()==null){
generateToken();
Expand All @@ -53,4 +52,34 @@ public IResponse Cancelation(String xml) throws AuthException, GeneralException

}

public IResponse Cancelation(String uuid, String password_csd, String rfc, String b64Pfx) throws AuthException, GeneralException, IOException {

if (getToken()==null){
generateToken();
}

//MAKE CANCELATION PROCESS, CUSTOMER ALREADY HAS TOKEN

CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),uuid, password_csd, rfc, b64Pfx);

CancelationRequest req = new CancelationRequest();
return req.sendRequestPfx(settings);

}

public IResponse Cancelation(String uuid, String rfc) throws AuthException, GeneralException, IOException {

if (getToken()==null){
generateToken();
}

//MAKE CANCELATION PROCESS, CUSTOMER ALREADY HAS TOKEN

CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),uuid, rfc);

CancelationRequest req = new CancelationRequest();
return req.sendRequestUuid(settings);

}

}
49 changes: 49 additions & 0 deletions src/main/java/Services/Pdf/SWPdfService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package Services.Pdf;

import java.io.IOException;

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Services.SWService;
import Utils.Requests.Pdf.PdfOptionsRequest;
import Utils.Requests.Pdf.PdfRequest;
import Utils.Responses.IResponse;


public class SWPdfService extends SWService {

public SWPdfService(String user, String password, String URI) {
super(user, password, URI);
}

public SWPdfService(String token, String URI) {
super(token, URI);
}

public IResponse GeneratePdf(String xml) throws AuthException, GeneralException, IOException {
if (getToken()==null){
generateToken();
}
PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml);
PdfRequest req = new PdfRequest();
return req.sendRequest(settings);
}

public IResponse GeneratePdf(String xml, String extras) throws AuthException, GeneralException, IOException {
if (getToken()==null){
generateToken();
}
PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras);
PdfRequest req = new PdfRequest();
return req.sendRequest(settings);
}

public IResponse GeneratePdf(String xml, String extras, String templateId) throws AuthException, GeneralException, IOException {
if (getToken()==null){
generateToken();
}
PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras, templateId);
PdfRequest req = new PdfRequest();
return req.sendRequest(settings);
}
}
6 changes: 3 additions & 3 deletions src/main/java/Services/SWService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package Services;

import java.io.IOException;

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Utils.Constants;
import Utils.Requests.Authentication.AuthOptionsRequest;
import Utils.Requests.Authentication.AuthRequest;
import Utils.Responses.IResponse;
import Utils.Responses.SuccessAuthResponse;

public abstract class SWService {
Expand Down Expand Up @@ -55,7 +55,7 @@ public void setPassword(String password) {
Password = password;
}

public void generateToken() throws AuthException, GeneralException {
public void generateToken() throws AuthException, GeneralException, IOException {

if (User == null || Password == null) {
//CUSTOMER HASN'T TOKEN, USER AND PASSWORD--> WE CANT' DO ANYTHING --> THROW EXCEPTION
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Services/Stamp/SWStampService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Utils.Responses.IResponse;


import java.io.IOException;
import java.nio.charset.Charset;


Expand All @@ -23,7 +23,7 @@ public SWStampService(String token, String URI) {
super(token, URI);
}

public IResponse Stamp(String xml, String version) throws AuthException, GeneralException {
public IResponse Stamp(String xml, String version) throws AuthException, GeneralException, IOException {



Expand All @@ -40,7 +40,7 @@ public IResponse Stamp(String xml, String version) throws AuthException, General
}
//

public IResponse Stamp(String xml, String version, boolean isb64) throws AuthException, GeneralException {
public IResponse Stamp(String xml, String version, boolean isb64) throws AuthException, GeneralException, IOException {



Expand All @@ -64,7 +64,7 @@ public IResponse Stamp(String xml, String version, boolean isb64) throws AuthExc


}
public IResponse Stamp(byte[] xmlFile, String version, boolean isb64) throws AuthException, GeneralException {
public IResponse Stamp(byte[] xmlFile, String version, boolean isb64) throws AuthException, GeneralException, IOException{
//BINARY XML


Expand All @@ -86,7 +86,7 @@ public IResponse Stamp(byte[] xmlFile, String version, boolean isb64) throws Aut

}

public IResponse Stamp(byte[] xmlFile, String version) throws AuthException, GeneralException {
public IResponse Stamp(byte[] xmlFile, String version) throws AuthException, GeneralException, IOException {
//BINARY XML


Expand Down
Loading

0 comments on commit ad0a117

Please sign in to comment.