Skip to content
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
2 changes: 1 addition & 1 deletion src/main/java/com/didww/sdk/resource/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

@Type("addresses")
public class Address extends BaseResource {
public class Address extends BaseResource implements ProofEntity {

@JsonProperty("city_name")
private String cityName;
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/didww/sdk/resource/AddressVerification.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class AddressVerification extends BaseResource {
private String status;

@JsonProperty(value = "reject_reasons", access = JsonProperty.Access.WRITE_ONLY)
private List<String> rejectReasons;
private String rejectReasons;

@JsonProperty(value = "reference", access = JsonProperty.Access.WRITE_ONLY)
private String reference;

@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
private OffsetDateTime createdAt;
Expand Down Expand Up @@ -62,10 +65,14 @@ public String getStatus() {
return status;
}

public List<String> getRejectReasons() {
public String getRejectReasons() {
return rejectReasons;
}

public String getReference() {
return reference;
}

public OffsetDateTime getCreatedAt() {
return createdAt;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/didww/sdk/resource/AvailableDid.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ public class AvailableDid extends BaseResource {
@Relationship("did_group")
private DidGroup didGroup;

@Relationship("nanpa_prefix")
private NanpaPrefix nanpaPrefix;

public String getNumber() {
return number;
}

public DidGroup getDidGroup() {
return didGroup;
}

public NanpaPrefix getNanpaPrefix() {
return nanpaPrefix;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/didww/sdk/resource/Did.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class Did extends BaseResource {
@JsonProperty(value = "expires_at", access = JsonProperty.Access.WRITE_ONLY)
private OffsetDateTime expiresAt;

@JsonProperty("billing_cycles_count")
private Integer billingCyclesCount;

@JsonProperty(value = "channels_included_count", access = JsonProperty.Access.WRITE_ONLY)
private Integer channelsIncludedCount;

@Relationship("order")
private Order order;

Expand All @@ -57,6 +63,9 @@ public class Did extends BaseResource {
@Relationship("shared_capacity_group")
private SharedCapacityGroup sharedCapacityGroup;

@Relationship("address_verification")
private AddressVerification addressVerification;

public String getNumber() {
return number;
}
Expand Down Expand Up @@ -117,6 +126,18 @@ public OffsetDateTime getExpiresAt() {
return expiresAt;
}

public Integer getBillingCyclesCount() {
return billingCyclesCount;
}

public void setBillingCyclesCount(Integer billingCyclesCount) {
this.billingCyclesCount = billingCyclesCount;
}

public Integer getChannelsIncludedCount() {
return channelsIncludedCount;
}

public Order getOrder() {
return order;
}
Expand Down Expand Up @@ -156,4 +177,8 @@ public SharedCapacityGroup getSharedCapacityGroup() {
public void setSharedCapacityGroup(SharedCapacityGroup sharedCapacityGroup) {
this.sharedCapacityGroup = sharedCapacityGroup;
}

public AddressVerification getAddressVerification() {
return addressVerification;
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/didww/sdk/resource/DidGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class DidGroup extends BaseResource {
@Relationship("did_group_type")
private DidGroupType didGroupType;

@Relationship("requirement")
private Requirement requirement;

public String getAreaName() {
return areaName;
}
Expand Down Expand Up @@ -78,4 +81,8 @@ public City getCity() {
public DidGroupType getDidGroupType() {
return didGroupType;
}

public Requirement getRequirement() {
return requirement;
}
}
13 changes: 12 additions & 1 deletion src/main/java/com/didww/sdk/resource/Identity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;

@Type("identities")
public class Identity extends BaseResource {
public class Identity extends BaseResource implements ProofEntity {

@JsonProperty("first_name")
private String firstName;
Expand Down Expand Up @@ -47,6 +47,9 @@ public class Identity extends BaseResource {
@JsonProperty("external_reference_id")
private String externalReferenceId;

@JsonProperty("contact_email")
private String contactEmail;

@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
private OffsetDateTime createdAt;

Expand Down Expand Up @@ -161,6 +164,14 @@ public void setExternalReferenceId(String externalReferenceId) {
this.externalReferenceId = externalReferenceId;
}

public String getContactEmail() {
return contactEmail;
}

public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}

public OffsetDateTime getCreatedAt() {
return createdAt;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/didww/sdk/resource/Proof.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class Proof extends BaseResource {
@JsonProperty("expires_at")
private OffsetDateTime expiresAt;

@Relationship("entity")
private ProofEntity entity;

@Relationship("proof_type")
private ProofType proofType;

Expand All @@ -30,6 +33,14 @@ public OffsetDateTime getExpiresAt() {
return expiresAt;
}

public ProofEntity getEntity() {
return entity;
}

public void setEntity(ProofEntity entity) {
this.entity = entity;
}

public ProofType getProofType() {
return proofType;
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/didww/sdk/resource/ProofEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.didww.sdk.resource;

/**
* Marker interface for resources that can be the entity of a Proof.
* Supports polymorphic relationship - entity can be either Identity or Address.
*/
public interface ProofEntity {
String getId();
}
8 changes: 8 additions & 0 deletions src/main/java/com/didww/sdk/resource/VoiceInTrunkGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.jasminb.jsonapi.annotations.Relationship;
import com.github.jasminb.jsonapi.annotations.Type;

import java.time.OffsetDateTime;
import java.util.List;

@Type("voice_in_trunk_groups")
Expand All @@ -15,6 +16,9 @@ public class VoiceInTrunkGroup extends BaseResource {
@JsonProperty("capacity_limit")
private Integer capacityLimit;

@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
private OffsetDateTime createdAt;

@Relationship("voice_in_trunks")
private List<VoiceInTrunk> voiceInTrunks;

Expand All @@ -34,6 +38,10 @@ public void setCapacityLimit(Integer capacityLimit) {
this.capacityLimit = capacityLimit;
}

public OffsetDateTime getCreatedAt() {
return createdAt;
}

public List<VoiceInTrunk> getVoiceInTrunks() {
return voiceInTrunks;
}
Expand Down
60 changes: 60 additions & 0 deletions src/test/java/com/didww/sdk/resource/ProofTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,66 @@ void testCreateProof() {
assertThat(created.getCreatedAt()).isNotNull();
}

@Test
void testCreateProofWithIdentityEntity() {
wireMock.stubFor(post(urlPathEqualTo("/v3/proofs"))
.withRequestBody(equalToJson(loadFixture("proofs/create_with_identity_request.json"), true, false))
.willReturn(aResponse()
.withStatus(201)
.withHeader("Content-Type", "application/vnd.api+json")
.withBody(loadFixture("proofs/create_with_identity.json"))));

ProofType proofType = new ProofType();
proofType.setId("d2c1b3fb-29f7-46ca-ba82-b617f4630b78");

EncryptedFile encryptedFile = new EncryptedFile();
encryptedFile.setId("cc52b6b3-0627-47d3-a1c9-b54d3de42813");

Identity identity = new Identity();
identity.setId("54c92d8e-f135-4b55-ac48-748d44437509");

Proof proof = new Proof();
proof.setProofType(proofType);
proof.setFiles(Collections.singletonList(encryptedFile));
proof.setEntity(identity);

ApiResponse<Proof> response = client.proofs().create(proof);
Proof created = response.getData();

assertThat(created.getId()).isEqualTo("84155378-88d5-456e-844d-103596e3fb2c");
assertThat(created.getCreatedAt()).isNotNull();
}

@Test
void testCreateProofWithAddressEntity() {
wireMock.stubFor(post(urlPathEqualTo("/v3/proofs"))
.withRequestBody(equalToJson(loadFixture("proofs/create_with_address_request.json"), true, false))
.willReturn(aResponse()
.withStatus(201)
.withHeader("Content-Type", "application/vnd.api+json")
.withBody(loadFixture("proofs/create_with_address.json"))));

ProofType proofType = new ProofType();
proofType.setId("d2c1b3fb-29f7-46ca-ba82-b617f4630b78");

EncryptedFile encryptedFile = new EncryptedFile();
encryptedFile.setId("cc52b6b3-0627-47d3-a1c9-b54d3de42813");

Address address = new Address();
address.setId("54c92d8e-f135-4b55-ac48-748d44437509");

Proof proof = new Proof();
proof.setProofType(proofType);
proof.setFiles(Collections.singletonList(encryptedFile));
proof.setEntity(address);

ApiResponse<Proof> response = client.proofs().create(proof);
Proof created = response.getData();

assertThat(created.getId()).isEqualTo("84155378-88d5-456e-844d-103596e3fb2c");
assertThat(created.getCreatedAt()).isNotNull();
}

@Test
void testDeleteProof() {
String id = "ed46925b-a830-482d-917d-015858cf7ab9";
Expand Down
27 changes: 27 additions & 0 deletions src/test/resources/fixtures/proofs/create_with_address.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"data": {
"id": "84155378-88d5-456e-844d-103596e3fb2c",
"type": "proofs",
"attributes": {
"created_at": "2021-03-28T18:01:50.387Z",
"expires_at": null
},
"relationships": {
"proof_type": {
"links": {
"self": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/relationships/proof_type",
"related": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/proof_type"
}
},
"entity": {
"links": {
"self": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/relationships/entity",
"related": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/entity"
}
}
}
},
"meta": {
"api_version": "2022-05-10"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"data": {
"type": "proofs",
"attributes": {},
"relationships": {
"files": {
"data": [
{
"type": "encrypted_files",
"id": "cc52b6b3-0627-47d3-a1c9-b54d3de42813"
}
]
},
"proof_type": {
"data": {
"type": "proof_types",
"id": "d2c1b3fb-29f7-46ca-ba82-b617f4630b78"
}
},
"entity": {
"data": {
"type": "addresses",
"id": "54c92d8e-f135-4b55-ac48-748d44437509"
}
}
}
}
}
27 changes: 27 additions & 0 deletions src/test/resources/fixtures/proofs/create_with_identity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"data": {
"id": "84155378-88d5-456e-844d-103596e3fb2c",
"type": "proofs",
"attributes": {
"created_at": "2021-03-28T18:01:50.387Z",
"expires_at": null
},
"relationships": {
"proof_type": {
"links": {
"self": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/relationships/proof_type",
"related": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/proof_type"
}
},
"entity": {
"links": {
"self": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/relationships/entity",
"related": "https://sandbox-api.didww.com/v3/proofs/84155378-88d5-456e-844d-103596e3fb2c/entity"
}
}
}
},
"meta": {
"api_version": "2022-05-10"
}
}
Loading