-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLinkCard.java
More file actions
70 lines (58 loc) · 2.23 KB
/
Copy pathLinkCard.java
File metadata and controls
70 lines (58 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.bunq.tinker;
import com.bunq.sdk.context.ApiEnvironmentType;
import com.bunq.sdk.model.generated.endpoint.Card;
import com.bunq.sdk.model.generated.object.CardPinAssignment;
import com.bunq.tinker.libs.BunqLib;
import com.bunq.tinker.libs.SharedLib;
import com.bunq.tinker.utils.ITinker;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import java.util.ArrayList;
public class LinkCard implements ITinker {
/**
* Input constants.
*/
private static final String CARD_PIN_ASSIGNMENT_TYPE_PRIMARY = "PRIMARY";
/**
* @param args
*
* @throws ParseException
*/
public void run(String[] args) throws ParseException {
CommandLine allOption = SharedLib.parseAllOption(args);
ApiEnvironmentType environmentType = SharedLib.determineEnvironmentType(allOption);
ArrayList<CardPinAssignment> allCardPinAssignment = new ArrayList<>();
SharedLib.printHeader();
BunqLib bunq = new BunqLib(environmentType);
String cardId = SharedLib.determineCardIdFromAllOptionOrStdIn(allOption);
String accountId = SharedLib.determineAccountIdFromAllOptionOrStdIn(allOption);
allCardPinAssignment.add(new CardPinAssignment(
CARD_PIN_ASSIGNMENT_TYPE_PRIMARY,
null, /* pinCode */
Integer.parseInt(accountId))
);
System.out.println();
System.out.println(" | Link Card: " + cardId);
System.out.println(" | To Account: " + accountId);
System.out.println();
System.out.println(" ...");
System.out.println();
Card.update(
Integer.parseInt(cardId),
null, /* pinCode */
null, /* activationCode */
null, /* status */
null, /* cardLimit */
null, /* cardLimitAtm */
null, /* magStripePermissions */
allCardPinAssignment
);
System.out.println();
System.out.println(" | ✅ Account switched");
System.out.println();
System.out.println(" | ▶️ Check your changed overview");
System.out.println();
System.out.println();
bunq.updateContext();
}
}