Skip to content

Commit c79e2fc

Browse files
authored
Add support for trustee transfers (#246)
1 parent f27d4d0 commit c79e2fc

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

src/main/java/com/dnsimple/data/DomainTransfer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ public class DomainTransfer {
77
private final String state;
88
private final boolean autoRenew;
99
private final boolean whoisPrivacy;
10+
private final boolean trusteeService;
1011
private final String statusDescription;
1112
private final String createdAt;
1213
private final String updatedAt;
1314

14-
public DomainTransfer(Integer id, Integer domainId, Integer registrantId, String state, boolean autoRenew, boolean whoisPrivacy, String statusDescription, String createdAt, String updatedAt) {
15+
public DomainTransfer(Integer id, Integer domainId, Integer registrantId, String state, boolean autoRenew, boolean whoisPrivacy, boolean trusteeService, String statusDescription, String createdAt, String updatedAt) {
1516
this.id = id;
1617
this.domainId = domainId;
1718
this.registrantId = registrantId;
1819
this.state = state;
1920
this.autoRenew = autoRenew;
2021
this.whoisPrivacy = whoisPrivacy;
22+
this.trusteeService = trusteeService;
2123
this.statusDescription = statusDescription;
2224
this.createdAt = createdAt;
2325
this.updatedAt = updatedAt;
@@ -47,6 +49,10 @@ public boolean hasWhoisPrivacy() {
4749
return whoisPrivacy;
4850
}
4951

52+
public boolean hasTrusteeService() {
53+
return trusteeService;
54+
}
55+
5056
public String getStatusDescription() {
5157
return statusDescription;
5258
}

src/main/java/com/dnsimple/request/TransferOptions.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,44 @@ public class TransferOptions {
1212
private final Boolean autoRenew;
1313
private final Map<String, String> extendedAttributes;
1414
private final String premiumPrice;
15+
private final Boolean trusteeService;
1516

16-
private TransferOptions(Long registrantId, String authCode, Boolean whoisPrivacy, Boolean autoRenew, Map<String, String> extendedAttributes, String premiumPrice) {
17+
private TransferOptions(Long registrantId, String authCode, Boolean whoisPrivacy, Boolean autoRenew, Map<String, String> extendedAttributes, String premiumPrice, Boolean trusteeService) {
1718
this.registrantId = registrantId;
1819
this.authCode = authCode;
1920
this.whoisPrivacy = whoisPrivacy;
2021
this.autoRenew = autoRenew;
2122
this.extendedAttributes = extendedAttributes;
2223
this.premiumPrice = premiumPrice;
24+
this.trusteeService = trusteeService;
2325
}
2426

2527
/**
2628
* @param registrantId The ID of an existing contact in your account.
2729
*/
2830
public static TransferOptions of(Number registrantId) {
29-
return new TransferOptions(registrantId.longValue(), null, false, true, emptyMap(), null);
31+
return new TransferOptions(registrantId.longValue(), null, false, true, emptyMap(), null, null);
3032
}
3133

3234
/**
3335
* Set the authCode required for TLDS that require authorization-based transfer (the vast majority of TLDs).
3436
*/
3537
public TransferOptions authCode(String authCode) {
36-
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, extendedAttributes, premiumPrice);
38+
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, extendedAttributes, premiumPrice, trusteeService);
3739
}
3840

3941
/**
4042
* Enable the whois privacy as part of the transfer. An extra cost may apply.
4143
*/
4244
public TransferOptions whoisPrivacy() {
43-
return new TransferOptions(registrantId, authCode, true, autoRenew, extendedAttributes, premiumPrice);
45+
return new TransferOptions(registrantId, authCode, true, autoRenew, extendedAttributes, premiumPrice, trusteeService);
4446
}
4547

4648
/**
4749
* Disable the auto-renewal of the domain.
4850
*/
4951
public TransferOptions noAutoRenew() {
50-
return new TransferOptions(registrantId, authCode, whoisPrivacy, false, extendedAttributes, premiumPrice);
52+
return new TransferOptions(registrantId, authCode, whoisPrivacy, false, extendedAttributes, premiumPrice, trusteeService);
5153
}
5254

5355
/**
@@ -57,13 +59,23 @@ public TransferOptions noAutoRenew() {
5759
public TransferOptions extendedAttribute(String name, String value) {
5860
Map<String, String> newExtendedAttributes = new HashMap<>(extendedAttributes);
5961
newExtendedAttributes.put(name, value);
60-
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, newExtendedAttributes, premiumPrice);
62+
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, newExtendedAttributes, premiumPrice, trusteeService);
6163
}
6264

6365
/**
6466
* Required as confirmation of the price, only if the domain is premium.
6567
*/
6668
public TransferOptions premiumPrice(String premiumPrice) {
67-
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, extendedAttributes, premiumPrice);
69+
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, extendedAttributes, premiumPrice, trusteeService);
70+
}
71+
72+
/**
73+
* Enable trustee service as part of the domain transfer.
74+
*
75+
* <p>This parameter is optional; if you never call this method, the SDK will omit
76+
* {@code trustee_service} from the JSON request payload.</p>
77+
*/
78+
public TransferOptions trusteeService() {
79+
return new TransferOptions(registrantId, authCode, whoisPrivacy, autoRenew, extendedAttributes, premiumPrice, true);
6880
}
6981
}

src/test/java/com/dnsimple/endpoints/RegistrarTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public void testGetDomainTransfer() {
165165
assertThat(transfer.getState(), is("cancelled"));
166166
assertThat(transfer.hasAutoRenew(), is(false));
167167
assertThat(transfer.hasWhoisPrivacy(), is(false));
168+
assertThat(transfer.hasTrusteeService(), is(false));
168169
assertThat(transfer.getStatusDescription(), is("Canceled by customer"));
169170
assertThat(transfer.getCreatedAt(), is("2020-06-05T18:08:00Z"));
170171
assertThat(transfer.getUpdatedAt(), is("2020-06-05T18:10:01Z"));
@@ -183,6 +184,7 @@ public void testCancelDomainTransfer() {
183184
assertThat(transfer.getState(), is("transferring"));
184185
assertThat(transfer.hasAutoRenew(), is(false));
185186
assertThat(transfer.hasWhoisPrivacy(), is(false));
187+
assertThat(transfer.hasTrusteeService(), is(false));
186188
assertThat(transfer.getStatusDescription(), isEmptyOrNullString());
187189
assertThat(transfer.getCreatedAt(), is("2020-06-05T18:08:00Z"));
188190
assertThat(transfer.getUpdatedAt(), is("2020-06-05T18:08:04Z"));

0 commit comments

Comments
 (0)