diff --git a/src/main/java/com/didww/sdk/resource/Address.java b/src/main/java/com/didww/sdk/resource/Address.java index bfd3a03..3a6b22b 100644 --- a/src/main/java/com/didww/sdk/resource/Address.java +++ b/src/main/java/com/didww/sdk/resource/Address.java @@ -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; diff --git a/src/main/java/com/didww/sdk/resource/AddressVerification.java b/src/main/java/com/didww/sdk/resource/AddressVerification.java index dfb72eb..1113d6d 100644 --- a/src/main/java/com/didww/sdk/resource/AddressVerification.java +++ b/src/main/java/com/didww/sdk/resource/AddressVerification.java @@ -23,7 +23,10 @@ public class AddressVerification extends BaseResource { private String status; @JsonProperty(value = "reject_reasons", access = JsonProperty.Access.WRITE_ONLY) - private List 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; @@ -62,10 +65,14 @@ public String getStatus() { return status; } - public List getRejectReasons() { + public String getRejectReasons() { return rejectReasons; } + public String getReference() { + return reference; + } + public OffsetDateTime getCreatedAt() { return createdAt; } diff --git a/src/main/java/com/didww/sdk/resource/AvailableDid.java b/src/main/java/com/didww/sdk/resource/AvailableDid.java index 779ec19..c756ac5 100644 --- a/src/main/java/com/didww/sdk/resource/AvailableDid.java +++ b/src/main/java/com/didww/sdk/resource/AvailableDid.java @@ -13,6 +13,9 @@ public class AvailableDid extends BaseResource { @Relationship("did_group") private DidGroup didGroup; + @Relationship("nanpa_prefix") + private NanpaPrefix nanpaPrefix; + public String getNumber() { return number; } @@ -20,4 +23,8 @@ public String getNumber() { public DidGroup getDidGroup() { return didGroup; } + + public NanpaPrefix getNanpaPrefix() { + return nanpaPrefix; + } } diff --git a/src/main/java/com/didww/sdk/resource/Did.java b/src/main/java/com/didww/sdk/resource/Did.java index 76b34d5..d26dc0d 100644 --- a/src/main/java/com/didww/sdk/resource/Did.java +++ b/src/main/java/com/didww/sdk/resource/Did.java @@ -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; @@ -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; } @@ -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; } @@ -156,4 +177,8 @@ public SharedCapacityGroup getSharedCapacityGroup() { public void setSharedCapacityGroup(SharedCapacityGroup sharedCapacityGroup) { this.sharedCapacityGroup = sharedCapacityGroup; } + + public AddressVerification getAddressVerification() { + return addressVerification; + } } diff --git a/src/main/java/com/didww/sdk/resource/DidGroup.java b/src/main/java/com/didww/sdk/resource/DidGroup.java index 01c5449..dadce27 100644 --- a/src/main/java/com/didww/sdk/resource/DidGroup.java +++ b/src/main/java/com/didww/sdk/resource/DidGroup.java @@ -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; } @@ -78,4 +81,8 @@ public City getCity() { public DidGroupType getDidGroupType() { return didGroupType; } + + public Requirement getRequirement() { + return requirement; + } } diff --git a/src/main/java/com/didww/sdk/resource/Identity.java b/src/main/java/com/didww/sdk/resource/Identity.java index 90ea6cb..4b30890 100644 --- a/src/main/java/com/didww/sdk/resource/Identity.java +++ b/src/main/java/com/didww/sdk/resource/Identity.java @@ -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; @@ -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; @@ -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; } diff --git a/src/main/java/com/didww/sdk/resource/Proof.java b/src/main/java/com/didww/sdk/resource/Proof.java index b4d8be7..9dd3aae 100644 --- a/src/main/java/com/didww/sdk/resource/Proof.java +++ b/src/main/java/com/didww/sdk/resource/Proof.java @@ -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; @@ -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; } diff --git a/src/main/java/com/didww/sdk/resource/ProofEntity.java b/src/main/java/com/didww/sdk/resource/ProofEntity.java new file mode 100644 index 0000000..ea802ee --- /dev/null +++ b/src/main/java/com/didww/sdk/resource/ProofEntity.java @@ -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(); +} diff --git a/src/main/java/com/didww/sdk/resource/VoiceInTrunkGroup.java b/src/main/java/com/didww/sdk/resource/VoiceInTrunkGroup.java index 19e7688..24e74fe 100644 --- a/src/main/java/com/didww/sdk/resource/VoiceInTrunkGroup.java +++ b/src/main/java/com/didww/sdk/resource/VoiceInTrunkGroup.java @@ -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") @@ -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 voiceInTrunks; @@ -34,6 +38,10 @@ public void setCapacityLimit(Integer capacityLimit) { this.capacityLimit = capacityLimit; } + public OffsetDateTime getCreatedAt() { + return createdAt; + } + public List getVoiceInTrunks() { return voiceInTrunks; } diff --git a/src/test/java/com/didww/sdk/resource/ProofTest.java b/src/test/java/com/didww/sdk/resource/ProofTest.java index bc26824..be547cf 100644 --- a/src/test/java/com/didww/sdk/resource/ProofTest.java +++ b/src/test/java/com/didww/sdk/resource/ProofTest.java @@ -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 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 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"; diff --git a/src/test/resources/fixtures/proofs/create_with_address.json b/src/test/resources/fixtures/proofs/create_with_address.json new file mode 100644 index 0000000..8935417 --- /dev/null +++ b/src/test/resources/fixtures/proofs/create_with_address.json @@ -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" + } +} diff --git a/src/test/resources/fixtures/proofs/create_with_address_request.json b/src/test/resources/fixtures/proofs/create_with_address_request.json new file mode 100644 index 0000000..73da322 --- /dev/null +++ b/src/test/resources/fixtures/proofs/create_with_address_request.json @@ -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" + } + } + } + } +} diff --git a/src/test/resources/fixtures/proofs/create_with_identity.json b/src/test/resources/fixtures/proofs/create_with_identity.json new file mode 100644 index 0000000..8935417 --- /dev/null +++ b/src/test/resources/fixtures/proofs/create_with_identity.json @@ -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" + } +} diff --git a/src/test/resources/fixtures/proofs/create_with_identity_request.json b/src/test/resources/fixtures/proofs/create_with_identity_request.json new file mode 100644 index 0000000..a8b8b45 --- /dev/null +++ b/src/test/resources/fixtures/proofs/create_with_identity_request.json @@ -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": "identities", + "id": "54c92d8e-f135-4b55-ac48-748d44437509" + } + } + } + } +}