-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bcf619
commit 06b5366
Showing
32 changed files
with
1,008 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/mercadopago/client/order/OrderCategoryDescriptorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderCategoryDescriptorRequest class. */ | ||
@Getter | ||
public class OrderCategoryDescriptorRequest { | ||
|
||
/** Event date. */ | ||
private String eventDate; | ||
|
||
/** Passenger information. */ | ||
private OrderPassengerRequest passenger; | ||
|
||
/** Route information. */ | ||
private OrderRouteRequest route; | ||
} | ||
|
80 changes: 80 additions & 0 deletions
80
src/main/java/com/mercadopago/client/order/OrderClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import com.mercadopago.MercadoPagoConfig; | ||
import com.mercadopago.client.MercadoPagoClient; | ||
import com.mercadopago.core.MPRequestOptions; | ||
import com.mercadopago.exceptions.MPApiException; | ||
import com.mercadopago.exceptions.MPException; | ||
import com.mercadopago.net.HttpMethod; | ||
import com.mercadopago.net.MPHttpClient; | ||
import com.mercadopago.net.MPRequest; | ||
import com.mercadopago.net.MPResponse; | ||
import com.mercadopago.resources.order.Order; | ||
import com.mercadopago.serialization.Serializer; | ||
|
||
import java.util.logging.Logger; | ||
import java.util.logging.StreamHandler; | ||
|
||
import static com.mercadopago.MercadoPagoConfig.getStreamHandler; | ||
|
||
/** Client that use the Order API */ | ||
public class OrderClient extends MercadoPagoClient { | ||
private static final Logger LOGGER = Logger.getLogger(OrderClient.class.getName()); | ||
|
||
/** Default constructor. Uses the default http client used by the SDK. */ | ||
public OrderClient() { | ||
this(MercadoPagoConfig.getHttpClient()); | ||
} | ||
|
||
/** | ||
* MercadoPagoClient constructor. | ||
* | ||
* @param httpClient http client | ||
*/ | ||
public OrderClient(MPHttpClient httpClient) { | ||
super(httpClient); | ||
StreamHandler streamHandler = getStreamHandler(); | ||
streamHandler.setLevel(MercadoPagoConfig.getLoggingLevel()); | ||
LOGGER.addHandler(streamHandler); | ||
LOGGER.setLevel(MercadoPagoConfig.getLoggingLevel()); | ||
} | ||
|
||
/** | ||
* Method responsible for creating order with request options | ||
* | ||
* @param request request | ||
* @param requestOptions metadata to customize the request | ||
* @return order response | ||
* @throws MPException an error if the request fails | ||
* @throws MPApiException an error if the request fails | ||
*/ | ||
public Order create(OrderCreateRequest request, MPRequestOptions requestOptions) | ||
throws MPException, MPApiException { | ||
LOGGER.info("Sending order creation request"); | ||
|
||
MPRequest mpRequest = MPRequest.builder() | ||
.uri("/v1/orders") | ||
.method(HttpMethod.POST) | ||
.payload(Serializer.serializeToJson(request)) | ||
.build(); | ||
|
||
MPResponse response = send(mpRequest, requestOptions); | ||
Order result = Serializer.deserializeFromJson(Order.class, response.getContent()); | ||
result.setResponse(response); | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* Method responsible for creating order with request options | ||
* | ||
* @param request request | ||
* @return order response | ||
* @throws MPException an error if the request fails | ||
* @throws MPApiException an error if the request fails | ||
*/ | ||
public Order create(OrderCreateRequest request) throws MPException, MPApiException { | ||
return this.create(request, null); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/mercadopago/client/order/OrderCouponRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderCouponRequest class. */ | ||
@Getter | ||
public class OrderCouponRequest { | ||
/** Coupon code. */ | ||
private String code; | ||
|
||
/** Amount of the coupon discount. */ | ||
private String amount; | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/mercadopago/client/order/OrderCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import com.mercadopago.net.MPResource; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
/** Order class. */ | ||
@Builder | ||
@Getter | ||
public class OrderCreateRequest extends MPResource { | ||
/** Order type. */ | ||
private String type; | ||
|
||
/** Total amount of the order. */ | ||
private String totalAmount; | ||
|
||
/** Reference you can synchronize with your payment system. */ | ||
private String externalReference; | ||
|
||
/** Order type configuration. */ | ||
private OrderTypeConfigRequest typeConfig; | ||
|
||
/** Order transaction information. */ | ||
private OrderTransactionRequest transactions; | ||
|
||
/** Currency information. */ | ||
private String currency; | ||
|
||
/** Configures which processing modes to use. */ | ||
private String processingMode; | ||
|
||
/** Description of the order. */ | ||
private String description; | ||
|
||
/** Payer's information. */ | ||
private OrderPayerRequest payer; | ||
|
||
/** Origin of the payment. */ | ||
private String marketplace; | ||
|
||
/** Fee collected by a marketplace or MercadoPago Application. */ | ||
private String marketplaceFee; | ||
|
||
/** Discount campaign ID. */ | ||
private String campaignId; | ||
|
||
/** Items information. */ | ||
private List<OrderItemRequest> items; | ||
|
||
/** Coupon information. */ | ||
private OrderCouponRequest coupon; | ||
|
||
/** Information's about split payments. */ | ||
private List<OrderSplitRequest> splits; | ||
|
||
/** Shipping information. */ | ||
private OrderShipmentRequest shipment; | ||
|
||
/** Expiration time of the order. */ | ||
private String expirationTime; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/mercadopago/client/order/OrderItemRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderItemRequest class. */ | ||
@Getter | ||
public class OrderItemRequest { | ||
|
||
/** Title of the item. */ | ||
private String title; | ||
|
||
/** Unit price of the item. */ | ||
private String unitPrice; | ||
|
||
/** Quantity of the item. */ | ||
private int quantity; | ||
|
||
/** Description of the item. */ | ||
private String description; | ||
|
||
/** Code of the item. */ | ||
private String code; | ||
|
||
/** Type of the item. */ | ||
private String type; | ||
|
||
/** Picture URL of the item. */ | ||
private String pictureUrl; | ||
|
||
/** True if you purchase the item with warranty, false if not. */ | ||
private Boolean warranty; | ||
|
||
/** Category Descriptor information */ | ||
private OrderCategoryDescriptorRequest categoryDescriptor; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/mercadopago/client/order/OrderPassengerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderPassengerRequest class. */ | ||
@Getter | ||
public class OrderPassengerRequest { | ||
|
||
/** Passenger first name. */ | ||
private String firstName; | ||
|
||
/** Passenger last name. */ | ||
private String lastName; | ||
|
||
/** Passenger identification type. */ | ||
private String identificationType; | ||
|
||
/** Passenger identification number. */ | ||
private String identificationNumber; | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/mercadopago/client/order/OrderPayerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import com.mercadopago.resources.common.Address; | ||
import com.mercadopago.resources.common.Identification; | ||
import com.mercadopago.resources.common.Phone; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
/** OrderPayerRequest class. */ | ||
@Getter | ||
@Builder | ||
public class OrderPayerRequest { | ||
|
||
/** Payer's email. */ | ||
private String email; | ||
|
||
/** Payer's first name. */ | ||
private String firstName; | ||
|
||
/** Payer's last name. */ | ||
private String lastName; | ||
|
||
/** Identification information. */ | ||
private Identification identification; | ||
|
||
/** Phone information. */ | ||
private Phone phone; | ||
|
||
/** Address information. */ | ||
private Address address; | ||
|
||
/** Type of authentication. */ | ||
private String authenticationType; | ||
|
||
/** Date of registration. */ | ||
private String registrationDate; | ||
|
||
/** Date of last purchase. */ | ||
private String lastPurchase; | ||
|
||
/** If payer is prime user. */ | ||
private Boolean isPrimeUser; | ||
|
||
/** If is first online purchase. */ | ||
private Boolean isFirstPurchaseOnline; | ||
|
||
/** Payer's entity type. */ | ||
private String entityType; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/mercadopago/client/order/OrderPaymentMethodRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
/** OrderPaymentMethodCreateRequest class. */ | ||
@Getter | ||
@Builder | ||
public class OrderPaymentMethodRequest { | ||
|
||
/** Payment method ID. */ | ||
private String id; | ||
|
||
/** Payment method type. */ | ||
private String type; | ||
|
||
/** Payment method token. */ | ||
private String token; | ||
|
||
/** Number of installments. */ | ||
private int installments; | ||
|
||
/** Payment method issuer. */ | ||
private String issuerId; | ||
|
||
/** How will look the payment in the card bill (e.g.: MERCADOPAGO). */ | ||
private String statementDescriptor; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/mercadopago/client/order/OrderPaymentRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
/** OrderPaymentCreateRequest class. */ | ||
@Getter | ||
@Builder | ||
public class OrderPaymentRequest { | ||
|
||
/** Payment amount. */ | ||
private String amount; | ||
|
||
/** Payment currency. */ | ||
private String currency; | ||
|
||
/** Payment method information. */ | ||
private OrderPaymentMethodRequest paymentMethod; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/mercadopago/client/order/OrderReceiverAddressRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderReceiverAddressRequest class. */ | ||
@Getter | ||
public class OrderReceiverAddressRequest { | ||
|
||
/** Street name. */ | ||
private String streetName; | ||
|
||
/** Street number. */ | ||
private String streetNumber; | ||
|
||
/** Zip code. */ | ||
private String zipCode; | ||
|
||
/** City name. */ | ||
private String cityName; | ||
|
||
/** State name. */ | ||
private String stateName; | ||
|
||
/** Floor. */ | ||
private String floor; | ||
|
||
/** Apartment. */ | ||
private String apartment; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/mercadopago/client/order/OrderRouteRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mercadopago.client.order; | ||
|
||
import lombok.Getter; | ||
|
||
/** OrderRouteRequest class. */ | ||
@Getter | ||
public class OrderRouteRequest { | ||
|
||
/** Departure city. */ | ||
private String departure; | ||
|
||
/** Destination city. */ | ||
private String destination; | ||
|
||
/** Departure date and time. */ | ||
private String departureDateTime; | ||
|
||
/** Arrival date and time. */ | ||
private String arrivalDateTime; | ||
|
||
/** Company name. */ | ||
private String company; | ||
} |
Oops, something went wrong.