Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate code for release #74

Merged
merged 3 commits into from
Mar 14, 2018
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
12 changes: 11 additions & 1 deletion src/main/java/com/bunq/sdk/examples/CardDebitExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.bunq.sdk.context.ApiContext;
import com.bunq.sdk.model.generated.endpoint.CardDebit;
import com.bunq.sdk.model.generated.object.CardPinAssignment;
import com.bunq.sdk.model.generated.object.Pointer;

import java.io.IOException;
import java.math.BigInteger;
import java.security.SecureRandom;
Expand All @@ -20,19 +22,27 @@ public class CardDebitExample {
private static final String EMAIL_YOUR_COMPANY = "[email protected]"; // Put your user email here
private static final String POINTER_NAME_TEST = "test pointer";
private static final int USER_ITEM_ID = 0; // Put your user ID here
private static final int MONETARY_ACCOUNT_ID = 0; // Put your monetary account ID here
private static final int NUM_BITS_20_DECIMAL_DIGITS = 66;
private static final int RADIX_DIGITS_AND_LATIN_LETTERS = 36;
private static final String CARD_PIN_ASSIGNMENT_TYPE_PRIMARY = "PRIMARY";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this is not an enum? Or is that impossible to generate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating ENUMs is also on the list. But its kind of impossible however. Will PM you the details.


/**
* @param args Command line arguments.
*/
public static void main(String[] args) throws IOException {
ApiContext apiContext = ApiContext.restore(API_CONTEXT_FILE_PATH);

CardPinAssignment cardPinAssignment = new CardPinAssignment(
CARD_PIN_ASSIGNMENT_TYPE_PRIMARY,
PIN_CODE,
MONETARY_ACCOUNT_ID
);

HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put(CardDebit.FIELD_NAME_ON_CARD, NAME_YOUR_COMPANY);
requestMap.put(CardDebit.FIELD_SECOND_LINE, generateRandomSecondLine());
requestMap.put(CardDebit.FIELD_PIN_CODE, PIN_CODE);
requestMap.put(CardDebit.FIELD_PIN_CODE_ASSIGNMENT, new CardPinAssignment[]{cardPinAssignment});
Pointer pointer = new Pointer(POINTER_TYPE_EMAIL, EMAIL_YOUR_COMPANY);
pointer.setName(POINTER_NAME_TEST);
requestMap.put(CardDebit.FIELD_ALIAS, pointer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class CardDebit extends BunqModel {
*/
public static final String FIELD_SECOND_LINE = "second_line";
public static final String FIELD_NAME_ON_CARD = "name_on_card";
public static final String FIELD_PIN_CODE = "pin_code";
public static final String FIELD_ALIAS = "alias";
public static final String FIELD_TYPE = "type";
public static final String FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class IdealMerchantTransaction extends BunqModel {
*/
public static final String FIELD_AMOUNT_REQUESTED = "amount_requested";
public static final String FIELD_ISSUER = "issuer";
public static final String FIELD_CALLBACK_TYPE = "callback_type";

/**
* Object type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ public class MasterCardAction extends BunqModel {
@SerializedName("eligible_whitelist_id")
private Integer eligibleWhitelistId;

/**
* The secure code id for this mastercard action or null.
*/
@Expose
@SerializedName("secure_code_id")
private Integer secureCodeId;

public static BunqResponse<MasterCardAction> get(ApiContext apiContext, Integer userId, Integer monetaryAccountId, Integer masterCardActionId) {
return get(apiContext, userId, monetaryAccountId, masterCardActionId, new HashMap<>());
}
Expand Down Expand Up @@ -499,6 +506,17 @@ public void setEligibleWhitelistId(Integer eligibleWhitelistId) {
this.eligibleWhitelistId = eligibleWhitelistId;
}

/**
* The secure code id for this mastercard action or null.
*/
public Integer getSecureCodeId() {
return this.secureCodeId;
}

public void setSecureCodeId(Integer secureCodeId) {
this.secureCodeId = secureCodeId;
}

/**
*/
public boolean isAllFieldNull() {
Expand Down Expand Up @@ -598,6 +616,10 @@ public boolean isAllFieldNull() {
return false;
}

if (this.secureCodeId != null) {
return false;
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public class RequestResponse extends BunqModel {
private Geolocation geolocation;

/**
* The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL or INTERNAL.
* The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL, SOFORT or
* INTERNAL.
*/
@Expose
@SerializedName("type")
Expand Down Expand Up @@ -458,7 +459,8 @@ public void setGeolocation(Geolocation geolocation) {
}

/**
* The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL or INTERNAL.
* The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL, SOFORT or
* INTERNAL.
*/
public String getType() {
return this.type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.bunq.sdk.model.generated.endpoint;

import com.bunq.sdk.context.ApiContext;
import com.bunq.sdk.http.ApiClient;
import com.bunq.sdk.http.BunqResponse;
import com.bunq.sdk.http.BunqResponseRaw;
import com.bunq.sdk.model.core.BunqModel;
import com.bunq.sdk.model.core.MonetaryAccountReference;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.lang.model.type.NullType;

/**
* Using this call you can create a SOFORT Request assigned to your User by providing the Token
* of the request.
*/
public class TokenQrRequestSofort extends BunqModel {

/**
* Endpoint constants.
*/
private static final String ENDPOINT_URL_CREATE = "user/%s/token-qr-request-sofort";

/**
* Field constants.
*/
public static final String FIELD_TOKEN = "token";

/**
* Object type.
*/
private static final String OBJECT_TYPE_POST = "RequestResponse";

public static BunqResponse<TokenQrRequestSofort> create(ApiContext apiContext, Map<String, Object> requestMap, Integer userId) {
return create(apiContext, requestMap, userId, new HashMap<>());
}

/**
* Create a request from an SOFORT transaction.
*/
public static BunqResponse<TokenQrRequestSofort> create(ApiContext apiContext, Map<String, Object> requestMap, Integer userId, Map<String, String> customHeaders) {
ApiClient apiClient = new ApiClient(apiContext);
byte[] requestBytes = gson.toJson(requestMap).getBytes();
BunqResponseRaw responseRaw = apiClient.post(String.format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders);

return fromJson(TokenQrRequestSofort.class, responseRaw, OBJECT_TYPE_POST);
}

/**
*/
public boolean isAllFieldNull() {
return true;
}

/**
*/
public static TokenQrRequestSofort fromJsonReader(JsonReader reader) {
return fromJsonReader(TokenQrRequestSofort.class, reader);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.bunq.sdk.model.generated.object.Address;
import com.bunq.sdk.model.generated.object.Amount;
import com.bunq.sdk.model.generated.object.Avatar;
import com.bunq.sdk.model.generated.object.BunqId;
import com.bunq.sdk.model.generated.object.CardLimit;
import com.bunq.sdk.model.generated.object.LabelUser;
import com.bunq.sdk.model.generated.object.NotificationFilter;
import com.bunq.sdk.model.generated.object.Pointer;
Expand Down Expand Up @@ -233,6 +235,20 @@ public class UserCompany extends BunqModel {
@SerializedName("session_timeout")
private Integer sessionTimeout;

/**
* Card ids used for centralized card limits.
*/
@Expose
@SerializedName("card_ids")
private List<BunqId> cardIds;

/**
* The centralized limits for user's cards.
*/
@Expose
@SerializedName("card_limits")
private List<CardLimit> cardLimits;

/**
* The amount the company can pay in the session without asking for credentials.
*/
Expand Down Expand Up @@ -565,6 +581,28 @@ public void setSessionTimeout(Integer sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}

/**
* Card ids used for centralized card limits.
*/
public List<BunqId> getCardIds() {
return this.cardIds;
}

public void setCardIds(List<BunqId> cardIds) {
this.cardIds = cardIds;
}

/**
* The centralized limits for user's cards.
*/
public List<CardLimit> getCardLimits() {
return this.cardLimits;
}

public void setCardLimits(List<CardLimit> cardLimits) {
this.cardLimits = cardLimits;
}

/**
* The amount the company can pay in the session without asking for credentials.
*/
Expand Down Expand Up @@ -720,6 +758,14 @@ public boolean isAllFieldNull() {
return false;
}

if (this.cardIds != null) {
return false;
}

if (this.cardLimits != null) {
return false;
}

if (this.dailyLimitWithoutConfirmationLogin != null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class UserPerson extends BunqModel {
public static final String FIELD_SUB_STATUS = "sub_status";
public static final String FIELD_LEGAL_GUARDIAN_ALIAS = "legal_guardian_alias";
public static final String FIELD_SESSION_TIMEOUT = "session_timeout";
public static final String FIELD_CARD_IDS = "card_ids";
public static final String FIELD_CARD_LIMITS = "card_limits";
public static final String FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login";
public static final String FIELD_COUNTER_BANK_IBAN = "counter_bank_iban";
public static final String FIELD_NOTIFICATION_FILTERS = "notification_filters";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public class CardPinAssignment extends BunqModel {
*/
@Expose
@SerializedName("monetary_account_id")
private String monetaryAccountId;
private Integer monetaryAccountId;

public CardPinAssignment(String type) {
public CardPinAssignment(String type, String pinCode, Integer monetaryAccountId) {
this.type = type;
this.pinCode = pinCode;
this.monetaryAccountId = monetaryAccountId;
}

/**
Expand All @@ -54,11 +56,11 @@ public void setType(String type) {
/**
* The ID of the monetary account to assign to this pin for the card.
*/
public String getMonetaryAccountId() {
public Integer getMonetaryAccountId() {
return this.monetaryAccountId;
}

public void setMonetaryAccountId(String monetaryAccountId) {
public void setMonetaryAccountId(Integer monetaryAccountId) {
this.monetaryAccountId = monetaryAccountId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.bunq.sdk.BunqSdkTestBase;
import com.bunq.sdk.Config;
import com.bunq.sdk.context.ApiContext;
import com.bunq.sdk.model.generated.object.CardPinAssignment;
import com.bunq.sdk.model.generated.object.Pointer;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class CardDebitTest extends BunqSdkTestBase {
private static final int RADIX_DIGITS_AND_LATIN_LETTERS = 36;
private static final int NUM_BITS_23_DECIMAL_DIGITS = 76;
private static final int FIRST_INDEX = 0;
private static final String CARD_PIN_ASSIGNMENT_TYPE_PRIMARY = "PRIMARY";

/**
* The name that is going to be shown on the card
Expand Down Expand Up @@ -70,10 +72,16 @@ private static String generateRandomSecondLine() {
public void orderNewMaestroCardTest() throws Exception {
String secondLine = generateRandomSecondLine();

CardPinAssignment cardPinAssignment = new CardPinAssignment(
CARD_PIN_ASSIGNMENT_TYPE_PRIMARY,
PIN_CODE,
Config.getMonetaryAccountId()
);

HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put(CardDebit.FIELD_SECOND_LINE, secondLine);
requestMap.put(CardDebit.FIELD_NAME_ON_CARD, nameOnCard);
requestMap.put(CardDebit.FIELD_PIN_CODE, PIN_CODE);
requestMap.put(CardDebit.FIELD_PIN_CODE_ASSIGNMENT, new CardPinAssignment[]{cardPinAssignment});
requestMap.put(CardDebit.FIELD_ALIAS, alias);
CardDebit cardDebit = CardDebit.create(apiContext, requestMap, userId).getValue();

Expand Down